Mail Archives: djgpp/1992/07/15/09:02:45
Suppose for some reason I want to read the contents of registers ( the segment
registers, say). I wrote a simple function to accomplish this using gcc's
inline assembler:
#include <dos.h>
#include <stdio.h>
struct SREGS *segregs ;
void segread(struct SREGS *segregs);
/* Read segment registers */
void segread(struct SREGS *segregs)
{
asm
(
"movl %0,%%cs;
movl %1,%%ds;
movl %2,%%es;
movl %3,%%fs;
movl %4,%%gs;
movl %5,%%ss;"
: "=g" (&segregs->cs), "=g" (&segregs->ds), "=g" (&segregs->es),
"=g" (&segregs->fs), "=g" (&segregs->gs), "=g" (&segregs->ss)
);
};
main()
{
void segread(struct SREGS *segregs);
printf("\n\tCS\t%.4x\n\tDS\t%.4x\n\tES\t%.4x\n\tFS\t%.4x\n\tGS\t%.4x\n
\tSS\t%.4x\n", segregs->cs, segregs->ds, segregs->es,
segregs->fs, segregs->gs, segregs->ss);
}
When I try to compile it I get error messages of the sort:
seread.c: In function `segread':
seread.c:21: invalid lvalue in assignment
seread.c:21: invalid lvalue in assignment
seread.c:21: invalid lvalue in assignment
seread.c:21: invalid lvalue in assignment
seread.c:21: invalid lvalue in assignment
seread.c:21: invalid lvalue in assignment
Please can somebody point out to me what I am doing wrong ?
Thank you.
H. I. SALEH
salehh AT atlantis DOT cs DOT orst DOT edu
- Raw text -