22.02.2014 Views

with DOS/4GW? - Open Watcom

with DOS/4GW? - Open Watcom

with DOS/4GW? - Open Watcom

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>DOS</strong> Programming Guide<br />

5.4 How do I access the first megabyte in the extended<br />

<strong>DOS</strong> environment?<br />

Many programmers require access to the first megabyte of memory in order to look at key low<br />

memory addresses. Under <strong>DOS</strong>, it was standard practice to use a far pointer, <strong>with</strong> the far<br />

pointer set to the segmented address of the memory area that was being inspected. Under<br />

<strong>DOS</strong> extenders, this practice is not so standard. Each <strong>DOS</strong> extender provides its own method<br />

for accessing the first megabyte of memory.<br />

5.4.1 Accessing the First Megabyte under Tenberry Software<br />

<strong>DOS</strong>/<strong>4GW</strong><br />

Under <strong>DOS</strong>/<strong>4GW</strong>, the first megabyte of physical memory - the real memory - is mapped as a<br />

shared linear address space. This allows your application to access the first megabyte of<br />

memory using a near pointer set to the linear address. The following program demonstrates<br />

this method. This example is similar to the screen memory access example.<br />

/*<br />

KEYSTAT.C - This example shows how to get the keyboard<br />

status under <strong>DOS</strong>/<strong>4GW</strong> by looking at the ROM BIOS<br />

keyboard status byte in low memory.<br />

Compile & Link: wcl386 /l=dos4g keystat<br />

*/<br />

#include <br />

#include <br />

/*<br />

Under <strong>DOS</strong>, the keyboard status byte has a segmented<br />

address of 0x0040:0x0017. This corresponds to a<br />

linear address of 0x417.<br />

*/<br />

#define LOW AREA 0x417<br />

void main()<br />

{<br />

/* Only need a near pointer in the flat model */<br />

char *ptr;<br />

/* Set pointer to linear address of the first<br />

status byte */<br />

ptr = (char *)LOW AREA;<br />

28 How do I access the first megabyte in the extended <strong>DOS</strong> environment?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!