Mail Archives: djgpp/1999/04/08/15:17:40
Hi,
I wrote inline assembly code to access the control register CR0 and
compiled it
under djgpp. It ran O.k. in window DOS but gave me general protection fault
under
pure DOS environment. The code is as follows.
---------------------------
#include <stdio.h>
unsigned long
getCR0()
{
unsigned long result=0;
__asm__ __volatile__
("pushl %%ebx\n
movl %%cr0, %%ebx\n
movl %%ebx, %0\n
popl %%ebx\n"
: "=b" (result)
:
: "%ebx","%cc", "memory"
);
return result;
}
void
main()
{
unsigned long result;
result=getCR0();
printf("inside getCR0: result=0x%x\n", result);
}
------------------------
I was able to access registers such as eax and ebx using the same inline
technique
under DOS. Anything that I should be aware of? Thanks.
Jay
- Raw text -