flat assembler
Message board for the users of flat assembler.

Index > DOS > What is wrong in this EXE code? (get cpu type)

Author
Thread Post new topic Reply to topic
prana



Joined: 28 Aug 2003
Posts: 51
prana
Could someone suggest me what's wrong in the following code:

Code:

format MZ
;
getcpu: mov     bx,sp
        mov     ax,sp
        and     sp,not 3
        mov     cl,20h
        shr     ax,cl
        jz      getcp5   ;8086/8088
        push    sp
        pop     ax
        test    al,2
        mov     al,1
        jnz     getcp5  ;80186
        inc     ax
        sgdt    fword ptr gdtadr
        cmp     byte  ptr gdtadr+5,0ffh
        jz      getcp5    ;80286
        pushfd
        pushfd
        pop     eax
        or      eax,240000h
        push    eax
        popfd
        pushfd
        pop     eax
        shr     eax,10h
        and     al,24h
        jz      getcp3  ;80386
        cmp     al,4
        jz      getcp4  ;80486
        mov     ax,1
        cpuid
        mov     al,ah
        and     al,0fh
        jmp     getcp4
getcp3: mov     al,3
getcp4: popfd
getcp5: mov     sp,bx
        ret

gdtadr  dw      0ffffh
        times   3       dw      0
gigadsc dw      0ffffh
        dw      0
        db      0
        db      92h
        dw      8fh          

    


Thanks for any help.
Post 02 Oct 2003, 20:29
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7752
Location: Kraków, Poland
Tomasz Grysztar
You cannot end MZ program with "ret" instruction. Replace it with:
Code:
mov ah,4Ch
int 21h    

and it should be OK.
Post 02 Oct 2003, 21:25
View user's profile Send private message Visit poster's website Reply with quote
prana



Joined: 28 Aug 2003
Posts: 51
prana
Thanks a lot Privalov.
Regards.
Post 03 Oct 2003, 03:53
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.