Detecting Processor Type:

 

 

Author : Amgad Magdy Madkour

Operating System Sector : Boot

Programming  Language : Assembly

Revision : None

Last Update : 24/7/2002

 

 

The detecting of the type of the processor mainly depends on the flag register, in our version of the Operating system we are depending on having a processor of 386+ to work on , in this version we have an Extended Flag Register (EFLAGS) which is a 32 bit register , in our case we care about bits from 12 to 15 which are

 

12 : IOPL = I/O Privilege Level flag , permissions are from 0-3

13 : NT = Nested Task Flag

14 : RF = Resume Flag

15 : VM = Virtual Mode Flag or to be exact Virtual 86 Mode Flag 

 

 

In the case that the processor is a 386 those bits would be modifiable bits , in the 8086 processor those bits will be all set to 1 ( 1111) and wont be allowed to be modified . In case that the processor is not an 8086 and maybe an 80286 then the bits would be (0111) but we wont be implementing checking code for that because we will only care about a 386 processor and anything else would be refused .

 

Now with the coding :

 

;Programmed By Amgad Madkour

;First of all we save the flag register by putting it into the stack

pushf

 

;next we make the high bit of the ax register = 0  , ah=0

xor ah,ah

 

;then we push ax on the stack , now we have flags and ax in the stack

push ax

 

;this means pop whats in the stack (top element) into the flag register

; what will be popped is the ax which is all 0’s into the flag register

popf

 

 

;push what is in the flag register into the stack after modification in

;the flag register via ax register

pushf

 

;pop whats in the stack which is the modified flags into ax for inspection

pop ax

 

;and (1111) in what is stored in the ah which represents what has been modified

;the result will be stored in the accumulator (ax)

; we want to and only the high bits if the (ax)

and ah,0f0h

 

; at this point if the result in the ah is 1111

cmp ah,0f0h

 

;then  the processor is not a 386

je no386

 

;else if not 1111 then it had been modified , then it’s a 386

;print that the user is having a 386+ processor

;those two are just printing procedures

mov si,is386

call kprint

 

 

Conclusion

 

This document has shown how to detect 386 + processor in a very simple way with small set of instructions .

 

TiTan OS Notes :

 

This File Depends On

None

 

This File is used by

Kernel Initialization structure

 

 

Any questions and comments about what is written would be appreciated and I would receive them on my mail , amgadmadkour@hotmail.com 

 

                                                                              Copyrights 2002 to the author