delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/07/15/09:02:45

Date: Wed, 15 Jul 92 05:06:30 -0700
From: Hassan Saleh <salehh AT atlantis DOT CS DOT ORST DOT EDU>
To: djgpp AT sun DOT soe DOT clarkson DOT edu

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019