OSDev.org

The Place to Start for Operating System Developers
It is currently Mon May 06, 2024 2:44 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: 32 bit
PostPosted: Sat Jan 20, 2007 7:47 am 
Offline
Member
Member

Joined: Sun Jan 07, 2007 7:54 am
Posts: 39
heres just a quick question. If i want to use the 32 bit registers do i have to be in protected mode?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 7:48 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 1223
Location: Sweden
No, but you better check so that it's a 386 or higher first.

_________________
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 20, 2007 7:51 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 11:33 pm
Posts: 3882
Location: Eindhoven
bubach wrote:
No, but you better check so that it's a 386 or higher first.

or register an invalid opcode handler (which then errs out) or just expect a crash.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 30, 2007 8:26 am 
Offline
Member
Member

Joined: Mon Jan 08, 2007 3:19 am
Posts: 30
Location: UK
The invalid opcode exception was only introduced on 386, IIRC. I once wrote a 386 detection routine that was small enough to fit in my boot sector, alongside the routine to load my stage 2 boot loader from a file in the root directory of a FAT filesystem, AND intelligible error messages for when stuff went wrong. I thought that was pretty cool at the time! :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 30, 2007 11:44 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2004 11:00 pm
Posts: 874
Location: WA
if you want the code for this, it is quite simple:

Code:
MOV AX, 0xF000           ; set all the high bits to 1
PUSHF                    ; save state of flags register before modifying
PUSH AX
POPF                     ; move AX into FLAGS
PUSHF
POP AX                   ; move it back -- anything in flags forced to a specific value is changed
POPF                     ; restore previous flags
AND AH,0xF0              ; mask out the bottom part, and move it into flags for checking
JS no386                 ; the sign bit is only set on 8086/8
JZ no386                 ; bits 12:15 0 on start, and cannot be changed in RMode on 286,
                                                ; but can on 386


:386code                 ; if you get here you have a 386

standard disclaimer:
this code is public domain, and can be used by anyone for any reason, and modified in any way -- im not responsible for any problems with this code

_________________
## ---- ----- ------ Intel Manuals
OSdev wiki


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Bing [Bot], DotBot [Bot] and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group