About CPU Version

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
tresss
Posts: 21
Joined: Thu Jul 06, 2006 10:52 pm

About CPU Version

Post by tresss »

the Source is in menuetOS:

Code: Select all

        pushf
        pop     ax
        mov     dx,ax
        xor     ax,0x4000
        push    ax
        popf
        pushf
        pop     ax
        and     ax,0x4000
        and     dx,0x4000
        cmp     ax,dx
        jnz     cpugood
        mov     si,not386-0x10000
        call    print
        jmp     $
     cpugood:
why can it check the version of CPU?
http://english.writeos.com

My English is not very good
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Post by Mikae »

AFAIK, bits 12-15 on 8086 always set to '1'and bits 12-15 on 80286 always set to '0'. This code inverts bit 14 and tries to save it back to FLAGS. If FLAGS is changed it means that the processor is not 80286 & 8086, but higher.

Note, that the code doesn't restore previous value of bit 14 (may be it does it later in 'cpugood' branch?). If not, you have to add something like:

Code: Select all

pushf
pop ax
xor ax, 0x4000
push ax
popf
tresss
Posts: 21
Joined: Thu Jul 06, 2006 10:52 pm

Thanks

Post by tresss »

OK...
I'm UnderStand....
Thank you very much
http://english.writeos.com

My English is not very good
Post Reply