Mail Archives: djgpp/2003/05/22/13:15:10
Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> wrote in message news:<bai9bg$mk2$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>...
> wfrogers <rogers AT westmont DOT edu> wrote:
> > I am trying to access 0xD000 using a simple C program compiled with
> > DJGPP and am getting
>
> *How* are you accessing it? You should have no problems at all doing
> this with the farptr functions or _dosmemget/put.
Thanks for your reply. By the way, the subject header I originally
included ought to have read "upper" memory, since the D page is within
the 1MB dos conventional memory.
I'll copy below the code in its two versions, one to read from video
memory (which works) and the same code modified to read from
the D page (in which data from the acquisition card is stored in
4-byte words), which doesn't work. The symptom is that data read from
memory and written to screen bears little or no resemblence to the
data that should be stored there from the acquisition card, and
changing the offset to look at different portions of that page doesn't
change the output dumped to screen. In the video memory example,
changing the offset successfully reads different portions of the
screen and correctly writes their ascii code values to the standard
output.
***** First example, reading from video memory *****
#include <go32.h>
#include <sys/farptr.h>
#include <string.h>
int main() {
int i, length, Y, X;
printf("Offset:");
scanf("%i", Y);
X = 10;
long buffer[X+10];
for(i = 0; i <= X+10; i++){
buffer[i] = 0;
}
length = X;
_farsetsel(_dos_ds);
for(i = 0; i < length; i++) {
buffer[i] = _farnspeekb( 0xB800*16+Y+i);
}
for (i = 0; i < (length); i++) {
printf("\n%8li", buffer[i]);
}
return 0;
}
***** Second example, reading from D-page memory *****
.
#include <go32.h>
#include <sys/farptr.h>
#include <string.h>
int main() {
int i, length, Y, X;
printf("Offset:");
scanf("%i", Y);
X = 10;
long buffer[X+10];
for(i = 0; i <= X+10; i++){
buffer[i] = 0;
}
length = X;
_farsetsel(_dos_ds);
for(i = 0; i < length; i++) {
buffer[i] = _farnspeekl( 0xD000L*16+Y+i);
}
for (i = 0; i < (length); i++) {
printf("\n%8li", buffer[i]);
}
return 0;
}
Thanks! WFR
p.s. the same symptoms occur in the second example if we use
_farnspeekb, and/or if we specify the memory segment without the L
qualifier.
- Raw text -