Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 1
mtrap.asm



      1					 ;
      2					 ; GRDB
      3					 ;
      4					 ; Copyright(c)	LADsoft
      5					 ;
      6					 ; David Lindauer, gclind01@starbase.spd.louisville.edu
      7					 ;
      8					 ;
      9					 ; mtrap.asm
     10					 ;
     11					 ; Function: handle the	all traps.  Int	3 and Int 1 are	debug traps and
     12					 ; are handled specially
     13						 ;MASM MODE
     14	    0000				 .model	small
     15						 .386
     16
     17	    0000				 .stack	1024
     18
     19					 include iversion.inc
1    20		  =000E			 verid = 14
     21					 include  eprints.inc
1    22					 PRINT_MESSAGE	 macro	 string
1    23						 call	 PrintFollowingMessage
1    24						 db	 string,0
1    25					 endm
1    26
1    27						 EXTRN	 printspace : PROC
1    28						 EXTRN	 printdword:PROC
1    29						 EXTRN	 printword:PROC
1    30						 EXTRN	 printbyte:PROC
1    31						 EXTRN	 scankey : PROC
1    32						 EXTRN	 crlf :	PROC
1    33
1    34						 EXTRN	 PureChar : PROC
1    35						 EXTRN	 PutChar : PROC
1    36						 EXTRN	 GetKey	: PROC
1    37						 EXTRN	 PrintFollowingMessage : PROC
1    38						 EXTRN	 olMessage : PROC
1    39						 EXTRN	 dgroupMessage : PROC
1    40
     41					 include  eregs.inc
1    42						 EXTRN	 ReadReg : PROC
1    43						 EXTRN	 DisplayRegisters : PROC
1    44						 EXTRN	 ModifyRegisters : PROC
1    45
     46					 include  einput.inc
1    47						 EXTRN	 qerr :	PROC
1    48						 EXTRN	 ReadNumber : PROC
1    49						 EXTRN	 ReadAddress : PROC
1    50						 EXTRN	 Inputhandler :	PROC
1    51						 EXTRN	 WadeSpace : PROC
1    52						 EXTRN	 GetInputLine :	PROC
1    53						 EXTRN	 WadeSpaceOnly : PROC
1    54						 EXTRN	 inputbuffer : byte
1    55					   EXTRN defDS : PROC
1    56					   EXTRN defCS : PROC
     57					 include  ebreaks.inc
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 2
mtrap.asm



1    58						 EXTRN	setbreak : PROC
1    59						 EXTRN	 breaks	: PROC
1    60						 EXTRN	enableBreaks : PROC
1    61						 EXTRN	 disableBreaks : PROC
1    62
     63					 include  eenv.inc
1    64						 EXTRN	 CopyEnv : PROC
1    65						 EXTRN	 TgtPgmEnvSeg :	word
1    66						 EXTRN	 TgtPgmEnvSpaceUsed: word
1    67						 EXTRN	 TgtPgmNamePtr : word
1    68						 EXTRN	 TgtPgmEnvLen :	word
1    69						 EXTRN	 SetEnvName : PROC
1    70						 EXTRN	 QualifyName : PROC
1    71
     72					 include  eloader.inc
1    73						 EXTRN	 MakeEmptyProg : PROC
1    74						 EXTRN	 userbasepsp : word
1    75						 EXTRN	 filelen : dword
1    76						 EXTRN	 loadcommand : byte
1    77						 EXTRN	 loadfile : byte
1    78						 EXTRN	 exeflag : byte
1    79						 EXTRN	 LoadProgram : proc
1    80						 EXTRN	 ParseProgName : PROC
1    81						 EXTRN	 ExeStats : PROC
1    82						 EXTRN	 lastexe : byte
1    83						 EXTRN	 lastip	: dword
1    84						 EXTRN	 lastcs: word
1    85
     86					 include  elogging.inc
1    87						 EXTRN	 LogToFile : PROC
1    88						 EXTRN	 CloseLogFile :	PROC
1    89						 EXTRN	 LoggingStat : PROC
1    90
     91					 include  edos.inc
1    92						 EXTRN	 SetUserPSP :PROC
1    93						 EXTRN	 SetDebugPSP : PROC
1    94						 EXTRN	 userpsp : word
1    95						 EXTRN	 int20handle : PROC
1    96						 EXTRN	 int21handle : PROC
1    97						 EXTRN	 UnLoadProgram : PROC
1    98						 EXTRN	 KillFiles : PROC
1    99						 EXTRN	 int1bh	: PROC
1   100						 EXTRN	 CtrlBrkPressedInDOS : byte
    101					 include  eMemory.inc
1   102						 EXTRN	 ResizeMem : PROC
1   103						 EXTRN	 ReleaseDebugMem : PROC
1   104						 EXTRN	 ReleaseMemory : PROC
1   105						 EXTRN	 tagarena : PROC
1   106
    107					 include  eints.inc
1   108						 EXTRN	 SetRMInts : PROC
1   109						 EXTRN	 IntSnapShot : PROC
1   110						 EXTRN	 UnLoadInts : PROC
1   111						 EXTRN	 ReleaseRMInts : PROC
1   112						 EXTRN	 SetVectAttrib : PROC
1   113						 EXTRN	 intpage : word
1   114						 EXTRN	 int21adr : dword
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 3
mtrap.asm



1   115						 EXTRN	 orgpic	: word
1   116						 EXTRN	 int20adr : dword
1   117
    118					 include  eexec.inc
1   119						 EXTRN	 trap :	PROC
1   120						 EXTRN	 go : PROC
1   121						 EXTRN	 proceed : PROC
1   122						 EXTRN	 callcheck : PROC
1   123						 EXTRN	 cmpstring : PROC
1   124						 EXTRN	 wadeprefix : PROC
1   125
    126					 include eoptions.inc
1   127						 EXTRN	 optdword : byte
1   128						 EXTRN	 optdwordcommand : byte
1   129						 EXTRN	 doopt : PROC
1   130						 EXTRN	 optdiv0 : byte
1   131						 EXTRN	 optpure : byte
1   132					   EXTRN optflat0 : byte
1   133					   EXTRN optsignedimm :	byte
1   134						 EXTRN	 ReadOptions : PROC
1   135						 EXTRN	 WriteOptions :	PROC
1   136						 EXTRN	 opthist : byte
1   137						 EXTRN	 Disassemble32Bit : byte
1   138						 EXTRN	 winshellchk : PROC
1   139					   EXTRN optdosio : byte
    140					 include eloader.inc
1   141						 EXTRN	 MakeEmptyProg : PROC
1   142						 EXTRN	 userbasepsp : word
1   143						 EXTRN	 filelen : dword
1   144						 EXTRN	 loadcommand : byte
1   145						 EXTRN	 loadfile : byte
1   146						 EXTRN	 exeflag : byte
1   147						 EXTRN	 LoadProgram : proc
1   148						 EXTRN	 ParseProgName : PROC
1   149						 EXTRN	 ExeStats : PROC
1   150						 EXTRN	 lastexe : byte
1   151						 EXTRN	 lastip	: dword
1   152						 EXTRN	 lastcs: word
1   153
    154					 include ehistory.inc
1   155						 EXTRN	 LoadHistory : PROC
1   156						 EXTRN	 EnterHistory :	PROC
1   157						 EXTRN	 CheckHistory:PROC
1   158					   EXTRN histoff : PROC
1   159						 EXTRN histon :	PROC
    160					 include eswift.inc
1   161						 EXTRN	 traceon : byte
1   162						 EXTRN	 swiftrace : PROC
1   163						 EXTRN	 untrace : proc
1   164
    165					 include efp.inc
1   166						 EXTRN	 fpcommand : PROC
1   167						 EXTRN	 floatcheck : PROC
1   168
    169					 include ehbreak.inc
1   170						 EXTRN	 hdwebreakcommand : PROC
1   171						 EXTRN	 hdwebreakenable : PROC
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 4
mtrap.asm



1   172						 EXTRN	 hdwebreakdisable : PROC
1   173						 EXTRN	 hdwechk : PROC
1   174
    175
    176						 public	 entry3,indos,entry1
    177						 PUBLIC	 RegdumpFLAGS,RegdumpEAX,RegdumpEBX,RegdumpECX,RegdumpEDX
    178						 PUBLIC	 RegdumpESI,RegdumpEDI,RegdumpEBP
    179						 PUBLIC	 RegdumpESP,RegdumpEIP
    180						 PUBLIC	 RegdumpCS,RegdumpES,RegdumpDS,RegdumpSS,RegdumpFS,RegdumpGS
    181						 PUBLIC	 TrapHandler, _exit, psp
**Error** mtrap.asm(43)	Undefined symbol: TrapHandler
    182						 PUBLIC	 reentry, grdbname, veclist, entry1
    183						 PUBLIC	 stackseg,stackofs, dosver
    184
    185						 extrn checkcpu	: PROC,	FileLoadErr : PROC, trapcount :	dword
    186						 extrn ReTrap :	PROC
    187						 EXTRN	 initflatreal:PROC, rundownflatreal : PROC
    188					 ;
    189					 ; CPU instruction trap	enable flag
    190					 ;
    191		  =0100			 TRAPFLAG = 100h
    192
    193	    0000				 .data
    194	    0000  0000			 stackofs	 dw	 0	 ;to restore out stack in INT1
    195	    0002  0000			 stackseg	 dw	 0
    196					 ;
    197					 ; Register image
    198					 ;
    199	    0004  00			 veclist db	 00h
    200	    0005  006Ar				 dw	 entry0
    201	    0007  01				 db	 1
    202	    0008  0077r				 dw	 entry1
    203	    000A  03				 db	 3
    204	    000B  008Er				 dw	 entry3
    205	    000D  1B				 db	 1bh
    206	    000E  0000e				 dw	 int1bh
    207	    0010  20				 db	 20h
    208	    0011  0000e				 dw	 int20handle
    209	    0013  21				 db	 21h
    210	    0014  0000e				 dw	 int21handle
    211	    0016  FF				 db	 0ffh	 ; trailer
    212	    0017  00000000		 RegdumpFLAGS	 dd	 0
    213	    001B  00000000		 RegdumpEAX	 dd	 0
    214	    001F  00000000		 RegdumpEBX	 dd	 0
    215	    0023  00000000		 RegdumpECX	 dd	 0
    216	    0027  00000000		 RegdumpEDX	 dd	 0
    217	    002B  00000000		 RegdumpESI	 dd	 0
    218	    002F  00000000		 RegdumpEDI	 dd	 0
    219	    0033  00000000		 RegdumpEBP	 dd	 0
    220	    0037  00000000		 RegdumpESP	 dd	 0
    221	    003B  00000000		 RegdumpEIP	 dd	 0
    222	    003F  0000			 RegdumpCS	 dw	 0
    223	    0041  0000			 RegdumpES	 dw	 0
    224	    0043  0000			 RegdumpDS	 dw	 0
    225	    0045  0000			 RegdumpSS	 dw	 0
    226	    0047  0000			 RegdumpFS	 dw	 0
    227	    0049  0000			 RegdumpGS	 dw	 0
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 5
mtrap.asm



    228					 ;
    229	    004B  0000			 dosver	 dw	 0
    230	    004D  0000			 haserr	 dw	 0	 ; If there is an error# on stack
    231	    004F  0000			 errnum	 dw	 0	 ; The error#
    232	    0051  0000			 trapnum dw	 0	 ; The trap#
    233	    0053  00000000		 indos	 dd	 0	 ; pointer to indos flag
    234	    0057  2A 2A	2A 2A 2A 2A 2A+	 grdbname	 db	 '********',0
    235		  2A 00
    236	    0060  0000			 psp	 dw	 0	 ;debugger PSP
    237	    0062  00			 neederr db	 0	 ;flag for file	load result from command line
    238
    239	    0063  00006790		 trappop dd	 6790h	 ;traps	that need to pop a value
    240
    241	    0067				 .code
    242	    0000  47 52	44 42 20 72 65+	 cpuerr	 db	 "GRDB requires	a 386 or better	processor",0
    243		  71 75	69 72 65 73 20+
    244		  61 20	33 38 36 20 6F+
    245		  72 20	62 65 74 74 65+
    246		  72 20	70 72 6F 63 65+
    247		  73 73	6F 72 00
    248	    0028  6E 6F	74 20 65 6E 6F+	 memerr	 db	 "not enough memory/corrupt arena",0
    249		  75 67	68 20 6D 65 6D+
    250		  6F 72	79 2F 63 6F 72+
    251		  72 75	70 74 20 61 72+
    252		  65 6E	61 00
    253	    0048  47 52	44 42 20 72 65+	 vererr	 db	 "GRDB requires	MSDOS 4.0 or better"
    254		  71 75	69 72 65 73 20+
    255		  4D 53	44 4F 53 20 34+
    256		  2E 30	20 6F 72 20 62+
    257		  65 74	74 65 72
    258	    0069  00			 nomsg	 db	 0
    259
    260					 ;This macro generates a front end for the interrupt handlers installed	for
    261					 ;int 0, 1 and 3.
    262
    263					 entry	 macro	 num
    264						 local	 est
    265					 entry&num:
    266					 if num	EQ 1
    267						 call	 hdwechk
    268						 jc	 est
    269						 call	 swiftrace
    270					 endif
    271					 if num	EQ 3
    272						 call	 swiftrace
    273					 endif
    274					 est:
    275						 push	 gs
    276						 push	 fs
    277						 push	 es
    278						 push	 ds
    279						 pushad
    280						 mov	 al,num
    281						 jmp	 traphandler
    282					 endm
    283
    284						 entry	 0
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 6
mtrap.asm



1   285	    006A			 entry0:
1   286	    006A			 ??0000:
1   287	    006A  0F A8				 push	 gs
1   288	    006C  0F A0				 push	 fs
1   289	    006E  06				 push	 es
1   290	    006F  1E				 push	 ds
1   291	    0070  66| 60			 pushad
1   292	    0072  B0 00				 mov	 al,0
1   293	    0074  E9 009E			 jmp	 traphandler
    294						 entry	 1
1   295	    0077			 entry1:
1   296	    0077  E8 0000e			 call	 hdwechk
1   297	    007A  72 05	90 90			 jc	 ??0001
1   298	    007E  E8 0000e			 call	 swiftrace
1   299	    0081			 ??0001:
1   300	    0081  0F A8				 push	 gs
1   301	    0083  0F A0				 push	 fs
1   302	    0085  06				 push	 es
1   303	    0086  1E				 push	 ds
1   304	    0087  66| 60			 pushad
1   305	    0089  B0 01				 mov	 al,1
1   306	    008B  E9 0087			 jmp	 traphandler
    307						 entry	 3
1   308	    008E			 entry3:
1   309	    008E  E8 0000e			 call	 swiftrace
1   310	    0091			 ??0002:
1   311	    0091  0F A8				 push	 gs
1   312	    0093  0F A0				 push	 fs
1   313	    0095  06				 push	 es
1   314	    0096  1E				 push	 ds
1   315	    0097  66| 60			 pushad
1   316	    0099  B0 03				 mov	 al,3
1   317	    009B  EB 78	90			 jmp	 traphandler
    318
    319					 ;
    320					 ; Save	an image of the	regs
    321					 ; This	MUST BE	the first thing	the trap handler calls;	it assumes
    322					 ; there is ONE	PUSH (return address) followed by the DS at the	time
    323					 ; of interrupt	followed by the	interrupt data
    324					 ;
    325	    009E			 saveregs	 PROC
    326	    009E  59				 pop	 cx
    327	    009F  66| 8F 06 002Fr		 pop	 [RegdumpEDI]
    328	    00A4  66| 8F 06 002Br		 pop	 [RegdumpESI]
    329	    00A9  66| 8F 06 0033r		 pop	 [RegdumpEBP]
    330	    00AE  66| 58			 pop	 eax
    331	    00B0  66| 8F 06 001Fr		 pop	 [RegdumpEBX]
    332	    00B5  66| 8F 06 0027r		 pop	 [RegdumpEDX]
    333	    00BA  66| 8F 06 0023r		 pop	 [RegdumpECX]
    334	    00BF  66| 8F 06 001Br		 pop	 [RegdumpEAX]
    335	    00C4  8F 06	0043r			 pop	 [RegdumpDS]
    336	    00C8  8F 06	0041r			 pop	 [RegdumpES]
    337	    00CC  8F 06	0047r			 pop	 [RegdumpFS]
    338	    00D0  8F 06	0049r			 pop	 [RegdumpGS]
    339	    00D4  0F BA	26 004Dr 00		 bt	 [haserr],0	 ; See if an error
    340	    00DA  73 05				 jnc	 short noerr	 ;
    341	    00DC  66| 58			 pop	 eax		 ; Get the error #
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 7
mtrap.asm



    342	    00DE  A3 004Fr			 mov	 [errnum],ax	 ;
    343	    00E1			 noerr:
    344	    00E1  8F 06	003Br			 pop	 word ptr [RegdumpEIP]
    345	    00E5  8F 06	003Fr			 pop	 [RegdumpCS]
    346	    00E9  8F 06	0017r			 pop	 word ptr [RegdumpFLAGS]
    347	    00ED  8C D0				 mov	 ax,ss		 ; Otherwise just save the current
    348	    00EF  A3 0045r			 mov	 [RegdumpSS],ax	 ; stack pointer before	we started pushing
    349	    00F2  66| 89 26 0037r		 mov	 [RegdumpESP],esp	 ;
    350	    00F7  FF E1				 jmp	 cx
    351	    00F9			 saveregs	 ENDP
    352					 ;
    353					 ; Adjust EIP to the trap if it's not int 3
    354					 ;
    355	    00F9			 adjusteip	 PROC
    356	    00F9  83 3E	0051r 03		 cmp	 [trapnum],3	 ; See if int 3
    357	    00FE  75 14				 jnz	 short noadj	 ; No, get out
    358	    0100  66| 8B 1E 003Br		 mov	 ebx,[RegdumpEIP]	 ;
    359	    0105  8E 26	003Fr			 mov	 fs,[RegdumpCS]	 ;
    360	    0109  64: 80 7F FF CC		 cmp	 BYTE PTR fs:[bx-1],0cch ; See if is an	INT 3
    361	    010E  74 04				 jz	 short nodecrement ; Get out if	so
    362	    0110  FF 0E	003Br			 dec	 word ptr [RegdumpEIP]		 ; Else	point at trap
    363	    0114			 nodecrement:
    364	    0114			 noadj:
    365	    0114  C3				 ret
    366	    0115			 adjusteip	 ENDP
    367					 ;
    368					 ; Generic trap	handler, int 1/3
    369					 ;
    370	    0115			 traphandler	 PROC
    371	    0115  FC				 cld
    372	    0116  FB				 sti
    373	    0117  8B 1E	0000			 mov	 bx,dgroup
**Error** mtrap.asm(190) Undefined symbol: dgroup
    374	    011B  8E DB				 mov	 ds,bx
    375	    011D  8E C3				 mov	 es,bx
    376	    011F  C6 06	0000e 00		 mov	 [CtrlBrkPressedInDOS],0
    377	    0124  66| 0F B6 C0			 movzx	 eax,al
    378	    0128  A3 0051r			 mov	 [trapnum],ax
    379	    012B  66| 0F A3 06 0063r		 bt	 [trappop],eax
    380	    0131  73 06	90 90			 jnc	 noerr2
    381	    0135  FF 06	004Dr			 inc	 [haserr]	 ; Set the error flag
    382	    0139			 noerr2:
    383	    0139  BE 0004r			 mov	 si,offset veclist
    384	    013C  E8 0000e			 call	 ReleaseRMInts
    385	    013F  E8 FF5C			 call	 saveregs	 ; Save	Regs
    386	    0142  66| 81 26 0017r     +		 and	 [RegdumpFLAGS],NOT TRAPFLAG ; reset trap flag in flags	image
    387		  FFFFFEFF
    388	    014B  8E 16	0002r			 mov	 ss,[stackseg]	 ; load	our stack
    389	    014F  66| 0F B7 26 0000r		 movzx	 esp,[stackofs]	 ; clear top of	ESP just in case...
    390	    0155  E8 0000e			 call	 disableBreaks	 ; Disable breakpoints if not
    391	    0158  E8 FF9E			 call	 adjusteip	 ; Adjust the EIP to point to the breakpoint
    392	    015B  E8 0000e			 call	 SetDebugPSP
    393	    015E  E8 0000e			 call	 crlf
    394	    0161  83 3E	0051r 03		 cmp	 [trapnum],3	 ; No stats if it is int 3
    395	    0166  74 38				 jz	 short reentry	 ;
    396	    0168  83 3E	0051r 01		 cmp	 [trapnum],1	 ; Or int 1
    397	    016D  74 31				 jz	 short reentry	 ;
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 8
mtrap.asm



    398						 PRINT_MESSAGE	 <'Trap: '>
1   399	    016F  E8 0000e			 call	 PrintFollowingMessage
1   400	    0172  54 72	61 70 3A 20 00		 db	 'Trap:	',0
    401	    0179  A1 0051r			 mov	 ax,[trapnum]	 ; Say which one
    402	    017C  E8 0000e			 call	 printbyte	 ;
    403	    017F  E8 0000e			 call	 crlf
    404	    0182  0F BA	36 004Dr 00		 btr	 [haserr],0	 ; If has error
    405	    0188  73 16	90 90			 jnc	 reentry	 ;
    406						 PRINT_MESSAGE	 <'Error: '>
1   407	    018C  E8 0000e			 call	 PrintFollowingMessage
1   408	    018F  45 72	72 6F 72 3A 20+		 db	 'Error: ',0
    409		  00
    410	    0197  A1 004Fr			 mov	 ax,[errnum]	 ; Say which one
    411	    019A  E8 0000e			 call	 printword
    412	    019D  E8 0000e			 call	 crlf
    413					 ; fall	through
    414	    01A0			 traphandler ENDP
    415	    01A0			 reentry PROC
    416	    01A0  E8 0000e			 call	 DisplayRegisters; Display registers
    417	    01A3  66| F7 06 0000e     +		 test	 [trapcount],-1	 ; see if tracing more than 1
    418		  FFFFFFFF
    419	    01AC  74 0A	90 90			 jz	 noretrace
    420	    01B0  66| FF 0E 0000e		 dec	 [trapcount]	 ; yes,	go do another trace
    421	    01B5  E9 0000e			 jmp	 ReTrap
    422	    01B8			 noretrace:
    423	    01B8  E8 0000e			 call	 initflatreal	 ; put us in flat real mode
    424	    01BB  F6 06	0062r FF		 test	 [neederr],-1	 ; test	if an error (startup usually)
    425	    01C0  0F 84	0000			 jz	 InputHandler
**Error** mtrap.asm(235) Undefined symbol: InputHandler
    426	    01C4  8A 26	0062r			 mov	 ah,[neederr]	 ; yes,	kill it
    427	    01C8  C6 06	0062r 00		 mov	 [neederr],0
    428	    01CD  9E				 sahf
    429	    01CE  E8 0000e			 call	 FileLoadErr	 ; display the error message
    430	    01D1  E9 0000			 jmp	 InputHandler	 ; Go do input
**Error** mtrap.asm(240) Undefined symbol: InputHandler
    431
    432	    01D4			 reentry ENDP
    433					 ;
    434					 ; Monitor init	routine, point all traps to point to the monitor handler
    435					 ;
    436
    437	    01D4			 start:
    438	    01D4  8B 1E	0000			 mov	 bx,dgroup	 ; setup
**Error** mtrap.asm(248) Undefined symbol: dgroup
    439	    01D8  8E DB				 mov	 ds,bx
    440	    01DA  8C 06	0060r			 mov	 [psp],es	 ; our PSP
    441	    01DE  8E C3				 mov	 es,bx		 ;set ES to DX
    442	    01E0  8C D0				 mov	 ax,ss		 ; have	to adjust stack	to be DS-relative
    443	    01E2  2B C3				 sub	 ax,bx		 ; the disassembler requires it
    444	    01E4  C1 E0	04			 shl	 ax,4		 ;to segment
    445	    01E7  03 C4				 add	 ax,sp		 ;add in the stack pointer
    446	    01E9  8E D3				 mov	 ss,bx		 ;set SS to DS
    447	    01EB  8B E0				 mov	 sp,ax		 ;and new stack	based on DS
    448	    01ED  8C 16	0002r			 mov	 [stackseg],ss
    449	    01F1  89 26	0000r			 mov	 [stackofs],sp
    450						 PRINT_MESSAGE	 <"GRDB	version	",30h +VERID/10,'.',30h	+ VERID	MOD 10,	" Copyright +
    451					 (c) LADsoft",13,10,13,10>
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 9
mtrap.asm



1   452	    01F5  E8 0000e			 call	 PrintFollowingMessage
1   453	    01F8  47 52	44 42 20 76 65+		 db	 "GRDB version ",30h +VERID/10,'.',30h + VERID MOD 10, " Copyright (c)	    +
    454		  72 73	69 6F 6E 20 30+	 LADsoft",13,10,13,10,0
    455		  2E 30	20 43 6F 70 79+
    456		  72 69	67 68 74 20 28+
    457		  63 29	20 4C 41 44 73+
    458		  6F 66	74 0D 0A 0D 0A+
    459		  00
**Error** mtrap.asm(260) PRINT_MESSAGE(2) Undefined symbol: VERID
    460	    0223  B4 30				 mov	 ah,30h				 ; dos version check
    461	    0225  CD 21				 int	 21h
    462	    0227  3C 04				 cmp	 al,4
    463	    0229  BA 0048r			 mov	 dx,offset cs:vererr
    464	    022C  0F 82	008C			 jc	 errx
    465	    0230  86 E0				 xchg	 ah,al
    466	    0232  A3 004Br			 mov	 [dosver],ax
    467	    0235  06				 push	 es				 ; get indos flag
    468	    0236  B4 34				 mov	 ah,34h
    469	    0238  CD 21				 int	 21h
    470	    023A  89 1E	0053r			 mov	 word ptr [indos],bx
    471	    023E  8C 06	0055r			 mov	 word ptr [indos+2],es
    472	    0242  07				 pop	 es
    473	    0243  E8 0000e			 call	 checkcpu			 ; validate CPU
    474	    0246  BA 0000r			 mov	 dx,offset cs:cpuerr
    475	    0249  72 71	90 90			 jc	 errx
    476	    024D  E8 0000e			 call	 ResizeMem			 ; cut mem back
    477	    0250  BA 0028r			 mov	 dx,offset cs:memerr
    478	    0253  72 67	90 90			 jc	 errx
    479	    0257  E8 0000			 call	 IntSnapshot			 ; grab	the ints so we can
**Error** mtrap.asm(281) Undefined symbol: IntSnapshot
    480											 ; restoire context later
    481	    025A  BA 0028r			 mov	 dx,offset cs:memerr
    482	    025D  72 4F	90 90			 jc	 errx2
    483	    0261  BE 0057r			 mov	 si,offset grdbname	 ; create data spaces for
    484	    0264  E8 0000e			 call	 MakeEmptyProg			 ; empty prog
    485	    0267  BA 0028r			 mov	 dx,offset cs:memerr
    486	    026A  72 42	90 90			 jc	 errx2
    487	    026E  E8 0000e			 call	 ReadOptions			 ; read	the options disk file
    488	    0271  E8 0000			 call	 FloatCheck			 ; check for an	FP coprocessor
**Error** mtrap.asm(290) Undefined symbol: FloatCheck
    489
    490	    0274  1E				 push	 ds				 ; parse command line params
    491	    0275  8E 1E	0060r			 mov	 ds,[psp]
    492	    0279  BE 0081			 mov	 si,81h
    493	    027C  E8 0000e			 call	 ParseProgName
    494	    027F  1F				 pop	 ds
    495	    0280  F6 06	0000e FF		 test	 [loadfile],-1			 ; load	program
    496	    0285  74 0C	90 90			 jz	 dohist
    497	    0289  2B C0				 sub	 ax,ax
    498	    028B  E8 0000e			 call	 LoadProgram			 ; load	the program
    499	    028E  9F				 lahf
    500	    028F  88 26	0062r			 mov	 [neederr],ah
    501	    0293			 dohist:
    502	    0293  F6 06	0000e FF		 test	 [opthist],0ffh			 ; init	history
    503	    0298  0F 84	FF04			 jz	 reentry
    504	    029C  E8 0000e			 call	 LoadHistory
    505	    029F  E9 FEFE			 jmp	 reentry			 ; get us started
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 10
mtrap.asm



    506					 ;
    507					 ; program exit
    508					 ;
    509	    02A2			 _exit:
    510	    02A2  E8 0000e			 call	 KillFiles			 ; close files they opened
    511	    02A5  E8 0000e			 call	 CloseLogFile			 ; close our log file
    512	    02A8  E8 0000e			 call	 rundownflatreal		 ; no more flat	real mode
    513	    02AB  BA 0069r			 mov	 dx,offset cs:nomsg
    514	    02AE			 errx2:
    515	    02AE  52				 push	 dx
    516	    02AF  E8 0000e			 call	 UnLoadInts			 ; unload int vects
    517	    02B2  E8 0000e			 call	 ReleaseMemory			 ; release any memory tagged
    518											 ; to them
    519	    02B5  E8 0000e			 call	 ReleaseDebugMem		 ; release any memory tagged
    520											 ; to us
    521	    02B8  E8 0000e			 call	 WriteOptions			 ; write options file
    522	    02BB  5A				 pop	 dx
    523	    02BC			 errx:
    524	    02BC  8B DA				 mov	 bx,dx
    525	    02BE  E8 0000e			 call	 olMessage			 ; display whatever message
    526	    02C1  BB 0000			 mov	 bx,0				 ; close the input file
    527	    02C4  B4 3E				 mov	 ah,3eh
    528	    02C6  CD 21				 int	 21h
    529	    02C8  B8 4C00			 mov	 ax,4c00h
    530	    02CB  CD 21				 int	 21h
    531
    532						 END	 start
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 11
Symbol Table




Symbol Name			  Type	 Value

??0000				  Near16 _TEXT:006A
??0001				  Near16 _TEXT:0081
??0002				  Near16 _TEXT:0091
??date				  Text	 "08-31-98"
??filename			  Text	 "mtrap	  "
??time				  Text	 "14:27:44"
??version			  Number 0500
@32Bit				  Text	 0
@CodeSize			  Text	 0
@Cpu				  Text	 0F0FH
@DataSize			  Text	 0
@FileName			  Text	 mtrap
@Interface			  Text	 000h
@Model				  Text	 2
@WordSize			  Text	 2
@code				  Text	 _TEXT
@curseg				  Text	 _TEXT
@data				  Text	 DGROUP
@stack				  Text	 DGROUP
CheckHistory			  Near16 ----:---- Extern
CloseLogFile			  Near16 ----:---- Extern
CopyEnv				  Near16 ----:---- Extern
CtrlBrkPressedInDOS		  Byte	 ----:---- Extern
Disassemble32Bit		  Byte	 ----:---- Extern
DisplayRegisters		  Near16 ----:---- Extern
EnterHistory			  Near16 ----:---- Extern
ExeStats			  Near16 ----:---- Extern
FileLoadErr			  Near16 ----:---- Extern
GetInputLine			  Near16 ----:---- Extern
GetKey				  Near16 ----:---- Extern
Inputhandler			  Near16 ----:---- Extern
IntSnapShot			  Near16 ----:---- Extern
KillFiles			  Near16 ----:---- Extern
LoadHistory			  Near16 ----:---- Extern
LoadProgram			  Near16 ----:---- Extern
LogToFile			  Near16 ----:---- Extern
LoggingStat			  Near16 ----:---- Extern
MakeEmptyProg			  Near16 ----:---- Extern
ModifyRegisters			  Near16 ----:---- Extern
ParseProgName			  Near16 ----:---- Extern
PrintFollowingMessage		  Near16 ----:---- Extern
PureChar			  Near16 ----:---- Extern
PutChar				  Near16 ----:---- Extern
QualifyName			  Near16 ----:---- Extern
ReTrap				  Near16 ----:---- Extern
ReadAddress			  Near16 ----:---- Extern
ReadNumber			  Near16 ----:---- Extern
ReadOptions			  Near16 ----:---- Extern
ReadReg				  Near16 ----:---- Extern
RegdumpCS			  Word	 DGROUP:003F
RegdumpDS			  Word	 DGROUP:0043
RegdumpEAX			  Dword	 DGROUP:001B
RegdumpEBP			  Dword	 DGROUP:0033
RegdumpEBX			  Dword	 DGROUP:001F
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 12
Symbol Table



RegdumpECX			  Dword	 DGROUP:0023
RegdumpEDI			  Dword	 DGROUP:002F
RegdumpEDX			  Dword	 DGROUP:0027
RegdumpEIP			  Dword	 DGROUP:003B
RegdumpES			  Word	 DGROUP:0041
RegdumpESI			  Dword	 DGROUP:002B
RegdumpESP			  Dword	 DGROUP:0037
RegdumpFLAGS			  Dword	 DGROUP:0017
RegdumpFS			  Word	 DGROUP:0047
RegdumpGS			  Word	 DGROUP:0049
RegdumpSS			  Word	 DGROUP:0045
ReleaseDebugMem			  Near16 ----:---- Extern
ReleaseMemory			  Near16 ----:---- Extern
ReleaseRMInts			  Near16 ----:---- Extern
ResizeMem			  Near16 ----:---- Extern
SetDebugPSP			  Near16 ----:---- Extern
SetEnvName			  Near16 ----:---- Extern
SetRMInts			  Near16 ----:---- Extern
SetUserPSP			  Near16 ----:---- Extern
SetVectAttrib			  Near16 ----:---- Extern
TRAPFLAG			  Number 0100
TgtPgmEnvLen			  Word	 ----:---- Extern
TgtPgmEnvSeg			  Word	 ----:---- Extern
TgtPgmEnvSpaceUsed		  Word	 ----:---- Extern
TgtPgmNamePtr			  Word	 ----:---- Extern
UnLoadInts			  Near16 ----:---- Extern
UnLoadProgram			  Near16 ----:---- Extern
WadeSpace			  Near16 ----:---- Extern
WadeSpaceOnly			  Near16 ----:---- Extern
WriteOptions			  Near16 ----:---- Extern
_exit				  Near16 _TEXT:02A2
adjusteip			  Near16 _TEXT:00F9
breaks				  Near16 ----:---- Extern
callcheck			  Near16 ----:---- Extern
checkcpu			  Near16 ----:---- Extern
cmpstring			  Near16 ----:---- Extern
cpuerr				  Byte	 _TEXT:0000
crlf				  Near16 ----:---- Extern
defCS				  Near16 ----:---- Extern
defDS				  Near16 ----:---- Extern
dgroupMessage			  Near16 ----:---- Extern
disableBreaks			  Near16 ----:---- Extern
dohist				  Near16 _TEXT:0293
doopt				  Near16 ----:---- Extern
dosver				  Word	 DGROUP:004B
enableBreaks			  Near16 ----:---- Extern
entry0				  Near16 _TEXT:006A
entry1				  Near16 _TEXT:0077
entry3				  Near16 _TEXT:008E
errnum				  Word	 DGROUP:004F
errx				  Near16 _TEXT:02BC
errx2				  Near16 _TEXT:02AE
exeflag				  Byte	 ----:---- Extern
filelen				  Dword	 ----:---- Extern
floatcheck			  Near16 ----:---- Extern
fpcommand			  Near16 ----:---- Extern
go				  Near16 ----:---- Extern
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 13
Symbol Table



grdbname			  Byte	 DGROUP:0057
haserr				  Word	 DGROUP:004D
hdwebreakcommand		  Near16 ----:---- Extern
hdwebreakdisable		  Near16 ----:---- Extern
hdwebreakenable			  Near16 ----:---- Extern
hdwechk				  Near16 ----:---- Extern
histoff				  Near16 ----:---- Extern
histon				  Near16 ----:---- Extern
indos				  Dword	 DGROUP:0053
initflatreal			  Near16 ----:---- Extern
inputbuffer			  Byte	 ----:---- Extern
int1bh				  Near16 ----:---- Extern
int20adr			  Dword	 ----:---- Extern
int20handle			  Near16 ----:---- Extern
int21adr			  Dword	 ----:---- Extern
int21handle			  Near16 ----:---- Extern
intpage				  Word	 ----:---- Extern
lastcs				  Word	 ----:---- Extern
lastexe				  Byte	 ----:---- Extern
lastip				  Dword	 ----:---- Extern
loadcommand			  Byte	 ----:---- Extern
loadfile			  Byte	 ----:---- Extern
memerr				  Byte	 _TEXT:0028
neederr				  Byte	 DGROUP:0062
noadj				  Near16 _TEXT:0114
nodecrement			  Near16 _TEXT:0114
noerr				  Near16 _TEXT:00E1
noerr2				  Near16 _TEXT:0139
nomsg				  Byte	 _TEXT:0069
noretrace			  Near16 _TEXT:01B8
olMessage			  Near16 ----:---- Extern
optdiv0				  Byte	 ----:---- Extern
optdosio			  Byte	 ----:---- Extern
optdword			  Byte	 ----:---- Extern
optdwordcommand			  Byte	 ----:---- Extern
optflat0			  Byte	 ----:---- Extern
opthist				  Byte	 ----:---- Extern
optpure				  Byte	 ----:---- Extern
optsignedimm			  Byte	 ----:---- Extern
orgpic				  Word	 ----:---- Extern
printbyte			  Near16 ----:---- Extern
printdword			  Near16 ----:---- Extern
printspace			  Near16 ----:---- Extern
printword			  Near16 ----:---- Extern
proceed				  Near16 ----:---- Extern
psp				  Word	 DGROUP:0060
qerr				  Near16 ----:---- Extern
reentry				  Near16 _TEXT:01A0
rundownflatreal			  Near16 ----:---- Extern
saveregs			  Near16 _TEXT:009E
scankey				  Near16 ----:---- Extern
setbreak			  Near16 ----:---- Extern
stackofs			  Word	 DGROUP:0000
stackseg			  Word	 DGROUP:0002
start				  Near16 _TEXT:01D4
swiftrace			  Near16 ----:---- Extern
tagarena			  Near16 ----:---- Extern
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 14
Symbol Table



traceon				  Byte	 ----:---- Extern
trap				  Near16 ----:---- Extern
trapcount			  Dword	 ----:---- Extern
traphandler			  Near16 _TEXT:0115
trapnum				  Word	 DGROUP:0051
trappop				  Dword	 DGROUP:0063
untrace				  Near16 ----:---- Extern
userbasepsp			  Word	 ----:---- Extern
userpsp				  Word	 ----:---- Extern
veclist				  Byte	 DGROUP:0004
vererr				  Byte	 _TEXT:0048
verid				  Number 000E
wadeprefix			  Near16 ----:---- Extern
winshellchk			  Near16 ----:---- Extern

Macro Name

PRINT_MESSAGE
entry

Groups & Segments		  Bit Size Align  Combine Class

DGROUP				  Group
  STACK				  16  0400 Para	  Stack	  STACK
  _DATA				  16  0067 Word	  Public  DATA
_TEXT				  16  02CD Word	  Public  CODE
Turbo Assembler	 Version 5.0	    08-31-98 14:27:45	    Page 15
Error Summary



**Error** mtrap.asm(43)	Undefined symbol: TrapHandler
**Error** mtrap.asm(190) Undefined symbol: dgroup
**Error** mtrap.asm(235) Undefined symbol: InputHandler
**Error** mtrap.asm(240) Undefined symbol: InputHandler
**Error** mtrap.asm(248) Undefined symbol: dgroup
**Error** mtrap.asm(260) PRINT_MESSAGE(2) Undefined symbol: VERID
**Error** mtrap.asm(281) Undefined symbol: IntSnapshot
**Error** mtrap.asm(290) Undefined symbol: FloatCheck
