Page 1 of 1

About CPU Version

Posted: Sun Jul 30, 2006 6:26 pm
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?

Posted: Mon Jul 31, 2006 6:29 am
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

Thanks

Posted: Mon Jul 31, 2006 6:38 pm
by tresss
OK...
I'm UnderStand....
Thank you very much