www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/08/15:17:40

Message-ID: <F554E1189472D21198D000805F654BFE05FA58@ntxchangerend.engr.rendition.com>
From: yjtseng <yjtseng AT micron DOT com>
To: djgpp AT delorie DOT com
Cc: yjtseng AT micron DOT com
Subject: Help needed in getting CR0 under DOS
Date: Thu, 8 Apr 1999 13:17:26 -0600
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)
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 <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 -


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