1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

How many x86 instructions?

Discussion in 'Intel' started by Yousuf Khan, Feb 20, 2014.

  1. On Sat, 26 Apr 2014 01:58:41 +0100, Yousuf Khan
    <> wrote:

    > On 25/04/2014 5:54 AM, Stanley Daniel de Liver wrote:
    >> On Fri, 21 Feb 2014 05:55:02 -0000, Yousuf Khan
    >> <> wrote:
    >>> I remember I designed an early version of the CPUID program that ran
    >>> under DOS. The whole executable including its *.exe headers was
    >>> something like 40 bytes! Got it down to under 20 bytes when I
    >>> converted it to *.com (which had no headers)! Most of the space was
    >>> used to store strings, like "This processor is a:" followed by
    >>> generated strings like 386SX or 486DX, etc. :)

    I doubt the minimalism; a print rtn is 6 bytes, and the text "This
    processor is a:" is 20 on it's own!

    >>> You could make some really tiny assembler programs on x86. Of course,
    >>> compiled programs ignored most of these useful high-level instructions
    >>> and stuck with simple instructions to do everything.
    >>> Yousuf Khan

    >> Did you cater for all the early cpus?
    >> ;This code assembles under nasm as 105 bytes of machine code, and will
    >> ;return the following values in ax:
    >> ;
    >> ;AX CPU
    >> ;0 8088 (NMOS)
    >> ;1 8086 (NMOS)
    >> ;2 8088 (CMOS)
    >> ;3 8086 (CMOS)
    >> ;4 NEC V20
    >> ;5 NEC V30
    >> ;6 80188
    >> ;7 80186
    >> ;8 286
    >> ;0Ah 386 and higher


    (this wasn't my code, I probably had it from clax some years back)
    > I don't know if I still have my old program anymore, but I do remember
    > at that time it could distinguish 386SX from DX and 486SX from DX as
    > well.
    > Yousuf Khan

    Here's the routine I boiled it down to:
    ; mikes shorter test for processor
    mov ax,07000h
    push ax
    pop ax
    and ah,0C0h ; isolate top 2 bits
    shr ah,1 ; avoid negative
    cmp ah,020h
    ; anything greater means 8086 - but 80 =-1!
    ; anything less means bit 4 off, i.e 286
    ; equal implies 386

    of course when the CPUID instruction was introduced it made the later
    chips much easier to identify!
    It's a money /life balance.
    Stanley Daniel de Liver, Apr 26, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.