@@ -930,9 +930,13 @@ prompt1 db @CatStr(!',%PROMPT,!')
930930else
931931prompt1 db '-' ;main prompt
932932endif
933+
933934prompt2 db ':' ;prompt for register value
934- if ?DPMI
935+
936+ if ?PM
937+ if ?DPMI
935938 db '!'
939+ endif
936940prompt3 db '#' ;protected-mode prompt
937941endif
938942
@@ -1388,19 +1392,6 @@ _DATA ends
13881392
13891393endif
13901394
1391- if EXCCSIP
1392- _DATA segment
1393- if EXCCSEIP
1394- intexceip label dword
1395- endif
1396- intexcip dw 0 ;IP if internal exception
1397- if EXCCSEIP
1398- dw 0
1399- endif
1400- intexccs dw 0 ;CS if internal exception
1401- _DATA ends
1402- endif
1403-
14041395if ?DPMI
14051396
14061397intcall proto stdcall :word , :word
@@ -1911,10 +1902,14 @@ if LCMDFILE
19111902@@:
19121903endif
19131904 mov cx , 1
1905+ ife ?PM
1906+ mov dx , offset prompt1
1907+ else
1908+ if ?DPMI
19141909 mov dx , offset prompt1
1915- if ?DPMI
19161910 call ispm_dbe ; debuggee in rm/pm?
19171911 jz @F
1912+ endif
19181913 mov dx , offset prompt3
19191914@@:
19201915endif
@@ -5129,7 +5124,8 @@ endif
51295124;--- E/SI=src offset, E/DX=end src
51305125
51315126dd2:
5132- mov [ lastcmd ], offset lastddd
5127+ ; mov [lastcmd],offset lastddd
5128+ mov [ lastcmd ], offset d_cmd
51335129 call prephack ;set up for faking int vectors 23 and 24
51345130dd_loop:
51355131; mov ax,[d_addr+4]
@@ -5782,7 +5778,9 @@ if ?DPMI
57825778 pop dx ;get old MSW
57835779endif
57845780
5781+ ife RING0
57855782 @dprintf "g_cmd: run returned, [spadjust]=%X, [spsav]=%lX" , [ spadjust ], dword ptr ds : [ SPSAV ]
5783+ endif
57865784
57875785if ?PM
57885786 call getcsattr
@@ -7178,6 +7176,36 @@ error:
71787176
71797177IsWriteableBX endp
71807178
7179+ if RING0
7180+
7181+ ;--- hack to make 'u' work with a real-mode segment
7182+
7183+ setscratchsel proc
7184+ pushad
7185+ mov bp , sp
7186+ sub sp , 6
7187+ sgdt [ bp - 6 ]
7188+ pop ax
7189+ pop eax
7190+ movzx ebx , [ scratchsel ]
7191+ add ebx , eax
7192+ movzx eax , word ptr [ bp + 5 * 4 ] ;get DX
7193+ shl eax , 4
7194+ push ds
7195+ mov ds , [ wFl at ]
7196+ mov word ptr [ ebx + 0 ], - 1
7197+ mov word ptr [ ebx + 2 ], ax
7198+ shr eax , 16
7199+ mov byte ptr [ ebx + 4 ], al
7200+ mov word ptr [ ebx + 5 ], 9Bh
7201+ mov byte ptr [ ebx + 7 ], ah
7202+ pop ds
7203+ popad
7204+ mov bx , [ scratchsel ]
7205+ ret
7206+ setscratchsel endp
7207+ endif
7208+
71817209 if ?DPMI
71827210setrmsegm:
71837211 . 286
@@ -8183,7 +8211,8 @@ t_cmd proc
81838211 cmp ax , 'tm'
81848212 jz tm_cmd
81858213tt0:
8186- mov [ lastcmd ], offset tt0
8214+ ; mov [lastcmd], offset tt0
8215+ mov [ lastcmd ], offset t_cmd
81878216 call parse_pt ;process arguments
81888217@@:
81898218 push cx
@@ -8365,8 +8394,9 @@ endif
83658394
83668395trace1 endp
83678396
8368- ;--- test if memory at CS:E/IP can be written to
8397+ ;--- test if memory at CS:E/IP can be written to.
83698398;--- return C if not
8399+ ;--- used by T cmd.
83708400;--- IN: CX=offset for (E)IP
83718401
83728402iswriteablecseip proc
@@ -8412,7 +8442,7 @@ ctos_1:
84128442clear_tf_onstack endp
84138443
84148444;--- Print message about unexpected interrupt, dump registers, and end
8415- ;--- command. This code is also used by the G and P commands .
8445+ ;--- command. This code is used by G, P and T cmds .
84168446
84178447ue_int:
84188448 mov dl , [ run_int ]
@@ -8427,17 +8457,21 @@ endif
84278457@@:
84288458 jmp cmdloop ;back to the start
84298459
8460+ ;--- "unexpected" exception in real-mode inside debugger
8461+
84308462ife RING0
84318463 if CATCHINT07 or CATCHINT0C or CATCHINT0D
84328464ue_intxx:
84338465 if EXCCSIP
8434- pop cs : [ intexcip ]
8435- pop cs : [ intexccs ]
8466+ pop cx
8467+ pop dx
84368468 endif
84378469 push cs
84388470 pop ss
84398471 mov sp , cs : [ top_sp ]
8440- push ax
8472+ push cx ; ip
8473+ push dx ; cs
8474+ push ax ; msg
84418475
84428476;--- fall thru
84438477
@@ -8447,8 +8481,8 @@ endif
84478481
84488482if ?PM or CATCHINT07 or CATCHINT0C or CATCHINT0D
84498483
8450- ;--- unexpected exception occured inside debugger
8451- ;--- [SP] = msg
8484+ ;--- " unexpected" exception occured inside debugger
8485+ ;--- [SP] = msg, cs, [e]ip
84528486
84538487ue_intx proc
84548488 cld
@@ -8472,15 +8506,15 @@ if EXCCSIP
84728506 mov di , offset line_out
84738507 mov si , offset excloc ; "CS:IP="
84748508 call copystring
8475- mov ax , [ intexccs ]
8509+ pop ax
84768510 call hexword
84778511 mov al , ':'
84788512 stosb
84798513 if EXCCSEIP
8480- mov eax , [ intexceip ]
8514+ pop eax
84818515 call hexdword
84828516 else
8483- mov ax , [ intexcip ]
8517+ pop ax
84848518 call hexword
84858519 endif
84868520 call putsline
@@ -8493,7 +8527,8 @@ endif
84938527;--- U command - disassemble.
84948528
84958529u_cmd proc
8496- mov [ lastcmd ], offset lastuu
8530+ ; mov [lastcmd],offset lastuu
8531+ mov [ lastcmd ], offset u_cmd
84978532 cmp al , CR
84988533 je lastuu ;if no address was given
84998534 sizeprfX ;xor ecx, ecx
@@ -10685,8 +10720,9 @@ glfbx_2:
1068510720getlenforbx endp
1068610721
1068710722; getrange - Get address range from input line.
10688- ; a range consists of either start and end address
10689- ; or a start address, a 'L' and a length.
10723+ ; a range consists of:
10724+ ; 1. a start address: [segment:]start-offset
10725+ ; 2. an end-offset or a 'L' followed by a length.
1069010726; Entry AL First character of range
1069110727; SI Address of next character
1069210728; BX Default segment to use
@@ -10801,6 +10837,23 @@ if ?PM
1080110837 mov bx , cs : [ wFl at ]
1080210838 jmp ga3
1080310839@@:
10840+ ;--- hack for a/u cmds: allow to enter a real-mode address.
10841+ ;--- since the debugger cannot handle v86-mode exceptions yet,
10842+ ;--- this hack allows to at least (dis)assemble real-mode code parts.
10843+ cmp al , '$'
10844+ jnz normseg
10845+ cmp [ lastcmd ], offset u_cmd ; u cmd?
10846+ jz @F
10847+ cmp [ errret ], offset cmdloop ; a cmd?
10848+ jz normseg
10849+ @@:
10850+ lodsb
10851+ call getword
10852+ cmp al , ':'
10853+ jnz errorj2
10854+ call setscratchsel ; set BX to scratchsel
10855+ jmp ga3
10856+ normseg:
1080410857 endif
1080510858endif
1080610859 call getofsforbx
0 commit comments