Message-ID: <370CFD59.82E25337@rendition.com> From: Jay Yichang Tseng X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Help needed in getting CR0 under DOS Content-Type: text/plain; charset=big5 Content-Transfer-Encoding: 7bit Lines: 46 Date: Thu, 08 Apr 1999 18:58:11 GMT NNTP-Posting-Host: 204.242.232.44 NNTP-Posting-Date: Thu, 08 Apr 1999 14:58:11 EDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 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