JABHACK.ASM (1764B)
1 ; JABHACK.ASM 2 3 .386C 4 IDEAL 5 MODEL MEDIUM 6 7 EXTRN LDIV@:far 8 9 ;============================================================================ 10 11 DATASEG 12 13 EXTRN _intaddr:word 14 15 ;============================================================================ 16 17 CODESEG 18 19 ; Hacked up Juan Jimenez's code a bit to just return 386/not 386 20 PROC _CheckIs386 21 PUBLIC _CheckIs386 22 23 pushf ; Save flag registers, we use them here 24 xor ax,ax ; Clear AX and... 25 push ax ; ...push it onto the stack 26 popf ; Pop 0 into flag registers (all bits to 0), 27 pushf ; attempting to set bits 12-15 of flags to 0's 28 pop ax ; Recover the save flags 29 and ax,08000h ; If bits 12-15 of flags are set to 30 cmp ax,08000h ; zero then it's 8088/86 or 80188/186 31 jz not386 32 33 mov ax,07000h ; Try to set flag bits 12-14 to 1's 34 push ax ; Push the test value onto the stack 35 popf ; Pop it into the flag register 36 pushf ; Push it back onto the stack 37 pop ax ; Pop it into AX for check 38 and ax,07000h ; if bits 12-14 are cleared then 39 jz not386 ; the chip is an 80286 40 41 mov ax,1 ; We now assume it's a 80386 or better 42 popf 43 retf 44 45 not386: 46 xor ax,ax 47 popf 48 retf 49 50 ENDP 51 52 53 PROC _jabhack2 54 PUBLIC _jabhack2 55 56 jmp @@skip 57 58 @@where: 59 int 060h 60 retf 61 62 @@skip: 63 push es 64 65 mov ax,seg LDIV@ 66 mov es,ax 67 mov ax,[WORD PTR @@where] 68 mov [WORD FAR es:LDIV@],ax 69 mov ax,[WORD PTR @@where+2] 70 mov [WORD FAR es:LDIV@+2],ax 71 72 mov ax,offset @@jabdiv 73 mov [_intaddr],ax 74 mov ax,seg @@jabdiv 75 mov [_intaddr+2],ax 76 77 pop es 78 retf 79 80 @@jabdiv: 81 add sp,4 ;Nuke IRET address, but leave flags 82 push bp 83 mov bp,sp ;Save BP, and set it equal to stack 84 cli 85 86 mov eax,[bp+8] 87 cdq 88 idiv [DWORD PTR bp+12] 89 mov edx,eax 90 shr edx,16 91 92 pop bp ;Restore BP 93 popf ;Restore flags (from INT) 94 retf 8 ;Return to original caller 95 96 ENDP 97 98 END