.model tiny .data one dt 1.0 bugnr dt 824633702449.0 feature_bits dd ? cprt db 'Pentium FDIV bug finder. (c) Terje Mathisen 1994',13,10,'$' I808x$ db 'This is an 808x cpu',13,10,'$' I286$ db 'This is a 286 cpu',13,10,'$' I386$ db 'This is a 386 cpu',13,10,'$' I486$ db 'This is a 486 cpu',13,10,'$' earlyP5$ db 'This is an early Pentium, with partial CPUID support!',13,10,'$' cpuid4$ db 'It supports CPUID:',13,10,'$' cpuid5$ db 'This is a Pentium or better cpu, with full CPUID support:' db 13,10,'$' vendor$ db 'Vendor id = "' vendor_id dd 3 dup (?) db '"',13,10 db 'Make = ' make$ dw '00' db ', stepping = ' step$ dw '00' db ', model = ' model$ dw '00' db 13,10,'$' FPU_bug$ db 'It has the FDIV bug!',13,10 db '(1.0/824633702449.0)*824633702449.0 is not equal to 1.0!',13,10,'$' FPU_OK$ db 'It does not have the FDIV bug!',13,10,'$' P5$ db 'This is a Pentium cpu',13,10,'$' stepping db ? CPUModel db ? Notp5$ db 'The FDIV bug occurs only on Pentium cpus!',13,10,'$' .code org 100h start: pushf pop ax and ah,0fh ; Try to clear four upper flag bits! push ax popf pushf pop ax cmp ah,0f0h lea dx,[i808x$] jae notP5 ; All four upper bits set -> 808x! or ah,0f0h ; Try to set the upper four bits: push ax popf pushf pop ax and ah,0f0h ; Isolate them lea dx,[i286$] jz notP5 ; Just a 286, no FDIV problem! ; ; *************** 386+ code ******************* ; .486 pushfd mov edx,esp and esp,not 3 ; DWORD-align ESP! pushfd pop eax mov ecx,eax xor ecx,1 SHL 18 push ecx popfd pushfd pop ecx push eax popfd mov esp,edx xor ecx,eax lea dx,[i386$] jz notP5 ; This is a 386! mov ecx,eax xor eax,1 SHL 21 push eax popfd pushfd pop eax xor eax,ecx jnz haveCPUID lea dx,[i486$] notP5: mov ah,9 int 21h lea dx,[notP5$] exitMsg: mov ah,9 int 21h mov ax,4c00h int 21h ; All done! cpuid486: lea dx,[i486$] mov ah,9 int 21h lea dx,[cpuid4$] mov ah,9 int 21h lea dx,[vendor$] jmp exitMsg haveCPUID: ; Use CPUID to get more info! xor eax,eax db 0Fh, 0A2h ; CPUID opcode! mov [vendor_id],ebx mov [vendor_id+4],edx mov [vendor_id+8],ecx test eax,eax lea dx,[earlyP5$] jz earlyp5 mov eax,1 db 0Fh, 0A2h ; CPUID mov [feature_bits],edx and ah,15 ; CPU Make [4(486), 5 (Pentium) etc] mov cl,ah ; Save it! mov ah,al shr ah,4 and al,15 mov [stepping],al mov [CpuModel],ah mov bh,ah xor ah,ah mov bl,10 div bl add ax,'00' mov [step$],ax mov al,bh xor ah,ah div bl add ax,'00' mov [model$],ax mov al,cl xor ah,ah div bl add ax,'00' mov [make$],ax cmp cl,5 jb cpuid486 ; This is at least a Pentium cpu, check for FPU bug: lea dx,[cpuid5$] mov ah,9 int 21h lea dx,[vendor$] earlyp5: mov ah,9 int 21h finit fld [one] fld [bugnr] fdivp st(1),st fld [bugnr] fmulp st(1),st fld [one] fcompp fstsw ax sahf lea dx,[FPU_bug$] jne exitMsg lea dx,[FPU_OK$] jmp exitMsg end start