JABHACK.ASM 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ; Catacomb Armageddon Source Code
  2. ; Copyright (C) 1993-2014 Flat Rock Software
  3. ;
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License along
  15. ; with this program; if not, write to the Free Software Foundation, Inc.,
  16. ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. ; JABHACK.ASM
  18. .386C
  19. IDEAL
  20. MODEL MEDIUM
  21. EXTRN LDIV@:far
  22. ;============================================================================
  23. DATASEG
  24. EXTRN _intaddr:word
  25. ;============================================================================
  26. CODESEG
  27. ; Hacked up Juan Jimenez's code a bit to just return 386/not 386
  28. PROC _CheckIs386
  29. PUBLIC _CheckIs386
  30. pushf ; Save flag registers, we use them here
  31. xor ax,ax ; Clear AX and...
  32. push ax ; ...push it onto the stack
  33. popf ; Pop 0 into flag registers (all bits to 0),
  34. pushf ; attempting to set bits 12-15 of flags to 0's
  35. pop ax ; Recover the save flags
  36. and ax,08000h ; If bits 12-15 of flags are set to
  37. cmp ax,08000h ; zero then it's 8088/86 or 80188/186
  38. jz not386
  39. mov ax,07000h ; Try to set flag bits 12-14 to 1's
  40. push ax ; Push the test value onto the stack
  41. popf ; Pop it into the flag register
  42. pushf ; Push it back onto the stack
  43. pop ax ; Pop it into AX for check
  44. and ax,07000h ; if bits 12-14 are cleared then
  45. jz not386 ; the chip is an 80286
  46. mov ax,1 ; We now assume it's a 80386 or better
  47. popf
  48. retf
  49. not386:
  50. xor ax,ax
  51. popf
  52. retf
  53. ENDP
  54. PROC _jabhack2
  55. PUBLIC _jabhack2
  56. jmp @@skip
  57. @@where:
  58. int 060h
  59. retf
  60. @@skip:
  61. push es
  62. mov ax,seg LDIV@
  63. mov es,ax
  64. mov ax,[WORD PTR @@where]
  65. mov [WORD FAR es:LDIV@],ax
  66. mov ax,[WORD PTR @@where+2]
  67. mov [WORD FAR es:LDIV@+2],ax
  68. mov ax,offset @@jabdiv
  69. mov [_intaddr],ax
  70. mov ax,seg @@jabdiv
  71. mov [_intaddr+2],ax
  72. pop es
  73. retf
  74. @@jabdiv:
  75. add sp,4 ;Nuke IRET address, but leave flags
  76. push bp
  77. mov bp,sp ;Save BP, and set it equal to stack
  78. cli
  79. mov eax,[bp+8]
  80. cdq
  81. idiv [DWORD PTR bp+12]
  82. mov edx,eax
  83. shr edx,16
  84. pop bp ;Restore BP
  85. popf ;Restore flags (from INT)
  86. retf 8 ;Return to original caller
  87. ENDP
  88. END