1 ; Catacomb Armageddon Source Code
\r
2 ; Copyright (C) 1993-2014 Flat Rock Software
\r
4 ; This program is free software; you can redistribute it and/or modify
\r
5 ; it under the terms of the GNU General Public License as published by
\r
6 ; the Free Software Foundation; either version 2 of the License, or
\r
7 ; (at your option) any later version.
\r
9 ; This program is distributed in the hope that it will be useful,
\r
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 ; GNU General Public License for more details.
\r
14 ; You should have received a copy of the GNU General Public License along
\r
15 ; with this program; if not, write to the Free Software Foundation, Inc.,
\r
16 ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
26 ;============================================================================
\r
32 ;============================================================================
\r
36 ; Hacked up Juan Jimenez's code a bit to just return 386/not 386
\r
40 pushf ; Save flag registers, we use them here
\r
41 xor ax,ax ; Clear AX and...
\r
42 push ax ; ...push it onto the stack
\r
43 popf ; Pop 0 into flag registers (all bits to 0),
\r
44 pushf ; attempting to set bits 12-15 of flags to 0's
\r
45 pop ax ; Recover the save flags
\r
46 and ax,08000h ; If bits 12-15 of flags are set to
\r
47 cmp ax,08000h ; zero then it's 8088/86 or 80188/186
\r
50 mov ax,07000h ; Try to set flag bits 12-14 to 1's
\r
51 push ax ; Push the test value onto the stack
\r
52 popf ; Pop it into the flag register
\r
53 pushf ; Push it back onto the stack
\r
54 pop ax ; Pop it into AX for check
\r
55 and ax,07000h ; if bits 12-14 are cleared then
\r
56 jz not386 ; the chip is an 80286
\r
58 mov ax,1 ; We now assume it's a 80386 or better
\r
84 mov ax,[WORD PTR @@where]
\r
85 mov [WORD FAR es:LDIV@],ax
\r
86 mov ax,[WORD PTR @@where+2]
\r
87 mov [WORD FAR es:LDIV@+2],ax
\r
89 mov ax,offset @@jabdiv
\r
98 add sp,4 ;Nuke IRET address, but leave flags
\r
100 mov bp,sp ;Save BP, and set it equal to stack
\r
105 idiv [DWORD PTR bp+12]
\r
110 popf ;Restore flags (from INT)
\r
111 retf 8 ;Return to original caller
\r