Subversion Repositories Kolibri OS

Rev

Rev 205 | Rev 485 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 205 Rev 410
1
format binary
1
format binary
2
use32
2
use32
3
	db	'MENUET01'
3
	db	'MENUET01'
4
	dd	1
4
	dd	1
5
	dd	start
5
	dd	start
6
	dd	i_end
6
	dd	i_end
7
	dd	used_mem
7
	dd	used_mem
8
	dd	used_mem
8
	dd	used_mem
9
	dd	i_param
9
	dd	i_param
10
	dd	0
10
	dd	0
11
 
11
 
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
 
15
 
16
data_width equ 80
16
data_width equ 80
17
data_x_pos equ 12
17
data_x_pos equ 12
18
data_x_size equ data_width*6
18
data_x_size equ data_width*6
19
 
19
 
20
title_x_pos equ 30
20
title_x_pos equ 30
21
title_y_pos equ 32
21
title_y_pos equ 32
22
title_y_size equ 10
22
title_y_size equ 10
23
 
23
 
24
registers_x_pos equ data_x_pos
24
registers_x_pos equ data_x_pos
25
registers_y_pos equ (title_y_pos + title_y_size)
25
registers_y_pos equ (title_y_pos + title_y_size)
26
registers_y_size equ 30
26
registers_y_size equ 30
27
 
27
 
28
dump_y_pos equ (registers_y_pos + registers_y_size + 5)
28
dump_y_pos equ (registers_y_pos + registers_y_size + 5)
29
dump_height equ 4
29
dump_height equ 4
30
dump_y_size equ (dump_height*10)
30
dump_y_size equ (dump_height*10)
31
 
31
 
32
disasm_y_pos equ (dump_y_pos + dump_y_size + 4)
32
disasm_y_pos equ (dump_y_pos + dump_y_size + 4)
33
disasm_height equ 16
33
disasm_height equ 16
34
disasm_y_size equ (disasm_height*10)
34
disasm_y_size equ (disasm_height*10)
35
 
35
 
36
messages_width equ data_width
36
messages_width equ data_width
37
messages_height equ 12
37
messages_height equ 12
38
messages_x_pos equ data_x_pos
38
messages_x_pos equ data_x_pos
39
messages_y_pos equ (disasm_y_pos + disasm_y_size + 4)
39
messages_y_pos equ (disasm_y_pos + disasm_y_size + 4)
40
messages_x_size equ messages_width*6
40
messages_x_size equ messages_width*6
41
messages_y_size equ messages_height*10
41
messages_y_size equ messages_height*10
42
 
42
 
43
cmdline_width equ data_width
43
cmdline_width equ data_width
44
cmdline_x_pos equ data_x_pos
44
cmdline_x_pos equ data_x_pos
45
cmdline_y_pos equ (messages_y_pos + messages_y_size + 10)
45
cmdline_y_pos equ (messages_y_pos + messages_y_size + 10)
46
cmdline_x_size equ messages_x_size
46
cmdline_x_size equ messages_x_size
47
cmdline_y_size equ 10
47
cmdline_y_size equ 10
48
 
48
 
49
wnd_x_size equ (data_x_pos + messages_x_size + data_x_pos)
49
wnd_x_size equ (data_x_pos + messages_x_size + data_x_pos)
50
wnd_y_size equ (cmdline_y_pos + cmdline_y_size + data_x_pos)
50
wnd_y_size equ (cmdline_y_pos + cmdline_y_size + data_x_pos)
51
 
51
 
52
start:
52
start:
53
	mov	edi, messages
53
	mov	edi, messages
54
	mov	ecx, messages_width*messages_height
54
	mov	ecx, messages_width*messages_height
55
	mov	al, ' '
55
	mov	al, ' '
56
	rep	stosb
56
	rep	stosb
57
	xor	eax, eax
57
	xor	eax, eax
58
	mov	[messages_pos], eax
58
	mov	[messages_pos], eax
59
	mov	[cmdline_len], eax
59
	mov	[cmdline_len], eax
60
	mov	[cmdline_pos], eax
60
	mov	[cmdline_pos], eax
61
	mov	edi, needzerostart
61
	mov	edi, needzerostart
62
	mov	ecx, (needzeroend-needzerostart+3)/4
62
	mov	ecx, (needzeroend-needzerostart+3)/4
63
	rep	stosd
63
	rep	stosd
64
	mov	esi, begin_str
64
	mov	esi, begin_str
65
	call	put_message_nodraw
65
	call	put_message_nodraw
66
; set event mask - default events and debugging events
66
; set event mask - default events and debugging events
67
	push	40
67
	push	40
68
	pop	eax
68
	pop	eax
69
	mov	ebx, 0x107
69
	mov	ebx, 0x107
70
	int	40h
70
	int	40h
71
; set debug messages buffer
71
; set debug messages buffer
72
	mov	ecx, dbgbufsize
72
	mov	ecx, dbgbufsize
73
	mov	dword [ecx], 256
73
	mov	dword [ecx], 256
74
	xor	ebx, ebx
74
	xor	ebx, ebx
75
	mov	[ecx+4], ebx
75
	mov	[ecx+4], ebx
76
	mov	al, 69
76
	mov	al, 69
77
	int	40h
77
	int	40h
78
	mov	esi, i_param
78
	mov	esi, i_param
79
	call	skip_spaces
79
	call	skip_spaces
80
	test	al, al
80
	test	al, al
81
	jz	dodraw
81
	jz	dodraw
82
	push	esi
82
	push	esi
83
	call	draw_window
83
	call	draw_window
84
	pop	esi
84
	pop	esi
85
	call	OnLoadInit
85
	call	OnLoadInit
86
	jmp	waitevent
86
	jmp	waitevent
87
dodraw:
87
dodraw:
88
	call	draw_window
88
	call	draw_window
89
waitevent:
89
waitevent:
90
	push	10
90
	push	10
91
	pop	eax
91
	pop	eax
92
	int	40h
92
	int	40h
93
	cmp	al, 9
93
	cmp	al, 9
94
	jz	debugmsg
94
	jz	debugmsg
95
	dec	eax
95
	dec	eax
96
	jz	dodraw
96
	jz	dodraw
97
	dec	eax
97
	dec	eax
98
	jz	keypressed
98
	jz	keypressed
99
	dec	eax
99
	dec	eax
100
	jnz	waitevent
100
	jnz	waitevent
101
; button pressed - we have only one button (close)
101
; button pressed - we have only one button (close)
102
	push	-1
102
	push	-1
103
	pop	eax
103
	pop	eax
104
	int	40h
104
	int	40h
105
keypressed:
105
keypressed:
106
	mov	al, 2
106
	mov	al, 2
107
	int	40h
107
	int	40h
108
	shr	eax, 8
108
	shr	eax, 8
109
	cmp	al, 8
109
	cmp	al, 8
110
	jz	.backspace
110
	jz	.backspace
111
	cmp	al, 0xB0
111
	cmp	al, 0xB0
112
	jz	.left
112
	jz	.left
113
	cmp	al, 0xB3
113
	cmp	al, 0xB3
114
	jz	.right
114
	jz	.right
115
	cmp	al, 0x0D
115
	cmp	al, 0x0D
116
	jz	.enter
116
	jz	.enter
117
	cmp	al, 0xB6
117
	cmp	al, 0xB6
118
	jz	.del
118
	jz	.del
119
	cmp	al, 0xB4
119
	cmp	al, 0xB4
120
	jz	.home
120
	jz	.home
121
	cmp	al, 0xB5
121
	cmp	al, 0xB5
122
	jz	.end
122
	jz	.end
123
	cmp	al, 0xB1
123
	cmp	al, 0xB1
124
	jz	.down
124
	jz	.down
125
	cmp	al, 0xB2
125
	cmp	al, 0xB2
126
	jz	.up
126
	jz	.up
127
	cmp	al, 0xD8
127
	cmp	al, 0xD8
128
	jz	CtrlF7
128
	jz	CtrlF7
129
	cmp	al, 0xD9
129
	cmp	al, 0xD9
130
	jz	CtrlF8
130
	jz	CtrlF8
131
	cmp	[cmdline_len], cmdline_width
131
	cmp	[cmdline_len], cmdline_width
132
	jae	waitevent
132
	jae	waitevent
133
	push	eax
133
	push	eax
134
	call	clear_cmdline_end
134
	call	clear_cmdline_end
135
	pop	eax
135
	pop	eax
136
	mov	edi, cmdline
136
	mov	edi, cmdline
137
	mov	ecx, [cmdline_len]
137
	mov	ecx, [cmdline_len]
138
	add	edi, ecx
138
	add	edi, ecx
139
	lea	esi, [edi-1]
139
	lea	esi, [edi-1]
140
	sub	ecx, [cmdline_pos]
140
	sub	ecx, [cmdline_pos]
141
	std
141
	std
142
	rep	movsb
142
	rep	movsb
143
	cld
143
	cld
144
	stosb
144
	stosb
145
	inc	[cmdline_len]
145
	inc	[cmdline_len]
146
	call	draw_cmdline_end
146
	call	draw_cmdline_end
147
	inc	[cmdline_pos]
147
	inc	[cmdline_pos]
148
	call	draw_cursor
148
	call	draw_cursor
149
	jmp	waitevent
149
	jmp	waitevent
150
.backspace:
150
.backspace:
151
	cmp	[cmdline_pos], 0
151
	cmp	[cmdline_pos], 0
152
	jz	waitevent
152
	jz	waitevent
153
	dec	[cmdline_pos]
153
	dec	[cmdline_pos]
154
.delchar:
154
.delchar:
155
	call	clear_cmdline_end
155
	call	clear_cmdline_end
156
	mov	edi, [cmdline_pos]
156
	mov	edi, [cmdline_pos]
157
	dec	[cmdline_len]
157
	dec	[cmdline_len]
158
	mov	ecx, [cmdline_len]
158
	mov	ecx, [cmdline_len]
159
	sub	ecx, edi
159
	sub	ecx, edi
160
	add	edi, cmdline
160
	add	edi, cmdline
161
	lea	esi, [edi+1]
161
	lea	esi, [edi+1]
162
	rep	movsb
162
	rep	movsb
163
	call	draw_cmdline_end
163
	call	draw_cmdline_end
164
	call	draw_cursor
164
	call	draw_cursor
165
	jmp	waitevent
165
	jmp	waitevent
166
.del:
166
.del:
167
	mov	eax, [cmdline_pos]
167
	mov	eax, [cmdline_pos]
168
	cmp	eax, [cmdline_len]
168
	cmp	eax, [cmdline_len]
169
	jae	waitevent
169
	jae	waitevent
170
	jmp	.delchar
170
	jmp	.delchar
171
.left:
171
.left:
172
	cmp	[cmdline_pos], 0
172
	cmp	[cmdline_pos], 0
173
	jz	waitevent
173
	jz	waitevent
174
	call	hide_cursor
174
	call	hide_cursor
175
	dec	[cmdline_pos]
175
	dec	[cmdline_pos]
176
	call	draw_cursor
176
	call	draw_cursor
177
	jmp	waitevent
177
	jmp	waitevent
178
.right:
178
.right:
179
	mov	eax, [cmdline_pos]
179
	mov	eax, [cmdline_pos]
180
	cmp	eax, [cmdline_len]
180
	cmp	eax, [cmdline_len]
181
	jae	waitevent
181
	jae	waitevent
182
	call	hide_cursor
182
	call	hide_cursor
183
	inc	[cmdline_pos]
183
	inc	[cmdline_pos]
184
	call	draw_cursor
184
	call	draw_cursor
185
	jmp	waitevent
185
	jmp	waitevent
186
.home:
186
.home:
187
	call	hide_cursor
187
	call	hide_cursor
188
	and	[cmdline_pos], 0
188
	and	[cmdline_pos], 0
189
	call	draw_cursor
189
	call	draw_cursor
190
	jmp	waitevent
190
	jmp	waitevent
191
.end:
191
.end:
192
	call	hide_cursor
192
	call	hide_cursor
193
	mov	eax, [cmdline_len]
193
	mov	eax, [cmdline_len]
194
	mov	[cmdline_pos], eax
194
	mov	[cmdline_pos], eax
195
	call	draw_cursor
195
	call	draw_cursor
196
.up:
196
.up:
197
.down:
197
.down:
198
	jmp	waitevent
198
	jmp	waitevent
199
.enter:
199
.enter:
200
	mov	ecx, [cmdline_len]
200
	mov	ecx, [cmdline_len]
201
	test	ecx, ecx
201
	test	ecx, ecx
202
	jz	waitevent
202
	jz	waitevent
203
	mov	esi, cmdline
203
	mov	esi, cmdline
204
	mov	byte [esi+ecx], 0
204
	mov	byte [esi+ecx], 0
205
	and	[cmdline_pos], 0
205
	and	[cmdline_pos], 0
206
	push	esi
206
	push	esi
207
	call	clear_cmdline_end
207
	call	clear_cmdline_end
208
	call	draw_cursor
208
	call	draw_cursor
209
	pop	esi
209
	pop	esi
210
	and	[cmdline_len], 0
210
	and	[cmdline_len], 0
211
; skip leading spaces
211
; skip leading spaces
212
	call	skip_spaces
212
	call	skip_spaces
213
	cmp	al, 0
213
	cmp	al, 0
214
	jz	waitevent
214
	jz	waitevent
215
; now esi points to command
215
; now esi points to command
216
	push	esi
216
	push	esi
217
	mov	esi, prompt
217
	mov	esi, prompt
218
	call	put_message_nodraw
218
	call	put_message_nodraw
219
	pop	esi
219
	pop	esi
220
	push	esi
220
	push	esi
221
	call	put_message_nodraw
221
	call	put_message_nodraw
222
z1:	mov	esi, newline
222
z1:	mov	esi, newline
223
	call	put_message
223
	call	put_message
224
	pop	esi
224
	pop	esi
225
	push	esi
225
	push	esi
226
	call	get_arg
226
	call	get_arg
227
	mov	[curarg], esi
227
	mov	[curarg], esi
228
	pop	edi
228
	pop	edi
229
	mov	esi, commands
229
	mov	esi, commands
230
	call	find_cmd
230
	call	find_cmd
231
	mov	eax, aUnknownCommand
231
	mov	eax, aUnknownCommand
232
	jc	.x11
232
	jc	.x11
233
; check command requirements
233
; check command requirements
234
; flags field:
234
; flags field:
235
; &1: command may be called without parameters
235
; &1: command may be called without parameters
236
; &2: command may be called with parameters
236
; &2: command may be called with parameters
237
; &4: command may be called without loaded program
237
; &4: command may be called without loaded program
238
; &8: command may be called with loaded program
238
; &8: command may be called with loaded program
239
	mov	eax, [esi+8]
239
	mov	eax, [esi+8]
240
	mov	ecx, [curarg]
240
	mov	ecx, [curarg]
241
	cmp	byte [ecx], 0
241
	cmp	byte [ecx], 0
242
	jz	.noargs
242
	jz	.noargs
243
	test	byte [esi+16], 2
243
	test	byte [esi+16], 2
244
	jz	.x11
244
	jz	.x11
245
	jmp	@f
245
	jmp	@f
246
.noargs:
246
.noargs:
247
	test	byte [esi+16], 1
247
	test	byte [esi+16], 1
248
	jz	.x11
248
	jz	.x11
249
@@:
249
@@:
250
	cmp	[debuggee_pid], 0
250
	cmp	[debuggee_pid], 0
251
	jz	.nodebuggee
251
	jz	.nodebuggee
252
	mov	eax, aAlreadyLoaded
252
	mov	eax, aAlreadyLoaded
253
	test	byte [esi+16], 8
253
	test	byte [esi+16], 8
254
	jz	.x11
254
	jz	.x11
255
	jmp	.x9
255
	jmp	.x9
256
.nodebuggee:
256
.nodebuggee:
257
	mov	eax, need_debuggee
257
	mov	eax, need_debuggee
258
	test	byte [esi+16], 4
258
	test	byte [esi+16], 4
259
	jnz	.x9
259
	jnz	.x9
260
.x11:
260
.x11:
261
	xchg	esi, eax
261
	xchg	esi, eax
262
	call	put_message
262
	call	put_message
263
.x10:
263
.x10:
264
	jmp	waitevent
264
	jmp	waitevent
265
.x9:
265
.x9:
266
	call	dword [esi+4]
266
	call	dword [esi+4]
267
	jmp	.x10
267
	jmp	.x10
268
 
268
 
269
find_cmd:
269
find_cmd:
270
; all commands are case-insensitive
270
; all commands are case-insensitive
271
	push	edi
271
	push	edi
272
.x4:
272
.x4:
273
	mov	al, [edi]
273
	mov	al, [edi]
274
	cmp	al, 0
274
	cmp	al, 0
275
	jz	.x5
275
	jz	.x5
276
	cmp	al, 'A'
276
	cmp	al, 'A'
277
	jb	@f
277
	jb	@f
278
	cmp	al, 'Z'
278
	cmp	al, 'Z'
279
	ja	@f
279
	ja	@f
280
	or	al, 20h
280
	or	al, 20h
281
@@:
281
@@:
282
	stosb
282
	stosb
283
	jmp	.x4
283
	jmp	.x4
284
.x5:
284
.x5:
285
; find command
285
; find command
286
	pop	edi
286
	pop	edi
287
.x6:
287
.x6:
288
	cmp	dword [esi], 0
288
	cmp	dword [esi], 0
289
	jz	.x7
289
	jz	.x7
290
	push	esi
290
	push	esi
291
	mov	esi, [esi]
291
	mov	esi, [esi]
292
	lodsb
292
	lodsb
293
	movzx	ecx, al
293
	movzx	ecx, al
294
	push	edi
294
	push	edi
295
	repz	cmpsb
295
	repz	cmpsb
296
	pop	edi
296
	pop	edi
297
	pop	esi
297
	pop	esi
298
	jz	.x8
298
	jz	.x8
299
	add	esi, 17
299
	add	esi, 17
300
	jmp	.x6
300
	jmp	.x6
301
.x7:
301
.x7:
302
	stc
302
	stc
303
.x8:
303
.x8:
304
	ret
304
	ret
305
 
305
 
306
get_arg:
306
get_arg:
307
	lodsb
307
	lodsb
308
	cmp	al, ' '
308
	cmp	al, ' '
309
	ja	get_arg
309
	ja	get_arg
310
	mov	byte [esi-1], 0
310
	mov	byte [esi-1], 0
311
	cmp	al, 0
311
	cmp	al, 0
312
	jnz	skip_spaces
312
	jnz	skip_spaces
313
	dec	esi
313
	dec	esi
314
skip_spaces:
314
skip_spaces:
315
	lodsb
315
	lodsb
316
	cmp	al, 0
316
	cmp	al, 0
317
	jz	@f
317
	jz	@f
318
	cmp	al, ' '
318
	cmp	al, ' '
319
	jbe	skip_spaces
319
	jbe	skip_spaces
320
@@:	dec	esi
320
@@:	dec	esi
321
	ret
321
	ret
322
 
322
 
323
clear_cmdline_end:
323
clear_cmdline_end:
324
	mov	ebx, [cmdline_pos]
324
	mov	ebx, [cmdline_pos]
325
	mov	ecx, [cmdline_len]
325
	mov	ecx, [cmdline_len]
326
	sub	ecx, ebx
326
	sub	ecx, ebx
327
	push	13
327
	push	13
328
	pop	eax
328
	pop	eax
329
	imul	ebx, 6
329
	imul	ebx, 6
330
	imul	ecx, 6
330
	imul	ecx, 6
331
	inc	ecx
331
	inc	ecx
332
	add	ebx, cmdline_x_pos
332
	add	ebx, cmdline_x_pos
333
	shl	ebx, 16
333
	shl	ebx, 16
334
	or	ebx, ecx
334
	or	ebx, ecx
335
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
335
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
336
	mov	edx, 0xFFFFFF
336
	mov	edx, 0xFFFFFF
337
	int	40h
337
	int	40h
338
	ret
338
	ret
339
 
339
 
340
draw_cmdline:
340
draw_cmdline:
341
	xor	ebx, ebx
341
	xor	ebx, ebx
342
	jmp	@f
342
	jmp	@f
343
draw_cmdline_end:
343
draw_cmdline_end:
344
	mov	ebx, [cmdline_pos]
344
	mov	ebx, [cmdline_pos]
345
@@:
345
@@:
346
	mov	esi, [cmdline_len]
346
	mov	esi, [cmdline_len]
347
	sub	esi, ebx
347
	sub	esi, ebx
348
	push	4
348
	push	4
349
	pop	eax
349
	pop	eax
350
	xor	ecx, ecx
350
	xor	ecx, ecx
351
	lea	edx, [cmdline+ebx]
351
	lea	edx, [cmdline+ebx]
352
	imul	ebx, 6
352
	imul	ebx, 6
353
	add	ebx, cmdline_x_pos
353
	add	ebx, cmdline_x_pos
354
	shl	ebx, 16
354
	shl	ebx, 16
355
	or	ebx, cmdline_y_pos+1
355
	or	ebx, cmdline_y_pos+1
356
	int	40h
356
	int	40h
357
	ret
357
	ret
358
 
358
 
359
put_message_nodraw:
359
put_message_nodraw:
360
; in: esi->ASCIZ message
360
; in: esi->ASCIZ message
361
	mov	edx, [messages_pos]
361
	mov	edx, [messages_pos]
362
.m:
362
.m:
363
	lea	edi, [messages+edx]
363
	lea	edi, [messages+edx]
364
.l:
364
.l:
365
	lodsb
365
	lodsb
366
	cmp	al, 0
366
	cmp	al, 0
367
	jz	.done
367
	jz	.done
368
	call	test_scroll
368
	call	test_scroll
369
	cmp	al, 10
369
	cmp	al, 10
370
	jz	.newline
370
	jz	.newline
371
	cmp	al, '%'
371
	cmp	al, '%'
372
	jnz	@f
372
	jnz	@f
373
	cmp	dword [esp], z1
373
	cmp	dword [esp], z1
374
	jnz	.format
374
	jnz	.format
375
@@:
375
@@:
376
	stosb
376
	stosb
377
	inc	edx
377
	inc	edx
378
	jmp	.l
378
	jmp	.l
379
.newline:
379
.newline:
380
	push	edx
380
	push	edx
381
	mov	ecx, messages_width
381
	mov	ecx, messages_width
382
	xor	eax, eax
382
	xor	eax, eax
383
	xchg	eax, edx
383
	xchg	eax, edx
384
	div	ecx
384
	div	ecx
385
	xchg	eax, edx
385
	xchg	eax, edx
386
	pop	edx
386
	pop	edx
387
	test	eax, eax
387
	test	eax, eax
388
	jz	.m
388
	jz	.m
389
	sub	edx, eax
389
	sub	edx, eax
390
	add	edx, ecx
390
	add	edx, ecx
391
	jmp	.m
391
	jmp	.m
392
.done:
392
.done:
393
	mov	[messages_pos], edx
393
	mov	[messages_pos], edx
394
	ret
394
	ret
395
.format:
395
.format:
396
; at moment all format specs must be %X
396
; at moment all format specs must be %X
397
	lodsb	; get 
397
	lodsb	; get 
398
	sub	al, '0'
398
	sub	al, '0'
399
	movzx	ecx, al
399
	movzx	ecx, al
400
	lodsb
400
	lodsb
401
	pop	eax
401
	pop	eax
402
	pop	ebp
402
	pop	ebp
403
	push	eax
403
	push	eax
404
; write number in ebp with ecx digits
404
; write number in ebp with ecx digits
405
	dec	ecx
405
	dec	ecx
406
	shl	ecx, 2
406
	shl	ecx, 2
407
.writenibble:
407
.writenibble:
408
	push	ecx
408
	push	ecx
409
	call	test_scroll
409
	call	test_scroll
410
	pop	ecx
410
	pop	ecx
411
	mov	eax, ebp
411
	mov	eax, ebp
412
	shr	eax, cl
412
	shr	eax, cl
413
	and	al, 0xF
413
	and	al, 0xF
414
	cmp	al, 10
414
	cmp	al, 10
415
	sbb	al, 69h
415
	sbb	al, 69h
416
	das
416
	das
417
	stosb
417
	stosb
418
	inc	edx
418
	inc	edx
419
	sub	ecx, 4
419
	sub	ecx, 4
420
	jns	.writenibble
420
	jns	.writenibble
421
	jmp	.l
421
	jmp	.l
422
 
422
 
423
test_scroll:
423
test_scroll:
424
	cmp	edx, messages_width*messages_height
424
	cmp	edx, messages_width*messages_height
425
	jnz	.ret
425
	jnz	.ret
426
	push	esi
426
	push	esi
427
	mov	edi, messages
427
	mov	edi, messages
428
	lea	esi, [edi+messages_width]
428
	lea	esi, [edi+messages_width]
429
	mov	ecx, (messages_height-1)*messages_width/4
429
	mov	ecx, (messages_height-1)*messages_width/4
430
	rep	movsd
430
	rep	movsd
431
	push	eax
431
	push	eax
432
	mov	al, ' '
432
	mov	al, ' '
433
	push	edi
433
	push	edi
434
	push	messages_width
434
	push	messages_width
435
	pop	ecx
435
	pop	ecx
436
	sub	edx, ecx
436
	sub	edx, ecx
437
	rep	stosb
437
	rep	stosb
438
	pop	edi
438
	pop	edi
439
	pop	eax
439
	pop	eax
440
	pop	esi
440
	pop	esi
441
.ret:	ret
441
.ret:	ret
442
 
442
 
443
put_message:
443
put_message:
444
	call	put_message_nodraw
444
	call	put_message_nodraw
445
 
445
 
446
draw_messages:
446
draw_messages:
447
	push	13
447
	push	13
448
	pop	eax
448
	pop	eax
449
	mov	edx, 0xFFFFFF
449
	mov	edx, 0xFFFFFF
450
	mov	ebx, messages_x_pos*10000h+messages_x_size
450
	mov	ebx, messages_x_pos*10000h+messages_x_size
451
	mov	ecx, messages_y_pos*10000h+messages_y_size
451
	mov	ecx, messages_y_pos*10000h+messages_y_size
452
	int	40h
452
	int	40h
453
	mov	edx, messages
453
	mov	edx, messages
454
	push	messages_width
454
	push	messages_width
455
	pop	esi
455
	pop	esi
456
	xor	ecx, ecx
456
	xor	ecx, ecx
457
	mov	al, 4
457
	mov	al, 4
458
	mov	ebx, messages_x_pos*10000h+messages_y_pos
458
	mov	ebx, messages_x_pos*10000h+messages_y_pos
459
@@:
459
@@:
460
	int	40h
460
	int	40h
461
	add	edx, esi
461
	add	edx, esi
462
	add	ebx, 10
462
	add	ebx, 10
463
	cmp	edx, messages+messages_width*messages_height
463
	cmp	edx, messages+messages_width*messages_height
464
	jb	@b
464
	jb	@b
465
	ret
465
	ret
466
 
466
 
467
draw_cursor:
467
draw_cursor:
468
	push	38
468
	push	38
469
	pop	eax
469
	pop	eax
470
	mov	ecx, cmdline_y_pos*10001h+cmdline_y_size-1
470
	mov	ecx, cmdline_y_pos*10001h+cmdline_y_size-1
471
	mov	ebx, [cmdline_pos]
471
	mov	ebx, [cmdline_pos]
472
	imul	ebx, 6
472
	imul	ebx, 6
473
	add	ebx, cmdline_x_pos
473
	add	ebx, cmdline_x_pos
474
	mov	edx, ebx
474
	mov	edx, ebx
475
	shl	ebx, 16
475
	shl	ebx, 16
476
	or	ebx, edx
476
	or	ebx, edx
477
	xor	edx, edx
477
	xor	edx, edx
478
	int	40h
478
	int	40h
479
	ret
479
	ret
480
hide_cursor:
480
hide_cursor:
481
	mov	ebx, [cmdline_pos]
481
	mov	ebx, [cmdline_pos]
482
	push	13
482
	push	13
483
	pop	eax
483
	pop	eax
484
	imul	ebx, 6
484
	imul	ebx, 6
485
	add	ebx, cmdline_x_pos
485
	add	ebx, cmdline_x_pos
486
	shl	ebx, 16
486
	shl	ebx, 16
487
	inc	ebx
487
	inc	ebx
488
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
488
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
489
	mov	edx, 0xFFFFFF
489
	mov	edx, 0xFFFFFF
490
	int	40h
490
	int	40h
491
	mov	ebx, [cmdline_pos]
491
	mov	ebx, [cmdline_pos]
492
	cmp	ebx, [cmdline_len]
492
	cmp	ebx, [cmdline_len]
493
	jae	.ret
493
	jae	.ret
494
	mov	al, 4
494
	mov	al, 4
495
	xor	ecx, ecx
495
	xor	ecx, ecx
496
	lea	edx, [cmdline+ebx]
496
	lea	edx, [cmdline+ebx]
497
	imul	ebx, 6
497
	imul	ebx, 6
498
	add	ebx, cmdline_x_pos
498
	add	ebx, cmdline_x_pos
499
	shl	ebx, 16
499
	shl	ebx, 16
500
	or	ebx, cmdline_y_pos+1
500
	or	ebx, cmdline_y_pos+1
501
	push	1
501
	push	1
502
	pop	esi
502
	pop	esi
503
	int	40h
503
	int	40h
504
.ret:
504
.ret:
505
	ret
505
	ret
506
 
506
 
507
redraw_title:
507
redraw_title:
508
	push	13
508
	push	13
509
	pop	eax
509
	pop	eax
510
	mov	edx, 0xFFFFFF
510
	mov	edx, 0xFFFFFF
511
	mov	ebx, title_x_pos*10000h + data_x_pos+data_x_size-title_x_pos
511
	mov	ebx, title_x_pos*10000h + data_x_pos+data_x_size-title_x_pos
512
	mov	ecx, title_y_pos*10000h + title_y_size
512
	mov	ecx, title_y_pos*10000h + title_y_size
513
	int	40h
513
	int	40h
514
draw_title:
514
draw_title:
515
	mov	al, 38
515
	mov	al, 38
516
	mov	ebx, (data_x_pos-2)*10000h + title_x_pos-5
516
	mov	ebx, (data_x_pos-2)*10000h + title_x_pos-5
517
	mov	ecx, (title_y_pos+5)*10001h
517
	mov	ecx, (title_y_pos+5)*10001h
518
	xor	edx, edx
518
	xor	edx, edx
519
	int	40h
519
	int	40h
520
	push	NoPrgLoaded_len
520
	push	NoPrgLoaded_len
521
	pop	esi
521
	pop	esi
522
	cmp	[debuggee_pid], 0
522
	cmp	[debuggee_pid], 0
523
	jz	@f
523
	jz	@f
524
	mov	esi, [prgname_len]
524
	mov	esi, [prgname_len]
525
@@:	imul	ebx, esi, 6
525
@@:	imul	ebx, esi, 6
526
	add	ebx, title_x_pos+4
526
	add	ebx, title_x_pos+4
527
	shl	ebx, 16
527
	shl	ebx, 16
528
	mov	bx, data_x_pos+data_x_size-10-5-6*7
528
	mov	bx, data_x_pos+data_x_size-10-5-6*7
529
	cmp	[bSuspended], 0
529
	cmp	[bSuspended], 0
530
	jz	@f
530
	jz	@f
531
	add	ebx, 6
531
	add	ebx, 6
532
@@:
532
@@:
533
	int	40h
533
	int	40h
534
	mov	ebx, (data_x_pos+data_x_size-10+4)*0x10000 + data_x_pos+data_x_size+2
534
	mov	ebx, (data_x_pos+data_x_size-10+4)*0x10000 + data_x_pos+data_x_size+2
535
	int	40h
535
	int	40h
536
	mov	al, 4
536
	mov	al, 4
537
	mov	ebx, title_x_pos*10000h+title_y_pos
537
	mov	ebx, title_x_pos*10000h+title_y_pos
538
	xor	ecx, ecx
538
	xor	ecx, ecx
539
	mov	edx, NoPrgLoaded_str
539
	mov	edx, NoPrgLoaded_str
540
	cmp	[debuggee_pid], 0
540
	cmp	[debuggee_pid], 0
541
	jz	@f
541
	jz	@f
542
	mov	edx, [prgname_ptr]
542
	mov	edx, [prgname_ptr]
543
@@:
543
@@:
544
	int	40h
544
	int	40h
545
	cmp	[debuggee_pid], 0
545
	cmp	[debuggee_pid], 0
546
	jz	.nodebuggee
546
	jz	.nodebuggee
547
	mov	ebx, (data_x_pos+data_x_size-10-6*7)*10000h + title_y_pos
547
	mov	ebx, (data_x_pos+data_x_size-10-6*7)*10000h + title_y_pos
548
	mov	edx, aRunning
548
	mov	edx, aRunning
549
	push	7
549
	push	7
550
	pop	esi
550
	pop	esi
551
	cmp	[bSuspended], 0
551
	cmp	[bSuspended], 0
552
	jz	@f
552
	jz	@f
553
	add	ebx, 6*10000h
553
	add	ebx, 6*10000h
554
	mov	edx, aPaused
554
	mov	edx, aPaused
555
	dec	esi
555
	dec	esi
556
@@:
556
@@:
557
	int	40h
557
	int	40h
558
	ret
558
	ret
559
.nodebuggee:
559
.nodebuggee:
560
	mov	al, 38
560
	mov	al, 38
561
	mov	ebx, (data_x_pos+data_x_size-10-6*7-5)*0x10000 + data_x_pos+data_x_size+2
561
	mov	ebx, (data_x_pos+data_x_size-10-6*7-5)*0x10000 + data_x_pos+data_x_size+2
562
	mov	ecx, (title_y_pos+5)*10001h
562
	mov	ecx, (title_y_pos+5)*10001h
563
	xor	edx, edx
563
	xor	edx, edx
564
	jmp	@b
564
	jmp	@b
565
 
565
 
566
draw_register:
566
draw_register:
567
; in: esi->value, edx->string, ecx=string len, ebx=coord
567
; in: esi->value, edx->string, ecx=string len, ebx=coord
568
	push	edx
568
	push	edx
569
	push	ecx
569
	push	ecx
570
	push	esi
570
	push	esi
571
	mov	eax, esi
571
	mov	eax, esi
572
	mov	esi, ecx
572
	mov	esi, ecx
573
; color
573
; color
574
	mov	ecx, 808080h
574
	mov	ecx, 808080h
575
	cmp	[debuggee_pid], 0
575
	cmp	[debuggee_pid], 0
576
	jz	.cd
576
	jz	.cd
577
	cmp	[bSuspended], 0
577
	cmp	[bSuspended], 0
578
	jz	.cd
578
	jz	.cd
579
	xor	ecx, ecx
579
	xor	ecx, ecx
580
	mov	edi, [eax]
580
	mov	edi, [eax]
581
	cmp	dword [eax+oldcontext-context], edi
581
	cmp	dword [eax+oldcontext-context], edi
582
	jz	.cd
582
	jz	.cd
583
	mov	ecx, 0x00AA00
583
	mov	ecx, 0x00AA00
584
.cd:
584
.cd:
585
	push	4
585
	push	4
586
	pop	eax
586
	pop	eax
587
	int	40h
587
	int	40h
588
	imul	esi, 60000h
588
	imul	esi, 60000h
589
	lea	edx, [ebx+esi]
589
	lea	edx, [ebx+esi]
590
	mov	al, 47
590
	mov	al, 47
591
	mov	ebx, 80101h
591
	mov	ebx, 80101h
592
	mov	esi, ecx
592
	mov	esi, ecx
593
	pop	ecx
593
	pop	ecx
594
	int	40h
594
	int	40h
595
	lea	ebx, [edx+60000h*18]
595
	lea	ebx, [edx+60000h*18]
596
	mov	esi, ecx
596
	mov	esi, ecx
597
	pop	ecx
597
	pop	ecx
598
	pop	edx
598
	pop	edx
599
	add	edx, ecx
599
	add	edx, ecx
600
	ret
600
	ret
601
draw_flag:
601
draw_flag:
602
	movzx	edi, byte [edx+7]
602
	movzx	edi, byte [edx+7]
603
	bt	[_eflags], edi
603
	bt	[_eflags], edi
604
	jc	.on
604
	jc	.on
605
	or	byte [edx], 20h
605
	or	byte [edx], 20h
606
	jmp	.onoff
606
	jmp	.onoff
607
.on:
607
.on:
608
	and	byte [edx], not 20h
608
	and	byte [edx], not 20h
609
.onoff:
609
.onoff:
610
	mov	ecx, 808080h
610
	mov	ecx, 808080h
611
	cmp	[debuggee_pid], 0
611
	cmp	[debuggee_pid], 0
612
	jz	.doit
612
	jz	.doit
613
	cmp	[bSuspended], 0
613
	cmp	[bSuspended], 0
614
	jz	.doit
614
	jz	.doit
615
	xor	ecx, ecx
615
	xor	ecx, ecx
616
	bt	[_eflags], edi
616
	bt	[_eflags], edi
617
	lahf
617
	lahf
618
	bt	dword [_eflags + oldcontext - context], edi
618
	bt	dword [_eflags + oldcontext - context], edi
619
	rcl	ah, 1
619
	rcl	ah, 1
620
	test	ah, 3
620
	test	ah, 3
621
	jp	.doit
621
	jp	.doit
622
	mov	ecx, 0x00AA00
622
	mov	ecx, 0x00AA00
623
.doit:
623
.doit:
624
	mov	ah, 0
624
	mov	ah, 0
625
	int	40h
625
	int	40h
626
	ret
626
	ret
627
 
627
 
628
redraw_registers:
628
redraw_registers:
629
	push	13
629
	push	13
630
	pop	eax
630
	pop	eax
631
	mov	edx, 0xFFFFFF
631
	mov	edx, 0xFFFFFF
632
	mov	ebx, data_x_pos*10000h + data_x_size
632
	mov	ebx, data_x_pos*10000h + data_x_size
633
	mov	ecx, registers_y_pos*10000h + registers_y_size
633
	mov	ecx, registers_y_pos*10000h + registers_y_size
634
	int	40h
634
	int	40h
635
draw_registers:
635
draw_registers:
636
	mov	esi, _eax
636
	mov	esi, _eax
637
	push	4
637
	push	4
638
	pop	ecx
638
	pop	ecx
639
	mov	edx, regs_strs
639
	mov	edx, regs_strs
640
	mov	ebx, registers_x_pos*10000h+registers_y_pos
640
	mov	ebx, registers_x_pos*10000h+registers_y_pos
641
	call	draw_register
641
	call	draw_register
642
	add	esi, _ebx-_eax
642
	add	esi, _ebx-_eax
643
	call	draw_register
643
	call	draw_register
644
	add	esi, _ecx-_ebx
644
	add	esi, _ecx-_ebx
645
	call	draw_register
645
	call	draw_register
646
	add	esi, _edx-_ecx
646
	add	esi, _edx-_ecx
647
	call	draw_register
647
	call	draw_register
648
	mov	ebx, registers_x_pos*10000h+registers_y_pos+10
648
	mov	ebx, registers_x_pos*10000h+registers_y_pos+10
649
	add	esi, _esi-_edx
649
	add	esi, _esi-_edx
650
	call	draw_register
650
	call	draw_register
651
	add	esi, _edi-_esi
651
	add	esi, _edi-_esi
652
	call	draw_register
652
	call	draw_register
653
	add	esi, _ebp-_edi
653
	add	esi, _ebp-_edi
654
	call	draw_register
654
	call	draw_register
655
	add	esi, _esp-_ebp
655
	add	esi, _esp-_ebp
656
	call	draw_register
656
	call	draw_register
657
	mov	ebx, registers_x_pos*10000h+registers_y_pos+20
657
	mov	ebx, registers_x_pos*10000h+registers_y_pos+20
658
	add	esi, _eip-_esp
658
	add	esi, _eip-_esp
659
	call	draw_register
659
	call	draw_register
660
	mov	cl, 7
660
	mov	cl, 7
661
	add	esi, _eflags-_eip
661
	add	esi, _eflags-_eip
662
	call	draw_register
662
	call	draw_register
663
	mov	al, 4
663
	mov	al, 4
664
	mov	ecx, 808080h
664
	mov	ecx, 808080h
665
	cmp	[debuggee_pid], 0
665
	cmp	[debuggee_pid], 0
666
	jz	@f
666
	jz	@f
667
	cmp	[bSuspended], 0
667
	cmp	[bSuspended], 0
668
	jz	@f
668
	jz	@f
669
	xor	ecx, ecx
669
	xor	ecx, ecx
670
@@:
670
@@:
671
	mov	edx, aColon
671
	mov	edx, aColon
672
	xor	esi, esi
672
	xor	esi, esi
673
	inc	esi
673
	inc	esi
674
	mov	ebx, (registers_x_pos+37*6)*10000h + registers_y_pos+20
674
	mov	ebx, (registers_x_pos+37*6)*10000h + registers_y_pos+20
675
	int	40h
675
	int	40h
676
	mov	edx, flags
676
	mov	edx, flags
677
@@:
677
@@:
678
	add	ebx, 2*6*10000h
678
	add	ebx, 2*6*10000h
679
	call	draw_flag
679
	call	draw_flag
680
	inc	edx
680
	inc	edx
681
	cmp	dl, flags_bits and 0xFF
681
	cmp	dl, flags_bits and 0xFF
682
	jnz	@b
682
	jnz	@b
683
	ret
683
	ret
684
 
684
 
685
redraw_dump:
685
redraw_dump:
686
	push	13
686
	push	13
687
	pop	eax
687
	pop	eax
688
	mov	edx, 0xFFFFFF
688
	mov	edx, 0xFFFFFF
689
	mov	ebx, data_x_pos*10000h + data_x_size
689
	mov	ebx, data_x_pos*10000h + data_x_size
690
	mov	ecx, dump_y_pos*10000h + dump_y_size
690
	mov	ecx, dump_y_pos*10000h + dump_y_size
691
	int	40h
691
	int	40h
692
draw_dump:
692
draw_dump:
693
; addresses
693
; addresses
694
	mov	al, 47
694
	mov	al, 47
695
	mov	ebx, 80100h
695
	mov	ebx, 80100h
696
	mov	edx, data_x_pos*10000h + dump_y_pos
696
	mov	edx, data_x_pos*10000h + dump_y_pos
697
	mov	ecx, [dumppos]
697
	mov	ecx, [dumppos]
698
	mov	esi, 808080h
698
	mov	esi, 808080h
699
	cmp	[debuggee_pid], 0
699
	cmp	[debuggee_pid], 0
700
	jz	@f
700
	jz	@f
701
	cmp	[bSuspended], 0
701
	cmp	[bSuspended], 0
702
	jz	@f
702
	jz	@f
703
	xor	esi, esi
703
	xor	esi, esi
704
@@:
704
@@:
705
	int	40h
705
	int	40h
706
	add	ecx, 10h
706
	add	ecx, 10h
707
	add	edx, 10
707
	add	edx, 10
708
	cmp	dl, dump_y_pos + dump_y_size
708
	cmp	dl, dump_y_pos + dump_y_size
709
	jb	@b
709
	jb	@b
710
; hex dump of data
710
; hex dump of data
711
	mov	ebx, 20101h
711
	mov	ebx, 20101h
712
	mov	ecx, dumpdata
712
	mov	ecx, dumpdata
713
	push	ecx
713
	push	ecx
714
	xor	edi, edi
714
	xor	edi, edi
715
	mov	edx, (data_x_pos+12*6)*10000h + dump_y_pos
715
	mov	edx, (data_x_pos+12*6)*10000h + dump_y_pos
716
	cmp	[dumpread], edi
716
	cmp	[dumpread], edi
717
	jz	.hexdumpdone1
717
	jz	.hexdumpdone1
718
.hexdumploop1:
718
.hexdumploop1:
719
	int	40h
719
	int	40h
720
	add	edx, 3*6*10000h
720
	add	edx, 3*6*10000h
721
	inc	ecx
721
	inc	ecx
722
	inc	edi
722
	inc	edi
723
	test	edi, 15
723
	test	edi, 15
724
	jz	.16
724
	jz	.16
725
	test	edi, 7
725
	test	edi, 7
726
	jnz	@f
726
	jnz	@f
727
	add	edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
727
	add	edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
728
.16:
728
.16:
729
	add	edx, 10 - 6*(3*10h+2)*10000h
729
	add	edx, 10 - 6*(3*10h+2)*10000h
730
@@:
730
@@:
731
	cmp	edi, [dumpread]
731
	cmp	edi, [dumpread]
732
	jb	.hexdumploop1
732
	jb	.hexdumploop1
733
.hexdumpdone1:
733
.hexdumpdone1:
734
	mov	al, 4
734
	mov	al, 4
735
	mov	ecx, esi
735
	mov	ecx, esi
736
	mov	ebx, edx
736
	mov	ebx, edx
737
	push	2
737
	push	2
738
	pop	esi
738
	pop	esi
739
	mov	edx, aQuests
739
	mov	edx, aQuests
740
.hexdumploop2:
740
.hexdumploop2:
741
	cmp	edi, dump_height*10h
741
	cmp	edi, dump_height*10h
742
	jae	.hexdumpdone2
742
	jae	.hexdumpdone2
743
	int	40h
743
	int	40h
744
	add	ebx, 3*6*10000h
744
	add	ebx, 3*6*10000h
745
	inc	edi
745
	inc	edi
746
	test	edi, 15
746
	test	edi, 15
747
	jz	.16x
747
	jz	.16x
748
	test	edi, 7
748
	test	edi, 7
749
	jnz	.hexdumploop2
749
	jnz	.hexdumploop2
750
	add	ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
750
	add	ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
751
.16x:
751
.16x:
752
	add	ebx, 10 - 6*(3*10h+2)*10000h
752
	add	ebx, 10 - 6*(3*10h+2)*10000h
753
	jmp	.hexdumploop2
753
	jmp	.hexdumploop2
754
.hexdumpdone2:
754
.hexdumpdone2:
755
	dec	esi
755
	dec	esi
756
; colon, minus signs
756
; colon, minus signs
757
	mov	ebx, (data_x_pos+8*6)*10000h + dump_y_pos
757
	mov	ebx, (data_x_pos+8*6)*10000h + dump_y_pos
758
	mov	edx, aColon
758
	mov	edx, aColon
759
@@:
759
@@:
760
	int	40h
760
	int	40h
761
	add	ebx, 10
761
	add	ebx, 10
762
	cmp	bl, dump_y_pos+dump_height*10
762
	cmp	bl, dump_y_pos+dump_height*10
763
	jb	@b
763
	jb	@b
764
	mov	ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos
764
	mov	ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos
765
	mov	edx, aMinus
765
	mov	edx, aMinus
766
@@:
766
@@:
767
	int	40h
767
	int	40h
768
	add	ebx, 10
768
	add	ebx, 10
769
	cmp	bl, dump_y_pos+dump_height*10
769
	cmp	bl, dump_y_pos+dump_height*10
770
	jb	@b
770
	jb	@b
771
; ASCII data
771
; ASCII data
772
	mov	ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos
772
	mov	ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos
773
	mov	edi, dump_height*10h
773
	mov	edi, dump_height*10h
774
	pop	edx
774
	pop	edx
775
.asciiloop:
775
.asciiloop:
776
	push	edx
776
	push	edx
777
	cmp	byte [edx], 20h
777
	cmp	byte [edx], 20h
778
	jae	@f
778
	jae	@f
779
	mov	edx, aPoint
779
	mov	edx, aPoint
780
@@:
780
@@:
781
	int	40h
781
	int	40h
782
	pop	edx
782
	pop	edx
783
	inc	edx
783
	inc	edx
784
	add	ebx, 6*10000h
784
	add	ebx, 6*10000h
785
	dec	edi
785
	dec	edi
786
	jz	.asciidone
786
	jz	.asciidone
787
	test	edi, 15
787
	test	edi, 15
788
	jnz	.asciiloop
788
	jnz	.asciiloop
789
	add	ebx, 10 - 6*10h*10000h
789
	add	ebx, 10 - 6*10h*10000h
790
	jmp	.asciiloop
790
	jmp	.asciiloop
791
.asciidone:
791
.asciidone:
792
	ret
792
	ret
793
 
793
 
794
redraw_disasm:
794
redraw_disasm:
795
	push	13
795
	push	13
796
	pop	eax
796
	pop	eax
797
	mov	edx, 0xFFFFFF
797
	mov	edx, 0xFFFFFF
798
	mov	ebx, data_x_pos*10000h + data_x_size
798
	mov	ebx, data_x_pos*10000h + data_x_size
799
	mov	ecx, (disasm_y_pos-1)*10000h + (disasm_y_size+1)
799
	mov	ecx, (disasm_y_pos-1)*10000h + (disasm_y_size+1)
800
	int	40h
800
	int	40h
801
draw_disasm:
801
draw_disasm:
802
	mov	eax, [disasm_start_pos]
802
	mov	eax, [disasm_start_pos]
803
	mov	[disasm_cur_pos], eax
803
	mov	[disasm_cur_pos], eax
804
	and	[disasm_cur_str], 0
804
	and	[disasm_cur_str], 0
805
.loop:
805
.loop:
806
	push	[disasm_cur_pos]
806
	push	[disasm_cur_pos]
807
	call	disasm_instr
807
	call	disasm_instr
808
	pop	ebp
808
	pop	ebp
809
	jc	.loopend
809
	jc	.loopend
810
	xor	esi, esi	; default color: black
810
	xor	esi, esi	; default color: black
811
	mov	ebx, data_x_pos*10000h + data_x_size
811
	mov	ebx, data_x_pos*10000h + data_x_size
812
	mov	ecx, [disasm_cur_str]
812
	mov	ecx, [disasm_cur_str]
813
	imul	ecx, 10*10000h
813
	imul	ecx, 10*10000h
814
	add	ecx, (disasm_y_pos-1)*10000h + 10
814
	add	ecx, (disasm_y_pos-1)*10000h + 10
815
	mov	eax, ebp
815
	mov	eax, ebp
816
	pushad
816
	pushad
817
	call	find_enabled_breakpoint
817
	call	find_enabled_breakpoint
818
	popad
818
	popad
819
	jnz	.nored
819
	jnz	.nored
820
	push	13
820
	push	13
821
	pop	eax
821
	pop	eax
822
	mov	edx, 0xFF0000
822
	mov	edx, 0xFF0000
823
	int	40h
823
	int	40h
824
.nored:
824
.nored:
825
	mov	eax, [_eip]
825
	mov	eax, [_eip]
826
	cmp	eax, ebp
826
	cmp	eax, ebp
827
	jnz	.noblue
827
	jnz	.noblue
828
	push	13
828
	push	13
829
	pop	eax
829
	pop	eax
830
	mov	edx, 0x0000FF
830
	mov	edx, 0x0000FF
831
	int	40h
831
	int	40h
832
	mov	esi, 0xFFFFFF	; on blue bgr, use white color
832
	mov	esi, 0xFFFFFF	; on blue bgr, use white color
833
.noblue:
833
.noblue:
834
	push	47
834
	push	47
835
	pop	eax
835
	pop	eax
836
	mov	ebx, 80100h
836
	mov	ebx, 80100h
837
	mov	edx, [disasm_cur_str]
837
	mov	edx, [disasm_cur_str]
838
	imul	edx, 10
838
	imul	edx, 10
839
	add	edx, data_x_pos*10000h + disasm_y_pos
839
	add	edx, data_x_pos*10000h + disasm_y_pos
840
	mov	ecx, ebp
840
	mov	ecx, ebp
841
	int	40h
841
	int	40h
842
	mov	al, 4
842
	mov	al, 4
843
	lea	ebx, [edx+8*6*10000h]
843
	lea	ebx, [edx+8*6*10000h]
844
	mov	ecx, esi
844
	mov	ecx, esi
845
	push	1
845
	push	1
846
	pop	esi
846
	pop	esi
847
	mov	edx, aColon
847
	mov	edx, aColon
848
	int	40h
848
	int	40h
849
	push	9
849
	push	9
850
	pop	edi
850
	pop	edi
851
	lea	edx, [ebx+2*6*10000h]
851
	lea	edx, [ebx+2*6*10000h]
852
	mov	esi, ecx
852
	mov	esi, ecx
853
	mov	al, 47
853
	mov	al, 47
854
	mov	ebx, 20101h
854
	mov	ebx, 20101h
855
	mov	ecx, ebp
855
	mov	ecx, ebp
856
	sub	ecx, [disasm_start_pos]
856
	sub	ecx, [disasm_start_pos]
857
	add	ecx, disasm_buffer
857
	add	ecx, disasm_buffer
858
.drawhex:
858
.drawhex:
859
	int	40h
859
	int	40h
860
	add	edx, 6*3*10000h
860
	add	edx, 6*3*10000h
861
	inc	ecx
861
	inc	ecx
862
	inc	ebp
862
	inc	ebp
863
	cmp	ebp, [disasm_cur_pos]
863
	cmp	ebp, [disasm_cur_pos]
864
	jae	.hexdone
864
	jae	.hexdone
865
	dec	edi
865
	dec	edi
866
	jnz	.drawhex
866
	jnz	.drawhex
867
	push	esi
867
	push	esi
868
	mov	esi, [disasm_cur_pos]
868
	mov	esi, [disasm_cur_pos]
869
	dec	esi
869
	dec	esi
870
	cmp	esi, ebp
870
	cmp	esi, ebp
871
	pop	esi
871
	pop	esi
872
	jbe	.drawhex
872
	jbe	.drawhex
873
	mov	al, 4
873
	mov	al, 4
874
	lea	ebx, [edx-6*10000h]
874
	lea	ebx, [edx-6*10000h]
875
	mov	ecx, esi
875
	mov	ecx, esi
876
	push	3
876
	push	3
877
	pop	esi
877
	pop	esi
878
	mov	edx, aDots
878
	mov	edx, aDots
879
	int	40h
879
	int	40h
880
	mov	esi, ecx
880
	mov	esi, ecx
881
.hexdone:
881
.hexdone:
882
	xor	eax, eax
882
	xor	eax, eax
883
	mov	edi, disasm_string
883
	mov	edi, disasm_string
884
	mov	edx, edi
884
	mov	edx, edi
885
	or	ecx, -1
885
	or	ecx, -1
886
	repnz	scasb
886
	repnz	scasb
887
	not	ecx
887
	not	ecx
888
	dec	ecx
888
	dec	ecx
889
	xchg	ecx, esi
889
	xchg	ecx, esi
890
	mov	ebx, [disasm_cur_str]
890
	mov	ebx, [disasm_cur_str]
891
	imul	ebx, 10
891
	imul	ebx, 10
892
	add	ebx, (data_x_pos+6*40)*10000h+disasm_y_pos
892
	add	ebx, (data_x_pos+6*40)*10000h+disasm_y_pos
893
	mov	al, 4
893
	mov	al, 4
894
	int	40h
894
	int	40h
895
	inc	[disasm_cur_str]
895
	inc	[disasm_cur_str]
896
	cmp	[disasm_cur_str], disasm_height
896
	cmp	[disasm_cur_str], disasm_height
897
	jb	.loop
897
	jb	.loop
898
.loopend:
898
.loopend:
899
	ret
899
	ret
900
 
900
 
901
update_disasm_eip:
901
update_disasm_eip:
902
; test if instruction at eip is showed
902
; test if instruction at eip is showed
903
	mov	ecx, disasm_height
903
	mov	ecx, disasm_height
904
	mov	eax, [disasm_start_pos]
904
	mov	eax, [disasm_start_pos]
905
	mov	[disasm_cur_pos], eax
905
	mov	[disasm_cur_pos], eax
906
@@:
906
@@:
907
	mov	eax, [_eip]
907
	mov	eax, [_eip]
908
	cmp	[disasm_cur_pos], eax
908
	cmp	[disasm_cur_pos], eax
909
	jz	redraw_disasm
909
	jz	redraw_disasm
910
	push	ecx
910
	push	ecx
911
	call	disasm_instr
911
	call	disasm_instr
912
	pop	ecx
912
	pop	ecx
913
	jc	@f
913
	jc	@f
914
	loop	@b
914
	loop	@b
915
@@:
915
@@:
916
update_disasm_eip_force:
916
update_disasm_eip_force:
917
	mov	eax, [_eip]
917
	mov	eax, [_eip]
918
	mov	[disasm_start_pos], eax
918
	mov	[disasm_start_pos], eax
919
update_disasm:
919
update_disasm:
920
	cmp	[debuggee_pid], 0
920
	cmp	[debuggee_pid], 0
921
	jz	.no
921
	jz	.no
922
	push	69
922
	push	69
923
	pop	eax
923
	pop	eax
924
	push	6
924
	push	6
925
	pop	ebx
925
	pop	ebx
926
	mov	ecx, [debuggee_pid]
926
	mov	ecx, [debuggee_pid]
927
	mov	edi, disasm_buffer
927
	mov	edi, disasm_buffer
928
	mov	edx, 256
928
	mov	edx, 256
929
	mov	esi, [disasm_start_pos]
929
	mov	esi, [disasm_start_pos]
930
	int	40h
930
	int	40h
931
	cmp	eax, -1
931
	cmp	eax, -1
932
	jnz	@f
932
	jnz	@f
933
	mov	esi, read_mem_err
933
	mov	esi, read_mem_err
934
	call	put_message
934
	call	put_message
935
.no:
935
.no:
936
	xor	eax, eax
936
	xor	eax, eax
937
@@:
937
@@:
938
	mov	[disasm_buf_size], eax
938
	mov	[disasm_buf_size], eax
939
	call	restore_from_breaks
939
	call	restore_from_breaks
940
	jmp	redraw_disasm
940
	jmp	redraw_disasm
941
 
941
 
942
draw_window:
942
draw_window:
943
; start redraw
943
; start redraw
944
	push	12
944
	push	12
945
	pop	eax
945
	pop	eax
946
	push	1
946
	push	1
947
	pop	ebx
947
	pop	ebx
948
	int	40h
948
	int	40h
949
; define window
949
; define window
950
	xor	eax, eax
950
	xor	eax, eax
951
	mov	ebx, wnd_x_size
951
	mov	ebx, wnd_x_size
952
	mov	ecx, wnd_y_size
952
	mov	ecx, wnd_y_size
953
	mov	edx, 3FFFFFFh
953
	mov	edx, 3FFFFFFh
954
	int	40h
954
	int	40h
955
; caption
955
; caption
956
	mov	al, 4
956
	mov	al, 4
957
	mov	ecx, 0xFFFFFF
957
	mov	ecx, 0xFFFFFF
958
	mov	ebx, 80008h
958
	mov	ebx, 80008h
959
	mov	edx, caption_str
959
	mov	edx, caption_str
960
	push	caption_len
960
	push	caption_len
961
	pop	esi
961
	pop	esi
962
	int	40h
962
	int	40h
963
; messages frame
963
; messages frame
964
	mov	al, 38
964
	mov	al, 38
965
	mov	ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2)
965
	mov	ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2)
966
	push	ebx
966
	push	ebx
967
	mov	ecx, (messages_y_pos-2)*10001h
967
	mov	ecx, (messages_y_pos-2)*10001h
968
	xor	edx, edx
968
	xor	edx, edx
969
	int	40h
969
	int	40h
970
	mov	ecx, (messages_y_pos+messages_y_size+2)*10001h
970
	mov	ecx, (messages_y_pos+messages_y_size+2)*10001h
971
	int	40h
971
	int	40h
972
	mov	ebx, (messages_x_pos-2)*10001h
972
	mov	ebx, (messages_x_pos-2)*10001h
973
	push	ebx
973
	push	ebx
974
	mov	ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2)
974
	mov	ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2)
975
	int	40h
975
	int	40h
976
	mov	ebx, (messages_x_pos+messages_x_size+2)*10001h
976
	mov	ebx, (messages_x_pos+messages_x_size+2)*10001h
977
	push	ebx
977
	push	ebx
978
	int	40h
978
	int	40h
979
; command line frame
979
; command line frame
980
	mov	ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2)
980
	mov	ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2)
981
	pop	ebx
981
	pop	ebx
982
	int	40h
982
	int	40h
983
	pop	ebx
983
	pop	ebx
984
	int	40h
984
	int	40h
985
	pop	ebx
985
	pop	ebx
986
	mov	ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h
986
	mov	ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h
987
	int	40h
987
	int	40h
988
	mov	ecx, (cmdline_y_pos-2)*10001h
988
	mov	ecx, (cmdline_y_pos-2)*10001h
989
	int	40h
989
	int	40h
990
; messages
990
; messages
991
	call	draw_messages
991
	call	draw_messages
992
; command line & cursor
992
; command line & cursor
993
	call	draw_cmdline
993
	call	draw_cmdline
994
	call	draw_cursor
994
	call	draw_cursor
995
; title & registers & dump & disasm
995
; title & registers & dump & disasm
996
	mov	al, 38
996
	mov	al, 38
997
	mov	ebx, (data_x_pos-2)*10001h
997
	mov	ebx, (data_x_pos-2)*10001h
998
	mov	ecx, (title_y_pos+5)*10000h + (messages_y_pos-2)
998
	mov	ecx, (title_y_pos+5)*10000h + (messages_y_pos-2)
999
	int	40h
999
	int	40h
1000
	mov	ebx, (data_x_pos+data_x_size+2)*10001h
1000
	mov	ebx, (data_x_pos+data_x_size+2)*10001h
1001
	int	40h
1001
	int	40h
1002
	mov	ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2)
1002
	mov	ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2)
1003
	mov	ecx, (dump_y_pos-3)*10001h
1003
	mov	ecx, (dump_y_pos-3)*10001h
1004
	int	40h
1004
	int	40h
1005
	mov	ecx, (disasm_y_pos-4)*10001h
1005
	mov	ecx, (disasm_y_pos-4)*10001h
1006
	int	40h
1006
	int	40h
1007
	call	draw_title
1007
	call	draw_title
1008
	call	draw_registers
1008
	call	draw_registers
1009
	call	draw_dump
1009
	call	draw_dump
1010
	call	draw_disasm
1010
	call	draw_disasm
1011
; end redraw
1011
; end redraw
1012
	mov	al, 12
1012
	mov	al, 12
1013
	push	2
1013
	push	2
1014
	pop	ebx
1014
	pop	ebx
1015
	int	40h
1015
	int	40h
1016
	ret
1016
	ret
1017
 
1017
 
1018
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1018
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1019
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1019
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1020
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1020
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1021
 
1021
 
1022
OnHelp:
1022
OnHelp:
1023
	mov	esi, help_msg
1023
	mov	esi, help_msg
1024
	mov	edi, [curarg]
1024
	mov	edi, [curarg]
1025
	cmp	byte [edi], 0
1025
	cmp	byte [edi], 0
1026
	jz	.x
1026
	jz	.x
1027
	mov	esi, help_groups
1027
	mov	esi, help_groups
1028
	call	find_cmd
1028
	call	find_cmd
1029
	jc	.nocmd
1029
	jc	.nocmd
1030
	mov	esi, [esi+12]
1030
	mov	esi, [esi+12]
1031
.x:
1031
.x:
1032
	jmp	put_message
1032
	jmp	put_message
1033
.nocmd:
1033
.nocmd:
1034
	mov	esi, aUnknownCommand
1034
	mov	esi, aUnknownCommand
1035
	jmp	.x
1035
	jmp	.x
1036
 
1036
 
1037
OnQuit:
1037
OnQuit:
1038
	xor	eax, eax
1038
	xor	eax, eax
1039
	dec	eax
1039
	dec	eax
1040
	int	40h
1040
	int	40h
1041
 
1041
 
1042
get_new_context:
1042
get_new_context:
1043
	mov	esi, context
1043
	mov	esi, context
1044
	mov	edi, oldcontext
1044
	mov	edi, oldcontext
1045
	mov	ecx, 10
1045
	mov	ecx, 10
1046
	rep	movsd
1046
	rep	movsd
1047
get_context:
1047
get_context:
1048
	push	1
1048
	push	1
1049
	pop	ebx
1049
	pop	ebx
1050
	push	69
1050
	push	69
1051
	pop	eax
1051
	pop	eax
1052
	mov	ecx, [debuggee_pid]
1052
	mov	ecx, [debuggee_pid]
1053
	mov	esi, context
1053
	mov	esi, context
1054
	push	28h
1054
	push	28h
1055
	pop	edx
1055
	pop	edx
1056
	int	40h
1056
	int	40h
1057
	ret
1057
	ret
1058
set_context:
1058
set_context:
1059
	push	2
1059
	push	2
1060
	pop	ebx
1060
	pop	ebx
1061
	push	69
1061
	push	69
1062
	pop	eax
1062
	pop	eax
1063
	mov	ecx, [debuggee_pid]
1063
	mov	ecx, [debuggee_pid]
1064
	mov	esi, context
1064
	mov	esi, context
1065
	push	28h
1065
	push	28h
1066
	pop	edx
1066
	pop	edx
1067
	int	40h
1067
	int	40h
1068
	ret
1068
	ret
1069
 
1069
 
1070
get_dump:
1070
get_dump:
1071
	mov	edi, dumpdata
1071
	mov	edi, dumpdata
1072
	mov	esi, [edi-4]
1072
	mov	esi, [edi-4]
1073
	mov	edx, dump_height*10h
1073
	mov	edx, dump_height*10h
1074
	mov	ecx, edx
1074
	mov	ecx, edx
1075
	xor	eax, eax
1075
	xor	eax, eax
1076
	push	edi
1076
	push	edi
1077
	rep	stosb
1077
	rep	stosb
1078
	pop	edi
1078
	pop	edi
1079
	mov	ecx, [debuggee_pid]
1079
	mov	ecx, [debuggee_pid]
1080
	mov	al, 69
1080
	mov	al, 69
1081
	push	6
1081
	push	6
1082
	pop	ebx
1082
	pop	ebx
1083
	int	40h
1083
	int	40h
1084
	cmp	eax, -1
1084
	cmp	eax, -1
1085
	jnz	@f
1085
	jnz	@f
1086
	mov	esi, read_mem_err
1086
	mov	esi, read_mem_err
1087
	call	put_message
1087
	call	put_message
1088
	xor	eax, eax
1088
	xor	eax, eax
1089
@@:
1089
@@:
1090
	mov	[edi-8], eax
1090
	mov	[edi-8], eax
1091
;	call	restore_from_breaks
1091
;	call	restore_from_breaks
1092
;	ret
1092
;	ret
1093
restore_from_breaks:
1093
restore_from_breaks:
1094
; in: edi=buffer,eax=size,esi=address
1094
; in: edi=buffer,eax=size,esi=address
1095
	mov	ebx, breakpoints
1095
	mov	ebx, breakpoints
1096
@@:
1096
@@:
1097
	test	byte [ebx+4], 1
1097
	test	byte [ebx+4], 1
1098
	jz	.cont		; ignore invalid
1098
	jz	.cont		; ignore invalid
1099
	test	byte [ebx+4], 2 or 8
1099
	test	byte [ebx+4], 2 or 8
1100
	jnz	.cont		; ignore disabled and memory breaks
1100
	jnz	.cont		; ignore disabled and memory breaks
1101
	mov	ecx, [ebx]
1101
	mov	ecx, [ebx]
1102
	sub	ecx, esi
1102
	sub	ecx, esi
1103
	cmp	ecx, eax
1103
	cmp	ecx, eax
1104
	jae	.cont
1104
	jae	.cont
1105
	mov	dl, [ebx+5]
1105
	mov	dl, [ebx+5]
1106
	mov	[edi+ecx], dl
1106
	mov	[edi+ecx], dl
1107
.cont:
1107
.cont:
1108
	add	ebx, 6
1108
	add	ebx, 6
1109
	cmp	ebx, breakpoints+breakpoints_n*6
1109
	cmp	ebx, breakpoints+breakpoints_n*6
1110
	jb	@b
1110
	jb	@b
1111
	ret
1111
	ret
1112
 
1112
 
1113
OnLoad:
1113
OnLoad:
1114
	mov	esi, [curarg]
1114
	mov	esi, [curarg]
1115
OnLoadInit:
1115
OnLoadInit:
1116
	mov	edi, loadname
1116
	mov	edi, loadname
1117
	or	[prgname_len], -1
1117
	or	[prgname_len], -1
1118
	mov	[prgname_ptr], edi
1118
	mov	[prgname_ptr], edi
1119
.copyname:
1119
.copyname:
1120
	lodsb
1120
	lodsb
1121
	stosb
1121
	stosb
1122
	inc	[prgname_len]
1122
	inc	[prgname_len]
1123
	cmp	al, '/'
1123
	cmp	al, '/'
1124
	jnz	@f
1124
	jnz	@f
1125
	or	[prgname_len], -1
1125
	or	[prgname_len], -1
1126
	mov	[prgname_ptr], edi
1126
	mov	[prgname_ptr], edi
1127
@@:
1127
@@:
1128
	cmp	al, ' '
1128
	cmp	al, ' '
1129
	ja	.copyname
1129
	ja	.copyname
1130
	mov	byte [edi-1], 0
1130
	mov	byte [edi-1], 0
1131
	and	[load_params], 0
1131
	and	[load_params], 0
1132
	dec	esi
1132
	dec	esi
1133
	call	skip_spaces
1133
	call	skip_spaces
1134
	cmp	al, 0
1134
	cmp	al, 0
1135
	jz	@f
1135
	jz	@f
1136
	mov	[load_params], esi
1136
	mov	[load_params], esi
1137
@@:
1137
@@:
1138
	and	[dumppos], 0
1138
	and	[dumppos], 0
1139
do_reload:
1139
do_reload:
1140
	push	18
1140
	push	18
1141
	pop	eax
1141
	pop	eax
1142
	push	7
1142
	push	7
1143
	pop	ebx
1143
	pop	ebx
1144
	int	40h
1144
	int	40h
1145
	mov	[dbgwnd], eax
1145
	mov	[dbgwnd], eax
1146
	xchg	ecx, eax
1146
	xchg	ecx, eax
1147
	push	70
1147
	push	70
1148
	pop	eax
1148
	pop	eax
1149
	mov	ebx, fn70_load_block
1149
	mov	ebx, fn70_load_block
1150
	int	40h
1150
	int	40h
1151
	test	eax, eax
1151
	test	eax, eax
1152
	jns	.load_ok
1152
	jns	.load_ok
1153
.load_err:
1153
.load_err:
1154
	push	eax
1154
	push	eax
1155
	mov	esi, load_err_msg
1155
	mov	esi, load_err_msg
1156
	call	put_message
1156
	call	put_message
1157
	pop	eax
1157
	pop	eax
1158
	not	eax
1158
	not	eax
1159
	cmp	eax, 0x20
1159
	cmp	eax, 0x20
1160
	jae	.unk_err
1160
	jae	.unk_err
1161
	mov	esi, [load_err_msgs+eax*4]
1161
	mov	esi, [load_err_msgs+eax*4]
1162
	test	esi, esi
1162
	test	esi, esi
1163
	jnz	put_message
1163
	jnz	put_message
1164
.unk_err:
1164
.unk_err:
1165
	mov	esi, unk_err_msg
1165
	mov	esi, unk_err_msg
1166
	inc	eax
1166
	inc	eax
1167
	push	eax
1167
	push	eax
1168
	call	put_message_nodraw
1168
	call	put_message_nodraw
1169
	jmp	draw_messages
1169
	jmp	draw_messages
1170
.load_ok:
1170
.load_ok:
1171
	mov	[debuggee_pid], eax
1171
	mov	[debuggee_pid], eax
1172
	mov	[bSuspended], 1
1172
	mov	[bSuspended], 1
1173
	push	ecx
1173
	push	ecx
1174
	call	get_context
1174
	call	get_context
1175
	mov	edi, oldcontext
1175
	mov	edi, oldcontext
1176
	mov	ecx, 10
1176
	mov	ecx, 10
1177
	rep	movsd
1177
	rep	movsd
1178
; activate debugger window
1178
; activate debugger window
1179
	pop	ecx
1179
	pop	ecx
1180
	mov	bl, 3
1180
	mov	bl, 3
1181
	push	18
1181
	push	18
1182
	pop	eax
1182
	pop	eax
1183
	int	40h
1183
	int	40h
1184
	call	redraw_title
1184
	call	redraw_title
1185
	call	redraw_registers
1185
	call	redraw_registers
1186
	call	get_dump
1186
	call	get_dump
1187
	call	redraw_dump
1187
	call	redraw_dump
1188
	call	update_disasm_eip_force
1188
	call	update_disasm_eip_force
1189
	mov	esi, load_succ_msg
1189
	mov	esi, load_succ_msg
1190
	push	[debuggee_pid]
1190
	push	[debuggee_pid]
1191
	call	put_message_nodraw
1191
	call	put_message_nodraw
1192
	call	draw_messages
1192
	call	draw_messages
1193
; now test for packed progs
1193
; now test for packed progs
1194
	cmp	[disasm_buf_size], 100h
1194
	cmp	[disasm_buf_size], 100h
1195
	jz	@f
1195
	jz	@f
1196
	ret
1196
	ret
1197
@@:
1197
@@:
1198
	mov	esi, mxp_nrv_sig
1198
	mov	esi, mxp_nrv_sig
1199
	mov	ebp, disasm_buffer
1199
	mov	ebp, disasm_buffer
1200
	mov	edi, ebp
1200
	mov	edi, ebp
1201
	push	3
1201
	push	3
1202
	pop	ecx
1202
	pop	ecx
1203
	repz	cmpsb
1203
	repz	cmpsb
1204
	jnz	.not_mxp_nrv
1204
	jnz	.not_mxp_nrv
1205
	cmpsb
1205
	cmpsb
1206
	mov	cl, mxp_nrv_sig_size-4
1206
	mov	cl, mxp_nrv_sig_size-4
1207
	repz	cmpsb
1207
	repz	cmpsb
1208
	mov	esi, mxp_nrv_name
1208
	mov	esi, mxp_nrv_name
1209
	jz	.packed
1209
	jz	.packed
1210
.not_mxp_nrv:
1210
.not_mxp_nrv:
1211
	mov	esi, mxp_sig
1211
	mov	esi, mxp_sig
1212
	mov	edi, ebp
1212
	mov	edi, ebp
1213
	mov	cl, mxp_sig_size
1213
	mov	cl, mxp_sig_size
1214
	repz	cmpsb
1214
	repz	cmpsb
1215
	mov	esi, mxp_name
1215
	mov	esi, mxp_name
1216
	jz	.packed
1216
	jz	.packed
1217
.not_mxp:
1217
.not_mxp:
1218
	mov	esi, mxp_lzo_sig1
1218
	mov	esi, mxp_lzo_sig1
1219
	mov	edi, ebp
1219
	mov	edi, ebp
1220
	mov	cl, mxp_lzo_sig1_size
1220
	mov	cl, mxp_lzo_sig1_size
1221
	repz	cmpsb
1221
	repz	cmpsb
1222
	mov	esi, mxp_lzo_name
1222
	mov	esi, mxp_lzo_name
1223
	jz	.packed
1223
	jz	.packed
1224
	mov	esi, mxp_lzo_sig2
1224
	mov	esi, mxp_lzo_sig2
1225
	mov	edi, ebp
1225
	mov	edi, ebp
1226
	mov	cl, 8
1226
	mov	cl, 8
1227
	repz	cmpsb
1227
	repz	cmpsb
1228
	jnz	.not_mxp_lzo
1228
	jnz	.not_mxp_lzo
1229
	cmpsb
1229
	cmpsb
1230
	mov	cl, mxp_lzo_sig2_size - 9
1230
	mov	cl, mxp_lzo_sig2_size - 9
1231
	repz	cmpsb
1231
	repz	cmpsb
1232
	mov	esi, mxp_lzo_name
1232
	mov	esi, mxp_lzo_name
1233
	jz	.packed
1233
	jz	.packed
1234
.not_mxp_lzo:
1234
.not_mxp_lzo:
1235
	mov	esi, mtappack_name
1235
	mov	esi, mtappack_name
1236
	cmp	dword [ebp], 0xBF5E246A
1236
	cmp	dword [ebp], 0xBF5E246A
1237
	jnz	.not_mtappack
1237
	jnz	.not_mtappack
1238
	cmp	dword [ebp+8], 0xEC4E8B57
1238
	cmp	dword [ebp+8], 0xEC4E8B57
1239
	jnz	.not_mtappack1
1239
	jnz	.not_mtappack1
1240
	cmp	dword [ebp+12], 0x8D5EA4F3
1240
	cmp	dword [ebp+12], 0x8D5EA4F3
1241
	jnz	.not_mtappack1
1241
	jnz	.not_mtappack1
1242
	cmp	byte [ebp+12h], 0xE9
1242
	cmp	byte [ebp+12h], 0xE9
1243
	jz	.packed
1243
	jz	.packed
1244
.not_mtappack1:
1244
.not_mtappack1:
1245
	cmp	word [ebp+8], 0xB957
1245
	cmp	word [ebp+8], 0xB957
1246
	jnz	.not_mtappack
1246
	jnz	.not_mtappack
1247
	cmp	dword [ebp+14], 0x575EA4F3
1247
	cmp	dword [ebp+14], 0x575EA4F3
1248
	jnz	.not_mtappack2
1248
	jnz	.not_mtappack2
1249
	cmp	byte [ebp+17h], 0xE9
1249
	cmp	byte [ebp+17h], 0xE9
1250
	jz	.packed
1250
	jz	.packed
1251
.not_mtappack2:
1251
.not_mtappack2:
1252
	cmp	dword [ebp+14], 0x5F8DA4F3
1252
	cmp	dword [ebp+14], 0x5F8DA4F3
1253
	jnz	.not_mtappack3
1253
	jnz	.not_mtappack3
1254
	cmp	word [ebp+18], 0xE9FC
1254
	cmp	word [ebp+18], 0xE9FC
1255
	jz	.packed
1255
	jz	.packed
1256
.not_mtappack3:
1256
.not_mtappack3:
1257
	cmp	word [ebp+14], 0xA4F3
1257
	cmp	word [ebp+14], 0xA4F3
1258
	jnz	.not_mtappack
1258
	jnz	.not_mtappack
1259
	cmp	byte [ebp+15h], 0xE9
1259
	cmp	byte [ebp+15h], 0xE9
1260
	jz	.packed
1260
	jz	.packed
1261
.not_mtappack:
1261
.not_mtappack:
1262
	ret
1262
	ret
1263
.packed:
1263
.packed:
1264
	push	esi
1264
	push	esi
1265
	mov	esi, aPacked1
1265
	mov	esi, aPacked1
1266
	call	put_message_nodraw
1266
	call	put_message_nodraw
1267
	pop	esi
1267
	pop	esi
1268
	call	put_message_nodraw
1268
	call	put_message_nodraw
1269
	mov	esi, aPacked2
1269
	mov	esi, aPacked2
1270
	call	put_message
1270
	call	put_message
1271
	call	hide_cursor
1271
	call	hide_cursor
1272
	push	40
1272
	push	40
1273
	pop	eax
1273
	pop	eax
1274
	push	7
1274
	push	7
1275
	pop	ebx
1275
	pop	ebx
1276
	int	40h
1276
	int	40h
1277
.wait:
1277
.wait:
1278
	push	10
1278
	push	10
1279
	pop	eax
1279
	pop	eax
1280
	int	40h
1280
	int	40h
1281
	dec	eax
1281
	dec	eax
1282
	jz	.redraw
1282
	jz	.redraw
1283
	dec	eax
1283
	dec	eax
1284
	jz	.key
1284
	jz	.key
1285
	or	eax, -1
1285
	or	eax, -1
1286
	int	40h
1286
	int	40h
1287
.redraw:
1287
.redraw:
1288
	call	draw_window
1288
	call	draw_window
1289
	call	hide_cursor
1289
	call	hide_cursor
1290
	jmp	.wait
1290
	jmp	.wait
1291
.key:
1291
.key:
1292
	mov	al, 2
1292
	mov	al, 2
1293
	int	40h
1293
	int	40h
1294
	cmp	ah, 'y'
1294
	cmp	ah, 'y'
1295
	jz	.yes
1295
	jz	.yes
1296
	cmp	ah, 'Y'
1296
	cmp	ah, 'Y'
1297
	jz	.yes
1297
	jz	.yes
1298
	cmp	ah, 0xD
1298
	cmp	ah, 0xD
1299
	jz	.yes
1299
	jz	.yes
1300
	cmp	ah, 'n'
1300
	cmp	ah, 'n'
1301
	jz	.no
1301
	jz	.no
1302
	cmp	ah, 'N'
1302
	cmp	ah, 'N'
1303
	jnz	.wait
1303
	jnz	.wait
1304
.no:
1304
.no:
1305
	push	40
1305
	push	40
1306
	pop	eax
1306
	pop	eax
1307
	mov	ebx, 0x107
1307
	mov	ebx, 0x107
1308
	int	40h
1308
	int	40h
1309
	call	draw_cursor
1309
	call	draw_cursor
1310
	mov	esi, aN_str
1310
	mov	esi, aN_str
1311
	jmp	put_message
1311
	jmp	put_message
1312
.yes:
1312
.yes:
1313
	push	40
1313
	push	40
1314
	pop	eax
1314
	pop	eax
1315
	mov	ebx, 0x107
1315
	mov	ebx, 0x107
1316
	int	40h
1316
	int	40h
1317
	call	draw_cursor
1317
	call	draw_cursor
1318
	mov	esi, aY_str
1318
	mov	esi, aY_str
1319
	call	put_message
1319
	call	put_message
1320
	call	OnUnpack
1320
	call	OnUnpack
1321
	ret
1321
	ret
1322
 
1322
 
1323
mxp_nrv_sig:
1323
mxp_nrv_sig:
1324
	xor	eax, eax
1324
	xor	eax, eax
1325
	mov	ecx, 0x95	; 0xA1 for programs with parameters
1325
	mov	ecx, 0x95	; 0xA1 for programs with parameters
1326
	mov	[eax], ecx
1326
	mov	[eax], ecx
1327
	add	ecx, [eax+24h]
1327
	add	ecx, [eax+24h]
1328
	push	40h
1328
	push	40h
1329
	pop	esi
1329
	pop	esi
1330
	mov	edi, [eax+20h]
1330
	mov	edi, [eax+20h]
1331
	push	edi
1331
	push	edi
1332
	rep	movsb
1332
	rep	movsb
1333
	jmp	dword [esp]
1333
	jmp	dword [esp]
1334
	pop	esi
1334
	pop	esi
1335
	add	esi, [eax]
1335
	add	esi, [eax]
1336
	xor	edi, edi
1336
	xor	edi, edi
1337
mxp_nrv_sig_size = $ - mxp_nrv_sig
1337
mxp_nrv_sig_size = $ - mxp_nrv_sig
1338
 
1338
 
1339
mxp_sig:
1339
mxp_sig:
1340
	mov	ecx, 1CBh
1340
	mov	ecx, 1CBh
1341
	push	46h
1341
	push	46h
1342
	pop	esi
1342
	pop	esi
1343
	mov	edi, [20h]
1343
	mov	edi, [20h]
1344
	rep	movsb
1344
	rep	movsb
1345
	mov	ecx, [24h]
1345
	mov	ecx, [24h]
1346
	rep	movsb
1346
	rep	movsb
1347
	jmp	dword [20h]
1347
	jmp	dword [20h]
1348
	mov	eax, [20h]
1348
	mov	eax, [20h]
1349
	add	eax, 1CBh
1349
	add	eax, 1CBh
1350
	push	eax
1350
	push	eax
1351
	push	dword [24h]
1351
	push	dword [24h]
1352
	push	0
1352
	push	0
1353
	push	8
1353
	push	8
1354
	call	$+0x25
1354
	call	$+0x25
1355
mxp_sig_size = $ - mxp_sig
1355
mxp_sig_size = $ - mxp_sig
1356
 
1356
 
1357
mxp_lzo_sig1:
1357
mxp_lzo_sig1:
1358
	xor	eax, eax
1358
	xor	eax, eax
1359
	mov	ebp, 0FFh
1359
	mov	ebp, 0FFh
1360
	mov	ecx, 175h
1360
	mov	ecx, 175h
1361
	mov	[eax], ecx
1361
	mov	[eax], ecx
1362
	add	ecx, [eax+24h]
1362
	add	ecx, [eax+24h]
1363
	push	45h
1363
	push	45h
1364
	pop	esi
1364
	pop	esi
1365
	mov	edi, [eax+20h]
1365
	mov	edi, [eax+20h]
1366
	push	edi
1366
	push	edi
1367
	rep	movsb
1367
	rep	movsb
1368
	jmp	dword [esp]
1368
	jmp	dword [esp]
1369
	pop	ebx
1369
	pop	ebx
1370
	add	ebx, [eax]
1370
	add	ebx, [eax]
1371
	xor	edi, edi
1371
	xor	edi, edi
1372
	cmp	byte [ebx], 11h
1372
	cmp	byte [ebx], 11h
1373
	jbe	$+0x1A
1373
	jbe	$+0x1A
1374
mxp_lzo_sig1_size = $ - mxp_lzo_sig1
1374
mxp_lzo_sig1_size = $ - mxp_lzo_sig1
1375
mxp_lzo_sig2:
1375
mxp_lzo_sig2:
1376
	xor	eax, eax
1376
	xor	eax, eax
1377
	mov	ebp, 0FFh
1377
	mov	ebp, 0FFh
1378
	mov	ecx, 188h	; or 177h
1378
	mov	ecx, 188h	; or 177h
1379
	mov	[eax], ecx
1379
	mov	[eax], ecx
1380
	add	ecx, [eax+24h]
1380
	add	ecx, [eax+24h]
1381
	push	44h
1381
	push	44h
1382
	pop	esi
1382
	pop	esi
1383
	mov	edi, [eax+20h]
1383
	mov	edi, [eax+20h]
1384
	rep	movsb
1384
	rep	movsb
1385
	jmp	dword [eax+20h]
1385
	jmp	dword [eax+20h]
1386
	mov	ebx, [eax+20h]
1386
	mov	ebx, [eax+20h]
1387
	add	ebx, [eax]
1387
	add	ebx, [eax]
1388
mxp_lzo_sig2_size = $ - mxp_lzo_sig2
1388
mxp_lzo_sig2_size = $ - mxp_lzo_sig2
1389
 
1389
 
1390
OnReload:
1390
OnReload:
1391
	cmp	[debuggee_pid], 0
1391
	cmp	[debuggee_pid], 0
1392
	jnz	terminate_reload
1392
	jnz	terminate_reload
1393
	mov	esi, need_debuggee
1393
	mov	esi, need_debuggee
1394
	cmp	byte [loadname], 0
1394
	cmp	byte [loadname], 0
1395
	jnz	do_reload
1395
	jnz	do_reload
1396
	jz	put_message
1396
	jz	put_message
1397
terminate_reload:
1397
terminate_reload:
1398
	mov	[bReload], 1
1398
	mov	[bReload], 1
1399
OnTerminate:
1399
OnTerminate:
1400
	mov	ecx, [debuggee_pid]
1400
	mov	ecx, [debuggee_pid]
1401
	push	8
1401
	push	8
1402
	pop	ebx
1402
	pop	ebx
1403
	push	69
1403
	push	69
1404
	pop	eax
1404
	pop	eax
1405
	int	40h
1405
	int	40h
1406
	ret
1406
	ret
1407
 
1407
 
1408
AfterSuspend:
1408
AfterSuspend:
1409
	mov	[bSuspended], 1
1409
	mov	[bSuspended], 1
1410
	call	get_new_context
1410
	call	get_new_context
1411
	call	get_dump
1411
	call	get_dump
1412
	call	redraw_title
1412
	call	redraw_title
1413
	call	redraw_registers
1413
	call	redraw_registers
1414
	call	redraw_dump
1414
	call	redraw_dump
1415
	call	update_disasm_eip
1415
	call	update_disasm_eip
1416
	ret
1416
	ret
1417
 
1417
 
1418
OnSuspend:
1418
OnSuspend:
1419
	mov	ecx, [debuggee_pid]
1419
	mov	ecx, [debuggee_pid]
1420
	push	4
1420
	push	4
1421
	pop	ebx
1421
	pop	ebx
1422
	push	69
1422
	push	69
1423
	pop	eax
1423
	pop	eax
1424
	int	40h
1424
	int	40h
1425
	call	AfterSuspend
1425
	call	AfterSuspend
1426
	mov	esi, aSuspended
1426
	mov	esi, aSuspended
1427
	jmp	put_message
1427
	jmp	put_message
1428
DoResume:
1428
DoResume:
1429
	mov	ecx, [debuggee_pid]
1429
	mov	ecx, [debuggee_pid]
1430
	push	5
1430
	push	5
1431
	pop	ebx
1431
	pop	ebx
1432
	push	69
1432
	push	69
1433
	pop	eax
1433
	pop	eax
1434
	int	40h
1434
	int	40h
1435
	mov	[bSuspended], 0
1435
	mov	[bSuspended], 0
1436
	ret
1436
	ret
1437
OnResume:
1437
OnResume:
1438
	mov	esi, [curarg]
1438
	mov	esi, [curarg]
1439
	cmp	byte [esi], 0
1439
	cmp	byte [esi], 0
1440
	jz	GoOn
1440
	jz	GoOn
1441
	call	calc_expression
1441
	call	calc_expression
1442
	jc	.ret
1442
	jc	.ret
1443
	mov	eax, ebp
1443
	mov	eax, ebp
1444
	push	eax
1444
	push	eax
1445
	call	find_enabled_breakpoint
1445
	call	find_enabled_breakpoint
1446
	pop	eax
1446
	pop	eax
1447
	jz	GoOn
1447
	jz	GoOn
1448
	mov	bl, 5	; valid enabled one-shot
1448
	mov	bl, 5	; valid enabled one-shot
1449
	call	add_breakpoint
1449
	call	add_breakpoint
1450
	jnc	GoOn
1450
	jnc	GoOn
1451
	mov	esi, aBreakpointLimitExceeded
1451
	mov	esi, aBreakpointLimitExceeded
1452
	call	put_message
1452
	call	put_message
1453
.ret:
1453
.ret:
1454
	ret
1454
	ret
1455
GoOn:
1455
GoOn:
1456
; test for enabled breakpoint at eip
1456
; test for enabled breakpoint at eip
1457
	mov	eax, [_eip]
1457
	mov	eax, [_eip]
1458
	call	find_enabled_breakpoint
1458
	call	find_enabled_breakpoint
1459
	jnz	.nobreak
1459
	jnz	.nobreak
1460
; temporarily disable breakpoint, make step, enable breakpoint, continue
1460
; temporarily disable breakpoint, make step, enable breakpoint, continue
1461
	inc	eax
1461
	inc	eax
1462
	mov	[temp_break], eax
1462
	mov	[temp_break], eax
1463
	mov	[bAfterGo], 1
1463
	mov	[bAfterGo], 1
1464
	dec	eax
1464
	dec	eax
1465
	call	disable_breakpoint
1465
	call	disable_breakpoint
1466
	call	get_context
1466
	call	get_context
1467
	or	byte [_eflags+1], 1		; set TF
1467
	or	byte [_eflags+1], 1		; set TF
1468
	call	set_context
1468
	call	set_context
1469
	and	byte [_eflags+1], not 1
1469
	and	byte [_eflags+1], not 1
1470
	call	DoResume
1470
	call	DoResume
1471
	ret
1471
	ret
1472
.nobreak:
1472
.nobreak:
1473
	call	DoResume
1473
	call	DoResume
1474
	call	redraw_title
1474
	call	redraw_title
1475
	call	redraw_registers
1475
	call	redraw_registers
1476
	call	redraw_dump
1476
	call	redraw_dump
1477
	ret
1477
	ret
1478
OnDetach:
1478
OnDetach:
1479
	mov	ecx, [debuggee_pid]
1479
	mov	ecx, [debuggee_pid]
1480
	push	3
1480
	push	3
1481
	pop	ebx
1481
	pop	ebx
1482
	push	69
1482
	push	69
1483
	pop	eax
1483
	pop	eax
1484
	int	40h
1484
	int	40h
1485
	and	[debuggee_pid], 0
1485
	and	[debuggee_pid], 0
1486
	call	redraw_title
1486
	call	redraw_title
1487
	call	redraw_registers
1487
	call	redraw_registers
1488
	call	redraw_dump
1488
	call	redraw_dump
1489
	mov	esi, aContinued
1489
	mov	esi, aContinued
1490
	jmp	put_message
1490
	jmp	put_message
1491
 
1491
 
1492
after_go_exception:
1492
after_go_exception:
1493
	push	eax
1493
	push	eax
1494
	mov	eax, [temp_break]
1494
	mov	eax, [temp_break]
1495
	dec	eax
1495
	dec	eax
1496
	push	esi
1496
	push	esi
1497
	call	enable_breakpoint
1497
	call	enable_breakpoint
1498
; in any case, clear TF and RF
1498
; in any case, clear TF and RF
1499
	call	get_new_context
1499
	call	get_new_context
1500
	and	[_eflags], not 10100h		; clear TF,RF
1500
	and	[_eflags], not 10100h		; clear TF,RF
1501
	call	set_context
1501
	call	set_context
1502
	xor	edx, edx
1502
	xor	edx, edx
1503
	mov	[temp_break], edx
1503
	mov	[temp_break], edx
1504
	xchg	dl, [bAfterGo]
1504
	xchg	dl, [bAfterGo]
1505
	pop	esi
1505
	pop	esi
1506
	pop	eax
1506
	pop	eax
1507
	cmp	dl, 2
1507
	cmp	dl, 2
1508
	jnz	@f
1508
	jnz	@f
1509
	lodsd
1509
	lodsd
1510
	push	esi
1510
	push	esi
1511
	call	get_dump
1511
	call	get_dump
1512
	jmp	exception.done
1512
	jmp	exception.done
1513
@@:	test	eax, eax
1513
@@:	test	eax, eax
1514
	jz	.notint1
1514
	jz	.notint1
1515
; if exception is result of single step, simply ignore it and continue
1515
; if exception is result of single step, simply ignore it and continue
1516
	test	dword [esi], 0xF
1516
	test	dword [esi], 0xF
1517
	jnz	dbgmsgstart.5
1517
	jnz	dbgmsgstart.5
1518
	lodsd
1518
	lodsd
1519
	push	esi
1519
	push	esi
1520
	mov	esi, oldcontext
1520
	mov	esi, oldcontext
1521
	mov	edi, context
1521
	mov	edi, context
1522
	mov	ecx, 28h/4
1522
	mov	ecx, 28h/4
1523
	rep	movsd
1523
	rep	movsd
1524
	call	DoResume
1524
	call	DoResume
1525
	jmp	dbgmsgend
1525
	jmp	dbgmsgend
1526
.notint1:
1526
.notint1:
1527
; in other case, work as without temp_break
1527
; in other case, work as without temp_break
1528
	lodsd
1528
	lodsd
1529
	push	esi
1529
	push	esi
1530
	push	eax
1530
	push	eax
1531
	jmp	exception.4
1531
	jmp	exception.4
1532
.notour:
1532
.notour:
1533
 
1533
 
1534
debugmsg:
1534
debugmsg:
1535
	neg	[dbgbufsize]
1535
	neg	[dbgbufsize]
1536
	mov	esi, dbgbuf
1536
	mov	esi, dbgbuf
1537
dbgmsgstart:
1537
dbgmsgstart:
1538
	lodsd
1538
	lodsd
1539
;	push	eax esi
1539
;	push	eax esi
1540
;	push	dword [esi]
1540
;	push	dword [esi]
1541
;	mov	esi, dbgmsg_str
1541
;	mov	esi, dbgmsg_str
1542
;	call	put_message_nodraw
1542
;	call	put_message_nodraw
1543
;	pop	esi eax
1543
;	pop	esi eax
1544
	add	esi, 4
1544
	add	esi, 4
1545
	dec	eax
1545
	dec	eax
1546
	jz	exception
1546
	jz	exception
1547
	dec	eax
1547
	dec	eax
1548
	jz	terminated
1548
	jz	terminated
1549
	mov	[bSuspended], 1
1549
	mov	[bSuspended], 1
1550
	cmp	[bAfterGo], 0
1550
	cmp	[bAfterGo], 0
1551
	jnz	after_go_exception
1551
	jnz	after_go_exception
1552
	push	esi
1552
	push	esi
1553
	call	get_new_context
1553
	call	get_new_context
1554
	and	[_eflags], not 10100h		; clear TF,RF
1554
	and	[_eflags], not 10100h		; clear TF,RF
1555
	call	set_context
1555
	call	set_context
1556
	pop	esi
1556
	pop	esi
1557
.5:
1557
.5:
1558
	push	esi
1558
	push	esi
1559
	call	get_dump
1559
	call	get_dump
1560
	pop	esi
1560
	pop	esi
1561
	lodsd
1561
	lodsd
1562
	xor	ecx, ecx
1562
	xor	ecx, ecx
1563
.6:
1563
.6:
1564
	bt	eax, ecx
1564
	bt	eax, ecx
1565
	jnc	.7
1565
	jnc	.7
1566
	mov	ebx, [drx_break+ecx*4]
1566
	mov	ebx, [drx_break+ecx*4]
1567
	test	ebx, ebx
1567
	test	ebx, ebx
1568
	jz	.7
1568
	jz	.7
1569
	pushad
1569
	pushad
1570
	dec	ebx
1570
	dec	ebx
1571
	push	ebx
1571
	push	ebx
1572
	mov	esi, aBreakStop
1572
	mov	esi, aBreakStop
1573
	call	put_message_nodraw
1573
	call	put_message_nodraw
1574
	popad
1574
	popad
1575
.7:
1575
.7:
1576
	inc	ecx
1576
	inc	ecx
1577
	cmp	cl, 4
1577
	cmp	cl, 4
1578
	jb	.6
1578
	jb	.6
1579
	push	esi
1579
	push	esi
1580
	jmp	exception.done_draw
1580
	jmp	exception.done_draw
1581
terminated:
1581
terminated:
1582
	push	esi
1582
	push	esi
1583
	mov	esi, terminated_msg
1583
	mov	esi, terminated_msg
1584
	call	put_message
1584
	call	put_message
1585
	and	[debuggee_pid], 0
1585
	and	[debuggee_pid], 0
1586
	and	[temp_break], 0
1586
	and	[temp_break], 0
1587
	mov	[bAfterGo], 0
1587
	mov	[bAfterGo], 0
1588
	xor	eax, eax
1588
	xor	eax, eax
1589
	mov	ecx, breakpoints_n*6/4+4
1589
	mov	ecx, breakpoints_n*6/4+4
1590
	mov	edi, breakpoints
1590
	mov	edi, breakpoints
1591
	rep	stosd
1591
	rep	stosd
1592
	cmp	[bReload], 1
1592
	cmp	[bReload], 1
1593
	sbb	[bReload], -1
1593
	sbb	[bReload], -1
1594
	jmp	exception.done
1594
	jmp	exception.done
1595
exception:
1595
exception:
1596
	mov	[bSuspended], 1
1596
	mov	[bSuspended], 1
1597
	cmp	[bAfterGo], 0
1597
	cmp	[bAfterGo], 0
1598
	jnz	after_go_exception
1598
	jnz	after_go_exception
1599
	lodsd
1599
	lodsd
1600
	push	esi
1600
	push	esi
1601
	push	eax
1601
	push	eax
1602
	call	get_new_context
1602
	call	get_new_context
1603
	and	[_eflags], not 10100h		; clear TF,RF
1603
	and	[_eflags], not 10100h		; clear TF,RF
1604
	call	set_context
1604
	call	set_context
1605
.4:
1605
.4:
1606
	call	get_dump
1606
	call	get_dump
1607
	pop	eax
1607
	pop	eax
1608
; int3 command generates exception 0D, #GP
1608
; int3 command generates exception 0D, #GP
1609
	push	eax
1609
	push	eax
1610
	cmp	al, 0Dh
1610
	cmp	al, 0Dh
1611
	jnz	.notdbg
1611
	jnz	.notdbg
1612
; check for 0xCC byte at eip
1612
; check for 0xCC byte at eip
1613
	push	0
1613
	push	0
1614
	push	69
1614
	push	69
1615
	pop	eax
1615
	pop	eax
1616
	push	6
1616
	push	6
1617
	pop	ebx
1617
	pop	ebx
1618
	mov	ecx, [debuggee_pid]
1618
	mov	ecx, [debuggee_pid]
1619
	mov	edi, esp
1619
	mov	edi, esp
1620
	mov	esi, [_eip]
1620
	mov	esi, [_eip]
1621
	push	1
1621
	push	1
1622
	pop	edx
1622
	pop	edx
1623
	int	40h
1623
	int	40h
1624
	pop	eax
1624
	pop	eax
1625
	cmp	al, 0xCC
1625
	cmp	al, 0xCC
1626
	jnz	.notdbg
1626
	jnz	.notdbg
1627
; this is either dbg breakpoint or int3 cmd in debuggee
1627
; this is either dbg breakpoint or int3 cmd in debuggee
1628
	mov	eax, [_eip]
1628
	mov	eax, [_eip]
1629
	call	find_enabled_breakpoint
1629
	call	find_enabled_breakpoint
1630
	jnz	.user_int3
1630
	jnz	.user_int3
1631
; dbg breakpoint; clear if one-shot
1631
; dbg breakpoint; clear if one-shot
1632
	pop	ecx
1632
	pop	ecx
1633
	push	eax
1633
	push	eax
1634
	mov	esi, aBreakStop
1634
	mov	esi, aBreakStop
1635
	test	byte [edi+4], 4
1635
	test	byte [edi+4], 4
1636
	jz	.put_msg_eax
1636
	jz	.put_msg_eax
1637
	pop	ecx
1637
	pop	ecx
1638
	call	clear_breakpoint
1638
	call	clear_breakpoint
1639
	jmp	.done
1639
	jmp	.done
1640
.user_int3:
1640
.user_int3:
1641
	mov	eax, [_eip]
1641
	mov	eax, [_eip]
1642
	inc	[_eip]
1642
	inc	[_eip]
1643
	pop	ecx
1643
	pop	ecx
1644
	push	eax
1644
	push	eax
1645
	call	set_context
1645
	call	set_context
1646
	mov	esi, aUserBreak
1646
	mov	esi, aUserBreak
1647
	jmp	.put_msg_eax
1647
	jmp	.put_msg_eax
1648
.notdbg:
1648
.notdbg:
1649
	mov	esi, aException
1649
	mov	esi, aException
1650
.put_msg_eax:
1650
.put_msg_eax:
1651
	call	put_message_nodraw
1651
	call	put_message_nodraw
1652
.done_draw:
1652
.done_draw:
1653
	call	draw_messages
1653
	call	draw_messages
1654
.done:
1654
.done:
1655
	push	18
1655
	push	18
1656
	pop	eax
1656
	pop	eax
1657
	push	3
1657
	push	3
1658
	pop	ebx
1658
	pop	ebx
1659
	mov	ecx, [dbgwnd]
1659
	mov	ecx, [dbgwnd]
1660
	int	40h	; activate dbg window
1660
	int	40h	; activate dbg window
1661
	call	redraw_title
1661
	call	redraw_title
1662
	call	redraw_registers
1662
	call	redraw_registers
1663
	call	redraw_dump
1663
	call	redraw_dump
1664
	call	update_disasm_eip
1664
	call	update_disasm_eip
1665
dbgmsgend:
1665
dbgmsgend:
1666
	pop	esi
1666
	pop	esi
1667
	mov	ecx, [dbgbuflen]
1667
	mov	ecx, [dbgbuflen]
1668
	add	ecx, dbgbuf
1668
	add	ecx, dbgbuf
1669
	cmp	esi, ecx
1669
	cmp	esi, ecx
1670
	jnz	dbgmsgstart
1670
	jnz	dbgmsgstart
1671
	and	[dbgbuflen], 0
1671
	and	[dbgbuflen], 0
1672
	neg	[dbgbufsize]
1672
	neg	[dbgbufsize]
1673
	cmp	[bReload], 2
1673
	cmp	[bReload], 2
1674
	jnz	@f
1674
	jnz	@f
1675
	mov	[bReload], 0
1675
	mov	[bReload], 0
1676
	call	do_reload
1676
	call	do_reload
1677
@@:
1677
@@:
1678
	jmp	waitevent
1678
	jmp	waitevent
1679
 
1679
 
1680
CtrlF7:
1680
CtrlF7:
1681
	cmp	[debuggee_pid], 0
1681
	cmp	[debuggee_pid], 0
1682
	jz	.no
1682
	jz	.no
1683
	call	OnStep
1683
	call	OnStep
1684
.no:
1684
.no:
1685
	jmp	waitevent
1685
	jmp	waitevent
1686
CtrlF8:
1686
CtrlF8:
1687
	cmp	[debuggee_pid], 0
1687
	cmp	[debuggee_pid], 0
1688
	jz	CtrlF7.no
1688
	jz	CtrlF7.no
1689
	call	OnProceed
1689
	call	OnProceed
1690
	jmp	CtrlF7.no
1690
	jmp	CtrlF7.no
1691
 
1691
 
1692
OnStep:
1692
OnStep:
1693
	cmp	[bSuspended], 0
1693
	cmp	[bSuspended], 0
1694
	jz	.running
1694
	jz	.running
1695
	call	get_context
1695
	call	get_context
1696
	or	byte [_eflags+1], 1		; set TF
1696
	or	byte [_eflags+1], 1		; set TF
1697
	call	set_context
1697
	call	set_context
1698
	and	byte [_eflags+1], not 1
1698
	and	byte [_eflags+1], not 1
1699
; if instruction at eip is "int xx", set one-shot breakpoint immediately after
1699
; if instruction at eip is "int xx", set one-shot breakpoint immediately after
1700
	mov	eax, [_eip]
1700
	mov	eax, [_eip]
1701
	call	find_enabled_breakpoint
1701
	call	find_enabled_breakpoint
1702
	jnz	@f
1702
	jnz	@f
1703
	cmp	byte [edi+5], 0xCD
1703
	cmp	byte [edi+5], 0xCD
1704
	jz	.int
1704
	jz	.int
1705
@@:
1705
@@:
1706
	push	0
1706
	push	0
1707
	push	69
1707
	push	69
1708
	pop	eax
1708
	pop	eax
1709
	push	6
1709
	push	6
1710
	pop	ebx
1710
	pop	ebx
1711
	mov	ecx, [debuggee_pid]
1711
	mov	ecx, [debuggee_pid]
1712
	push	3
1712
	push	3
1713
	pop	edx
1713
	pop	edx
1714
	mov	edi, esp
1714
	mov	edi, esp
1715
	mov	esi, [_eip]
1715
	mov	esi, [_eip]
1716
	int	40h
1716
	int	40h
1717
	cmp	eax, edx
1717
	cmp	eax, edx
1718
	pop	eax
1718
	pop	eax
1719
	jnz	.doit
1719
	jnz	.doit
1720
	cmp	al, 0xCD
1720
	cmp	al, 0xCD
1721
	jz	.int
1721
	jz	.int
-
 
1722
	cmp	ax, 0x050F
-
 
1723
	jz	.syscall_enter
-
 
1724
	cmp	ax, 0x340F
-
 
1725
	jz	.syscall_enter
1722
; resume process
1726
; resume process
1723
.doit:
1727
.doit:
1724
	call	GoOn
1728
	call	GoOn
1725
	cmp	[bAfterGo], 0
1729
	cmp	[bAfterGo], 0
1726
	jz	@f
1730
	jz	@f
1727
	mov	[bAfterGo], 2
1731
	mov	[bAfterGo], 2
1728
@@:
1732
@@:
1729
	ret
1733
	ret
-
 
1734
.syscall_enter:
-
 
1735
	and	byte [_eflags+1], not 1	; clear TF - avoid system halt (!)
-
 
1736
	call	set_context
1730
.int:
1737
.int:
1731
	mov	eax, [_eip]
1738
	mov	eax, [_eip]
1732
	inc	eax
1739
	inc	eax
1733
	inc	eax
1740
	inc	eax
1734
	push	eax
1741
	push	eax
1735
	call	find_enabled_breakpoint
1742
	call	find_enabled_breakpoint
1736
	pop	eax
1743
	pop	eax
1737
	jz	.doit
1744
	jz	.doit
1738
; there is no enabled breakpoint yet; set temporary breakpoint
1745
; there is no enabled breakpoint yet; set temporary breakpoint
1739
	mov	bl, 5
1746
	mov	bl, 5
1740
	call	add_breakpoint
1747
	call	add_breakpoint
1741
	jmp	.doit
1748
	jmp	.doit
1742
.running:
1749
.running:
1743
	mov	esi, aRunningErr
1750
	mov	esi, aRunningErr
1744
	jmp	put_message
1751
	jmp	put_message
1745
 
1752
 
1746
OnProceed:
1753
OnProceed:
1747
	cmp	[bSuspended], 0
1754
	cmp	[bSuspended], 0
1748
	jz	OnStep.running
1755
	jz	OnStep.running
1749
	mov	esi, [_eip]
1756
	mov	esi, [_eip]
1750
@@:
1757
@@:
1751
	call	get_byte_nobreak
1758
	call	get_byte_nobreak
1752
	jc	OnStep
1759
	jc	OnStep
1753
	inc	esi
1760
	inc	esi
1754
; skip prefixes
1761
; skip prefixes
1755
	call	is_prefix
1762
	call	is_prefix
1756
	jz	@b
1763
	jz	@b
1757
	cmp	al, 0xE8	; call
1764
	cmp	al, 0xE8	; call
1758
	jnz	@f
1765
	jnz	@f
1759
	add	esi, 4
1766
	add	esi, 4
1760
	jmp	.doit
1767
	jmp	.doit
1761
@@:	; A4,A5 = movs, A6,A7=cmps
1768
@@:	; A4,A5 = movs, A6,A7=cmps
1762
	cmp	al, 0xA4
1769
	cmp	al, 0xA4
1763
	jb	@f
1770
	jb	@f
1764
	cmp	al, 0xA8
1771
	cmp	al, 0xA8
1765
	jb	.doit
1772
	jb	.doit
1766
@@:	; AA,AB=stos, AC,AD=lods, AE,AF=scas
1773
@@:	; AA,AB=stos, AC,AD=lods, AE,AF=scas
1767
	cmp	al, 0xAA
1774
	cmp	al, 0xAA
1768
	jb	@f
1775
	jb	@f
1769
	cmp	al, 0xB0
1776
	cmp	al, 0xB0
1770
	jb	.doit
1777
	jb	.doit
1771
@@:	; E0=loopnz,E1=loopz,E2=loop
1778
@@:	; E0=loopnz,E1=loopz,E2=loop
1772
	cmp	al, 0xE0
1779
	cmp	al, 0xE0
1773
	jb	.noloop
1780
	jb	.noloop
1774
	cmp	al, 0xE2
1781
	cmp	al, 0xE2
1775
	ja	.noloop
1782
	ja	.noloop
1776
	inc	esi
1783
	inc	esi
1777
	jmp	.doit
1784
	jmp	.doit
1778
.noloop:	; FF /2 = call
1785
.noloop:	; FF /2 = call
1779
	cmp	al, 0xFF
1786
	cmp	al, 0xFF
1780
	jnz	OnStep
1787
	jnz	OnStep
1781
	call	get_byte_nobreak
1788
	call	get_byte_nobreak
1782
	jc	OnStep
1789
	jc	OnStep
1783
	inc	esi
1790
	inc	esi
1784
	mov	cl, al
1791
	mov	cl, al
1785
	and	al, 00111000b
1792
	and	al, 00111000b
1786
	cmp	al, 00010000b
1793
	cmp	al, 00010000b
1787
	jnz	OnStep
1794
	jnz	OnStep
1788
; skip instruction
1795
; skip instruction
1789
	mov	al, cl
1796
	mov	al, cl
1790
	and	eax, 7
1797
	and	eax, 7
1791
	shr	cl, 6
1798
	shr	cl, 6
1792
	jz	.mod0
1799
	jz	.mod0
1793
	jp	.doit
1800
	jp	.doit
1794
	cmp	al, 4
1801
	cmp	al, 4
1795
	jnz	@f
1802
	jnz	@f
1796
	inc	esi
1803
	inc	esi
1797
@@:
1804
@@:
1798
	inc	esi
1805
	inc	esi
1799
	dec	cl
1806
	dec	cl
1800
	jz	@f
1807
	jz	@f
1801
	add	esi, 3
1808
	add	esi, 3
1802
@@:
1809
@@:
1803
	jmp	.doit
1810
	jmp	.doit
1804
.mod0:
1811
.mod0:
1805
	cmp	al, 4
1812
	cmp	al, 4
1806
	jnz	@f
1813
	jnz	@f
1807
	call	get_byte_nobreak
1814
	call	get_byte_nobreak
1808
	jc	OnStep
1815
	jc	OnStep
1809
	inc	esi
1816
	inc	esi
1810
	and	al, 7
1817
	and	al, 7
1811
@@:
1818
@@:
1812
	cmp	al, 5
1819
	cmp	al, 5
1813
	jnz	.doit
1820
	jnz	.doit
1814
	add	esi, 4
1821
	add	esi, 4
1815
.doit:
1822
.doit:
1816
; insert one-shot breakpoint at esi and resume
1823
; insert one-shot breakpoint at esi and resume
1817
	call	get_byte_nobreak
1824
	call	get_byte_nobreak
1818
	jc	OnStep
1825
	jc	OnStep
1819
	mov	eax, esi
1826
	mov	eax, esi
1820
	call	find_enabled_breakpoint
1827
	call	find_enabled_breakpoint
1821
	jz	.ret
1828
	jz	.ret
1822
	mov	eax, esi
1829
	mov	eax, esi
1823
	mov	bl, 5
1830
	mov	bl, 5
1824
	call	add_breakpoint
1831
	call	add_breakpoint
1825
	jmp	OnStep.doit
1832
	jmp	OnStep.doit
1826
.ret:
1833
.ret:
1827
	ret
1834
	ret
1828
 
1835
 
1829
get_byte_nobreak:
1836
get_byte_nobreak:
1830
	mov	eax, esi
1837
	mov	eax, esi
1831
	call	find_enabled_breakpoint
1838
	call	find_enabled_breakpoint
1832
	jnz	.nobreak
1839
	jnz	.nobreak
1833
	mov	al, [edi+5]
1840
	mov	al, [edi+5]
1834
	clc
1841
	clc
1835
	ret
1842
	ret
1836
.nobreak:
1843
.nobreak:
1837
	push	69
1844
	push	69
1838
	pop	eax
1845
	pop	eax
1839
	push	6
1846
	push	6
1840
	pop	ebx
1847
	pop	ebx
1841
	mov	ecx, [debuggee_pid]
1848
	mov	ecx, [debuggee_pid]
1842
	xor	edx, edx
1849
	xor	edx, edx
1843
	push	edx
1850
	push	edx
1844
	inc	edx
1851
	inc	edx
1845
	mov	edi, esp
1852
	mov	edi, esp
1846
	int	40h
1853
	int	40h
1847
	dec	eax
1854
	dec	eax
1848
	clc
1855
	clc
1849
	jz	@f
1856
	jz	@f
1850
	stc
1857
	stc
1851
@@:	pop	eax
1858
@@:	pop	eax
1852
	ret
1859
	ret
1853
 
1860
 
1854
is_prefix:
1861
is_prefix:
1855
	cmp	al, 0x64	; fs:
1862
	cmp	al, 0x64	; fs:
1856
	jz	.ret
1863
	jz	.ret
1857
	cmp	al, 0x65	; gs:
1864
	cmp	al, 0x65	; gs:
1858
	jz	.ret
1865
	jz	.ret
1859
	cmp	al, 0x66	; use16/32
1866
	cmp	al, 0x66	; use16/32
1860
	jz	.ret
1867
	jz	.ret
1861
	cmp	al, 0x67	; addr16/32
1868
	cmp	al, 0x67	; addr16/32
1862
	jz	.ret
1869
	jz	.ret
1863
	cmp	al, 0xF0	; lock
1870
	cmp	al, 0xF0	; lock
1864
	jz	.ret
1871
	jz	.ret
1865
	cmp	al, 0xF2	; repnz
1872
	cmp	al, 0xF2	; repnz
1866
	jz	.ret
1873
	jz	.ret
1867
	cmp	al, 0xF3	; rep(z)
1874
	cmp	al, 0xF3	; rep(z)
1868
	jz	.ret
1875
	jz	.ret
1869
	cmp	al, 0x2E	; cs:
1876
	cmp	al, 0x2E	; cs:
1870
	jz	.ret
1877
	jz	.ret
1871
	cmp	al, 0x36	; ss:
1878
	cmp	al, 0x36	; ss:
1872
	jz	.ret
1879
	jz	.ret
1873
	cmp	al, 0x3E	; ds:
1880
	cmp	al, 0x3E	; ds:
1874
	jz	.ret
1881
	jz	.ret
1875
	cmp	al, 0x26	; es:
1882
	cmp	al, 0x26	; es:
1876
.ret:	ret
1883
.ret:	ret
1877
 
1884
 
1878
token_end	equ	1
1885
token_end	equ	1
1879
token_reg	equ	2
1886
token_reg	equ	2
1880
token_hex	equ	3
1887
token_hex	equ	3
1881
token_add	equ	4
1888
token_add	equ	4
1882
token_sub	equ	5
1889
token_sub	equ	5
1883
token_mul	equ	6
1890
token_mul	equ	6
1884
token_div	equ	7
1891
token_div	equ	7
1885
token_lp	equ	8
1892
token_lp	equ	8
1886
token_rp	equ	9
1893
token_rp	equ	9
1887
token_err	equ	-1
1894
token_err	equ	-1
1888
 
1895
 
1889
is_hex_digit:
1896
is_hex_digit:
1890
	cmp	al, '0'
1897
	cmp	al, '0'
1891
	jb	.no
1898
	jb	.no
1892
	cmp	al, '9'
1899
	cmp	al, '9'
1893
	jbe	.09
1900
	jbe	.09
1894
	cmp	al, 'A'
1901
	cmp	al, 'A'
1895
	jb	.no
1902
	jb	.no
1896
	cmp	al, 'F'
1903
	cmp	al, 'F'
1897
	jbe	.AF
1904
	jbe	.AF
1898
	cmp	al, 'a'
1905
	cmp	al, 'a'
1899
	jb	.no
1906
	jb	.no
1900
	cmp	al, 'f'
1907
	cmp	al, 'f'
1901
	jbe	.af
1908
	jbe	.af
1902
.no:
1909
.no:
1903
	stc
1910
	stc
1904
	ret
1911
	ret
1905
.09:
1912
.09:
1906
	sub	al, '0'
1913
	sub	al, '0'
1907
;	clc
1914
;	clc
1908
	ret
1915
	ret
1909
.AF:
1916
.AF:
1910
	sub	al, 'A'-10
1917
	sub	al, 'A'-10
1911
;	clc
1918
;	clc
1912
	ret
1919
	ret
1913
.af:
1920
.af:
1914
	sub	al, 'a'-10
1921
	sub	al, 'a'-10
1915
;	clc
1922
;	clc
1916
	ret
1923
	ret
1917
 
1924
 
1918
find_reg:
1925
find_reg:
1919
	mov	edi, reg_table
1926
	mov	edi, reg_table
1920
.findreg:
1927
.findreg:
1921
	movzx	ecx, byte [edi]
1928
	movzx	ecx, byte [edi]
1922
	stc
1929
	stc
1923
	jecxz	.regnotfound
1930
	jecxz	.regnotfound
1924
	inc	edi
1931
	inc	edi
1925
	push	esi edi ecx
1932
	push	esi edi ecx
1926
@@:
1933
@@:
1927
	lodsb
1934
	lodsb
1928
	or	al, 20h
1935
	or	al, 20h
1929
	scasb
1936
	scasb
1930
	loopz	@b
1937
	loopz	@b
1931
	pop	ecx edi esi
1938
	pop	ecx edi esi
1932
	lea	edi, [edi+ecx+1]
1939
	lea	edi, [edi+ecx+1]
1933
	jnz	.findreg
1940
	jnz	.findreg
1934
	movzx	edi, byte [edi-1]
1941
	movzx	edi, byte [edi-1]
1935
	add	esi, ecx
1942
	add	esi, ecx
1936
.regnotfound:
1943
.regnotfound:
1937
	ret
1944
	ret
1938
 
1945
 
1939
expr_get_token:
1946
expr_get_token:
1940
	lodsb
1947
	lodsb
1941
	cmp	al, 0
1948
	cmp	al, 0
1942
	jz	.end_token
1949
	jz	.end_token
1943
	cmp	al, ' '
1950
	cmp	al, ' '
1944
	jbe	expr_get_token
1951
	jbe	expr_get_token
1945
	cmp	al, '+'
1952
	cmp	al, '+'
1946
	jz	.add
1953
	jz	.add
1947
	cmp	al, '-'
1954
	cmp	al, '-'
1948
	jz	.sub
1955
	jz	.sub
1949
	cmp	al, '*'
1956
	cmp	al, '*'
1950
	jz	.mul
1957
	jz	.mul
1951
	cmp	al, '/'
1958
	cmp	al, '/'
1952
	jz	.div
1959
	jz	.div
1953
	cmp	al, '('
1960
	cmp	al, '('
1954
	jz	.lp
1961
	jz	.lp
1955
	cmp	al, ')'
1962
	cmp	al, ')'
1956
	jnz	.notsign
1963
	jnz	.notsign
1957
.rp:
1964
.rp:
1958
	mov	al, token_rp
1965
	mov	al, token_rp
1959
	ret
1966
	ret
1960
.div:
1967
.div:
1961
	mov	al, token_div
1968
	mov	al, token_div
1962
	ret
1969
	ret
1963
.end_token:
1970
.end_token:
1964
	mov	al, token_end
1971
	mov	al, token_end
1965
	ret
1972
	ret
1966
.add:
1973
.add:
1967
	mov	al, token_add
1974
	mov	al, token_add
1968
	ret
1975
	ret
1969
.sub:
1976
.sub:
1970
	mov	al, token_sub
1977
	mov	al, token_sub
1971
	ret
1978
	ret
1972
.mul:
1979
.mul:
1973
	mov	al, token_mul
1980
	mov	al, token_mul
1974
	ret
1981
	ret
1975
.lp:
1982
.lp:
1976
	mov	al, token_lp
1983
	mov	al, token_lp
1977
	ret
1984
	ret
1978
.notsign:
1985
.notsign:
1979
	dec	esi
1986
	dec	esi
1980
	call	find_reg
1987
	call	find_reg
1981
	jc	.regnotfound
1988
	jc	.regnotfound
1982
	mov	al, token_reg
1989
	mov	al, token_reg
1983
	ret
1990
	ret
1984
.regnotfound:
1991
.regnotfound:
1985
; test for hex number
1992
; test for hex number
1986
	xor	ecx, ecx
1993
	xor	ecx, ecx
1987
	xor	edi, edi
1994
	xor	edi, edi
1988
	xor	eax, eax
1995
	xor	eax, eax
1989
@@:
1996
@@:
1990
	lodsb
1997
	lodsb
1991
	call	is_hex_digit
1998
	call	is_hex_digit
1992
	jc	@f
1999
	jc	@f
1993
	shl	edi, 4
2000
	shl	edi, 4
1994
	or	edi, eax
2001
	or	edi, eax
1995
	inc	ecx
2002
	inc	ecx
1996
	jmp	@b
2003
	jmp	@b
1997
@@:
2004
@@:
1998
	dec	esi
2005
	dec	esi
1999
	jecxz	.err
2006
	jecxz	.err
2000
	cmp	ecx, 8
2007
	cmp	ecx, 8
2001
	ja	.err
2008
	ja	.err
2002
	mov	al, token_hex
2009
	mov	al, token_hex
2003
	ret
2010
	ret
2004
.err:
2011
.err:
2005
	mov	al, token_err
2012
	mov	al, token_err
2006
	mov	esi, aParseError
2013
	mov	esi, aParseError
2007
	ret
2014
	ret
2008
 
2015
 
2009
expr_read2:
2016
expr_read2:
2010
	cmp	al, token_hex
2017
	cmp	al, token_hex
2011
	jz	.hex
2018
	jz	.hex
2012
	cmp	al, token_reg
2019
	cmp	al, token_reg
2013
	jz	.reg
2020
	jz	.reg
2014
	cmp	al, token_lp
2021
	cmp	al, token_lp
2015
	jz	.lp
2022
	jz	.lp
2016
	mov	al, token_err
2023
	mov	al, token_err
2017
	mov	esi, aParseError
2024
	mov	esi, aParseError
2018
	ret
2025
	ret
2019
.hex:
2026
.hex:
2020
	mov	ebp, edi
2027
	mov	ebp, edi
2021
.ret:
2028
.ret:
2022
	jmp	expr_get_token
2029
	jmp	expr_get_token
2023
.reg:
2030
.reg:
2024
	cmp	edi, 24
2031
	cmp	edi, 24
2025
	jz	.eip
2032
	jz	.eip
2026
	sub	edi, 4
2033
	sub	edi, 4
2027
	jb	.8lo
2034
	jb	.8lo
2028
	sub	edi, 4
2035
	sub	edi, 4
2029
	jb	.8hi
2036
	jb	.8hi
2030
	sub	edi, 8
2037
	sub	edi, 8
2031
	jb	.16
2038
	jb	.16
2032
	mov	ebp, [_eax+edi*4]
2039
	mov	ebp, [_eax+edi*4]
2033
	jmp	.ret
2040
	jmp	.ret
2034
.16:
2041
.16:
2035
	movzx	ebp, word [_eax+(edi+8)*4]
2042
	movzx	ebp, word [_eax+(edi+8)*4]
2036
	jmp	.ret
2043
	jmp	.ret
2037
.8lo:
2044
.8lo:
2038
	movzx	ebp, byte [_eax+(edi+4)*4]
2045
	movzx	ebp, byte [_eax+(edi+4)*4]
2039
	jmp	.ret
2046
	jmp	.ret
2040
.8hi:
2047
.8hi:
2041
	movzx	ebp, byte [_eax+(edi+4)*4+1]
2048
	movzx	ebp, byte [_eax+(edi+4)*4+1]
2042
	jmp	.ret
2049
	jmp	.ret
2043
.eip:
2050
.eip:
2044
	mov	ebp, [_eip]
2051
	mov	ebp, [_eip]
2045
	jmp	.ret
2052
	jmp	.ret
2046
.lp:
2053
.lp:
2047
	call	expr_get_token
2054
	call	expr_get_token
2048
	call	expr_read0
2055
	call	expr_read0
2049
	cmp	al, token_err
2056
	cmp	al, token_err
2050
	jz	@f
2057
	jz	@f
2051
	cmp	al, token_rp
2058
	cmp	al, token_rp
2052
	jz	expr_get_token
2059
	jz	expr_get_token
2053
	mov	al, token_err
2060
	mov	al, token_err
2054
	mov	esi, aParseError
2061
	mov	esi, aParseError
2055
@@:	ret
2062
@@:	ret
2056
 
2063
 
2057
expr_read1:
2064
expr_read1:
2058
	call	expr_read2
2065
	call	expr_read2
2059
.1:
2066
.1:
2060
	cmp	al, token_mul
2067
	cmp	al, token_mul
2061
	jz	.mul
2068
	jz	.mul
2062
	cmp	al, token_div
2069
	cmp	al, token_div
2063
	jz	.div
2070
	jz	.div
2064
	ret
2071
	ret
2065
.mul:
2072
.mul:
2066
	push	ebp
2073
	push	ebp
2067
	call	expr_get_token
2074
	call	expr_get_token
2068
	call	expr_read2
2075
	call	expr_read2
2069
	pop	edx
2076
	pop	edx
2070
; ebp := edx*ebp
2077
; ebp := edx*ebp
2071
	imul	ebp, edx
2078
	imul	ebp, edx
2072
	jmp	.1
2079
	jmp	.1
2073
.div:
2080
.div:
2074
	push	ebp
2081
	push	ebp
2075
	call	expr_get_token
2082
	call	expr_get_token
2076
	call	expr_read2
2083
	call	expr_read2
2077
	pop	edx
2084
	pop	edx
2078
; ebp := edx/ebp
2085
; ebp := edx/ebp
2079
	test	ebp, ebp
2086
	test	ebp, ebp
2080
	jz	.div0
2087
	jz	.div0
2081
	push	eax
2088
	push	eax
2082
	xor	eax, eax
2089
	xor	eax, eax
2083
	xchg	eax, edx
2090
	xchg	eax, edx
2084
	div	ebp
2091
	div	ebp
2085
	xchg	eax, ebp
2092
	xchg	eax, ebp
2086
	pop	eax
2093
	pop	eax
2087
	jmp	.1
2094
	jmp	.1
2088
.div0:
2095
.div0:
2089
	mov	al, token_err
2096
	mov	al, token_err
2090
	mov	esi, aDivByZero
2097
	mov	esi, aDivByZero
2091
	ret
2098
	ret
2092
 
2099
 
2093
expr_read0:
2100
expr_read0:
2094
	xor	ebp, ebp
2101
	xor	ebp, ebp
2095
	cmp	al, token_add
2102
	cmp	al, token_add
2096
	jz	.add
2103
	jz	.add
2097
	cmp	al, token_sub
2104
	cmp	al, token_sub
2098
	jz	.sub
2105
	jz	.sub
2099
	call	expr_read1
2106
	call	expr_read1
2100
.1:
2107
.1:
2101
	cmp	al, token_add
2108
	cmp	al, token_add
2102
	jz	.add
2109
	jz	.add
2103
	cmp	al, token_sub
2110
	cmp	al, token_sub
2104
	jz	.sub
2111
	jz	.sub
2105
	ret
2112
	ret
2106
.add:
2113
.add:
2107
	push	ebp
2114
	push	ebp
2108
	call	expr_get_token
2115
	call	expr_get_token
2109
	call	expr_read1
2116
	call	expr_read1
2110
	pop	edx
2117
	pop	edx
2111
; ebp := edx+ebp
2118
; ebp := edx+ebp
2112
	add	ebp, edx
2119
	add	ebp, edx
2113
	jmp	.1
2120
	jmp	.1
2114
.sub:
2121
.sub:
2115
	push	ebp
2122
	push	ebp
2116
	call	expr_get_token
2123
	call	expr_get_token
2117
	call	expr_read1
2124
	call	expr_read1
2118
	pop	edx
2125
	pop	edx
2119
; ebp := edx-ebp
2126
; ebp := edx-ebp
2120
	xchg	edx, ebp
2127
	xchg	edx, ebp
2121
	sub	ebp, edx
2128
	sub	ebp, edx
2122
	jmp	.1
2129
	jmp	.1
2123
 
2130
 
2124
calc_expression:
2131
calc_expression:
2125
; in: esi->expression
2132
; in: esi->expression
2126
; out: CF=1 if error
2133
; out: CF=1 if error
2127
;      CF=0 and ebp=value if ok
2134
;      CF=0 and ebp=value if ok
2128
	call	expr_get_token
2135
	call	expr_get_token
2129
	call	expr_read0
2136
	call	expr_read0
2130
	cmp	al, token_end
2137
	cmp	al, token_end
2131
	jz	.end
2138
	jz	.end
2132
	cmp	al, token_err
2139
	cmp	al, token_err
2133
	jz	@f
2140
	jz	@f
2134
	mov	esi, aParseError
2141
	mov	esi, aParseError
2135
@@:
2142
@@:
2136
	call	put_message
2143
	call	put_message
2137
	stc
2144
	stc
2138
	ret
2145
	ret
2139
.end:
2146
.end:
2140
	clc
2147
	clc
2141
	ret
2148
	ret
2142
 
2149
 
2143
OnCalc:
2150
OnCalc:
2144
	mov	esi, [curarg]
2151
	mov	esi, [curarg]
2145
	call	calc_expression
2152
	call	calc_expression
2146
	jc	.ret
2153
	jc	.ret
2147
	push	ebp
2154
	push	ebp
2148
	mov	esi, calc_string
2155
	mov	esi, calc_string
2149
	call	put_message_nodraw
2156
	call	put_message_nodraw
2150
	jmp	draw_messages
2157
	jmp	draw_messages
2151
.ret:
2158
.ret:
2152
	ret
2159
	ret
2153
 
2160
 
2154
OnDump:
2161
OnDump:
2155
	mov	esi, [curarg]
2162
	mov	esi, [curarg]
2156
	cmp	byte [esi], 0
2163
	cmp	byte [esi], 0
2157
	jnz	.param
2164
	jnz	.param
2158
	add	[dumppos], dump_height*10h
2165
	add	[dumppos], dump_height*10h
2159
	jmp	.doit
2166
	jmp	.doit
2160
.param:
2167
.param:
2161
	call	calc_expression
2168
	call	calc_expression
2162
	jc	.ret
2169
	jc	.ret
2163
	mov	[dumppos], ebp
2170
	mov	[dumppos], ebp
2164
.doit:
2171
.doit:
2165
	call	get_dump
2172
	call	get_dump
2166
	call	redraw_dump
2173
	call	redraw_dump
2167
.ret:
2174
.ret:
2168
	ret
2175
	ret
2169
 
2176
 
2170
OnUnassemble:
2177
OnUnassemble:
2171
	mov	esi, [curarg]
2178
	mov	esi, [curarg]
2172
	cmp	byte [esi], 0
2179
	cmp	byte [esi], 0
2173
	jnz	.param
2180
	jnz	.param
2174
	mov	eax, [disasm_start_pos]
2181
	mov	eax, [disasm_start_pos]
2175
	mov	ecx, disasm_height
2182
	mov	ecx, disasm_height
2176
	mov	[disasm_cur_pos], eax
2183
	mov	[disasm_cur_pos], eax
2177
@@:
2184
@@:
2178
	push	ecx
2185
	push	ecx
2179
	call	disasm_instr
2186
	call	disasm_instr
2180
	pop	ecx
2187
	pop	ecx
2181
	jc	.err
2188
	jc	.err
2182
	loop	@b
2189
	loop	@b
2183
	mov	eax, [disasm_cur_pos]
2190
	mov	eax, [disasm_cur_pos]
2184
	jmp	.doit
2191
	jmp	.doit
2185
.param:
2192
.param:
2186
	call	calc_expression
2193
	call	calc_expression
2187
	jc	.ret
2194
	jc	.ret
2188
	mov	eax, ebp
2195
	mov	eax, ebp
2189
.doit:
2196
.doit:
2190
	push	eax
2197
	push	eax
2191
	push	[disasm_start_pos]
2198
	push	[disasm_start_pos]
2192
	mov	[disasm_start_pos], eax
2199
	mov	[disasm_start_pos], eax
2193
	call	update_disasm
2200
	call	update_disasm
2194
	pop	[disasm_start_pos]
2201
	pop	[disasm_start_pos]
2195
	pop	eax
2202
	pop	eax
2196
	cmp	[disasm_cur_str], 0
2203
	cmp	[disasm_cur_str], 0
2197
	jz	@f
2204
	jz	@f
2198
	mov	[disasm_start_pos], eax
2205
	mov	[disasm_start_pos], eax
2199
.ret:
2206
.ret:
2200
	ret
2207
	ret
2201
@@:
2208
@@:
2202
	call	update_disasm
2209
	call	update_disasm
2203
.err:
2210
.err:
2204
	mov	esi, aInvAddr
2211
	mov	esi, aInvAddr
2205
	jmp	put_message
2212
	jmp	put_message
2206
 
2213
 
2207
OnReg:
2214
OnReg:
2208
	mov	esi, [curarg]
2215
	mov	esi, [curarg]
2209
	call	skip_spaces
2216
	call	skip_spaces
2210
	call	find_reg
2217
	call	find_reg
2211
	jnc	@f
2218
	jnc	@f
2212
.err:
2219
.err:
2213
	mov	esi, RSyntax
2220
	mov	esi, RSyntax
2214
	jmp	put_message
2221
	jmp	put_message
2215
@@:
2222
@@:
2216
	call	skip_spaces
2223
	call	skip_spaces
2217
	test	al, al
2224
	test	al, al
2218
	jz	.err
2225
	jz	.err
2219
	cmp	al, '='
2226
	cmp	al, '='
2220
	jnz	@f
2227
	jnz	@f
2221
	inc	esi
2228
	inc	esi
2222
	call	skip_spaces
2229
	call	skip_spaces
2223
	test	al, al
2230
	test	al, al
2224
	jz	.err
2231
	jz	.err
2225
@@:
2232
@@:
2226
	push	edi
2233
	push	edi
2227
	call	calc_expression
2234
	call	calc_expression
2228
	pop	edi
2235
	pop	edi
2229
	jc	.ret
2236
	jc	.ret
2230
; now edi=register id, ebp=value
2237
; now edi=register id, ebp=value
2231
	cmp	[bSuspended], 0
2238
	cmp	[bSuspended], 0
2232
	mov	esi, aRunningErr
2239
	mov	esi, aRunningErr
2233
	jz	put_message
2240
	jz	put_message
2234
	xchg	eax, ebp
2241
	xchg	eax, ebp
2235
	cmp	edi, 24
2242
	cmp	edi, 24
2236
	jz	.eip
2243
	jz	.eip
2237
	sub	edi, 4
2244
	sub	edi, 4
2238
	jb	.8lo
2245
	jb	.8lo
2239
	sub	edi, 4
2246
	sub	edi, 4
2240
	jb	.8hi
2247
	jb	.8hi
2241
	sub	edi, 8
2248
	sub	edi, 8
2242
	jb	.16
2249
	jb	.16
2243
	mov	[_eax+edi*4], eax
2250
	mov	[_eax+edi*4], eax
2244
	jmp	.ret
2251
	jmp	.ret
2245
.16:
2252
.16:
2246
	mov	word [_eax+(edi+8)*4], ax
2253
	mov	word [_eax+(edi+8)*4], ax
2247
	jmp	.ret
2254
	jmp	.ret
2248
.8lo:
2255
.8lo:
2249
	mov	byte [_eax+(edi+4)*4], al
2256
	mov	byte [_eax+(edi+4)*4], al
2250
	jmp	.ret
2257
	jmp	.ret
2251
.8hi:
2258
.8hi:
2252
	mov	byte [_eax+(edi+4)*4+1], al
2259
	mov	byte [_eax+(edi+4)*4+1], al
2253
	jmp	.ret
2260
	jmp	.ret
2254
.eip:
2261
.eip:
2255
	mov	[_eip], eax
2262
	mov	[_eip], eax
2256
	call	update_disasm_eip
2263
	call	update_disasm_eip
2257
.ret:
2264
.ret:
2258
	call	set_context
2265
	call	set_context
2259
	jmp	redraw_registers
2266
	jmp	redraw_registers
2260
 
2267
 
2261
; Breakpoints manipulation
2268
; Breakpoints manipulation
2262
OnBp:
2269
OnBp:
2263
	mov	esi, [curarg]
2270
	mov	esi, [curarg]
2264
	call	calc_expression
2271
	call	calc_expression
2265
	jc	.ret
2272
	jc	.ret
2266
	xchg	eax, ebp
2273
	xchg	eax, ebp
2267
	push	eax
2274
	push	eax
2268
	call	find_breakpoint
2275
	call	find_breakpoint
2269
	inc	eax
2276
	inc	eax
2270
	pop	eax
2277
	pop	eax
2271
	jz	.notfound
2278
	jz	.notfound
2272
	mov	esi, aDuplicateBreakpoint
2279
	mov	esi, aDuplicateBreakpoint
2273
	jmp	.sayerr
2280
	jmp	.sayerr
2274
.notfound:
2281
.notfound:
2275
	mov	bl, 1
2282
	mov	bl, 1
2276
	call	add_breakpoint
2283
	call	add_breakpoint
2277
	jnc	.ret
2284
	jnc	.ret
2278
	mov	esi, aBreakpointLimitExceeded
2285
	mov	esi, aBreakpointLimitExceeded
2279
.sayerr:
2286
.sayerr:
2280
	call	put_message
2287
	call	put_message
2281
.ret:
2288
.ret:
2282
	jmp	redraw_disasm
2289
	jmp	redraw_disasm
2283
 
2290
 
2284
OnBpmb:
2291
OnBpmb:
2285
	mov	dh, 0011b
2292
	mov	dh, 0011b
2286
	jmp	DoBpm
2293
	jmp	DoBpm
2287
OnBpmw:
2294
OnBpmw:
2288
	mov	dh, 0111b
2295
	mov	dh, 0111b
2289
	jmp	DoBpm
2296
	jmp	DoBpm
2290
OnBpmd:
2297
OnBpmd:
2291
	mov	dh, 1111b
2298
	mov	dh, 1111b
2292
DoBpm:
2299
DoBpm:
2293
	mov	esi, [curarg]
2300
	mov	esi, [curarg]
2294
	cmp	byte [esi], 'w'
2301
	cmp	byte [esi], 'w'
2295
	jnz	@f
2302
	jnz	@f
2296
	and	dh, not 2
2303
	and	dh, not 2
2297
	inc	esi
2304
	inc	esi
2298
@@:
2305
@@:
2299
	push	edx
2306
	push	edx
2300
	call	calc_expression
2307
	call	calc_expression
2301
	pop	edx
2308
	pop	edx
2302
	jnc	@f
2309
	jnc	@f
2303
	ret
2310
	ret
2304
@@:
2311
@@:
2305
; ebp=expression, dh=flags
2312
; ebp=expression, dh=flags
2306
	movzx	eax, dh
2313
	movzx	eax, dh
2307
	shr	eax, 2
2314
	shr	eax, 2
2308
	test	ebp, eax
2315
	test	ebp, eax
2309
	jz	@f
2316
	jz	@f
2310
	mov	esi, aUnaligned
2317
	mov	esi, aUnaligned
2311
	jmp	put_message
2318
	jmp	put_message
2312
@@:
2319
@@:
2313
	mov	eax, ebp
2320
	mov	eax, ebp
2314
	mov	bl, 0Bh
2321
	mov	bl, 0Bh
2315
	call	add_breakpoint
2322
	call	add_breakpoint
2316
	jnc	@f
2323
	jnc	@f
2317
	mov	esi, aBreakpointLimitExceeded
2324
	mov	esi, aBreakpointLimitExceeded
2318
	jmp	put_message
2325
	jmp	put_message
2319
@@:
2326
@@:
2320
; now find index
2327
; now find index
2321
	push	eax
2328
	push	eax
2322
	xor	ecx, ecx
2329
	xor	ecx, ecx
2323
.l1:
2330
.l1:
2324
	cmp	[drx_break+ecx*4], 0
2331
	cmp	[drx_break+ecx*4], 0
2325
	jnz	.l2
2332
	jnz	.l2
2326
	push	69
2333
	push	69
2327
	pop	eax
2334
	pop	eax
2328
	push	ecx
2335
	push	ecx
2329
	mov	dl, cl
2336
	mov	dl, cl
2330
	mov	ecx, [debuggee_pid]
2337
	mov	ecx, [debuggee_pid]
2331
	mov	esi, ebp
2338
	mov	esi, ebp
2332
	push	9
2339
	push	9
2333
	pop	ebx
2340
	pop	ebx
2334
	int	40h
2341
	int	40h
2335
	test	eax, eax
2342
	test	eax, eax
2336
	jz	.ok
2343
	jz	.ok
2337
	pop	ecx
2344
	pop	ecx
2338
.l2:
2345
.l2:
2339
	inc	ecx
2346
	inc	ecx
2340
	cmp	ecx, 4
2347
	cmp	ecx, 4
2341
	jb	.l1
2348
	jb	.l1
2342
	pop	eax
2349
	pop	eax
2343
	call	clear_breakpoint
2350
	call	clear_breakpoint
2344
	mov	esi, aBreakpointLimitExceeded
2351
	mov	esi, aBreakpointLimitExceeded
2345
	jmp	put_message
2352
	jmp	put_message
2346
.ok:
2353
.ok:
2347
	pop	ecx
2354
	pop	ecx
2348
	pop	eax
2355
	pop	eax
2349
	and	byte [edi], not 2	; breakpoint is enabled
2356
	and	byte [edi], not 2	; breakpoint is enabled
2350
	shl	dl, 6
2357
	shl	dl, 6
2351
	or	dl, dh
2358
	or	dl, dh
2352
	mov	byte [edi+1], dl
2359
	mov	byte [edi+1], dl
2353
	inc	eax
2360
	inc	eax
2354
	mov	[drx_break+ecx*4], eax
2361
	mov	[drx_break+ecx*4], eax
2355
	ret
2362
	ret
2356
 
2363
 
2357
OnBc:
2364
OnBc:
2358
	mov	esi, [curarg]
2365
	mov	esi, [curarg]
2359
@@:	call	get_hex_number
2366
@@:	call	get_hex_number
2360
	jc	OnBp.ret
2367
	jc	OnBp.ret
2361
	call	clear_breakpoint
2368
	call	clear_breakpoint
2362
	jmp	@b
2369
	jmp	@b
2363
 
2370
 
2364
OnBd:
2371
OnBd:
2365
	mov	esi, [curarg]
2372
	mov	esi, [curarg]
2366
@@:	call	get_hex_number
2373
@@:	call	get_hex_number
2367
	jc	OnBp.ret
2374
	jc	OnBp.ret
2368
	call	disable_breakpoint
2375
	call	disable_breakpoint
2369
	jmp	@b
2376
	jmp	@b
2370
 
2377
 
2371
OnBe:
2378
OnBe:
2372
	mov	esi, [curarg]
2379
	mov	esi, [curarg]
2373
@@:	call	get_hex_number
2380
@@:	call	get_hex_number
2374
	jc	OnBp.ret
2381
	jc	OnBp.ret
2375
	push	eax
2382
	push	eax
2376
	call	find_enabled_breakpoint
2383
	call	find_enabled_breakpoint
2377
	pop	eax
2384
	pop	eax
2378
	jz	.err
2385
	jz	.err
2379
	call	enable_breakpoint
2386
	call	enable_breakpoint
2380
	jmp	@b
2387
	jmp	@b
2381
.err:
2388
.err:
2382
	mov	esi, OnBeErrMsg
2389
	mov	esi, OnBeErrMsg
2383
	jmp	put_message
2390
	jmp	put_message
2384
 
2391
 
2385
get_hex_number:
2392
get_hex_number:
2386
	call	skip_spaces
2393
	call	skip_spaces
2387
	xor	ecx, ecx
2394
	xor	ecx, ecx
2388
	xor	edx, edx
2395
	xor	edx, edx
2389
@@:
2396
@@:
2390
	lodsb
2397
	lodsb
2391
	call	is_hex_digit
2398
	call	is_hex_digit
2392
	jc	.ret
2399
	jc	.ret
2393
	shl	edx, 4
2400
	shl	edx, 4
2394
	or	dl, al
2401
	or	dl, al
2395
	inc	ecx
2402
	inc	ecx
2396
	jmp	@b
2403
	jmp	@b
2397
.ret:
2404
.ret:
2398
	dec	esi
2405
	dec	esi
2399
	cmp	ecx, 1
2406
	cmp	ecx, 1
2400
	xchg	eax, edx
2407
	xchg	eax, edx
2401
	ret
2408
	ret
2402
 
2409
 
2403
OnBl:
2410
OnBl:
2404
	mov	esi, [curarg]
2411
	mov	esi, [curarg]
2405
	cmp	byte [esi], 0
2412
	cmp	byte [esi], 0
2406
	jz	.listall
2413
	jz	.listall
2407
	call	get_hex_number
2414
	call	get_hex_number
2408
	jc	.ret
2415
	jc	.ret
2409
	cmp	eax, breakpoints_n
2416
	cmp	eax, breakpoints_n
2410
	jae	.err
2417
	jae	.err
2411
	push	eax
2418
	push	eax
2412
	add	eax, eax
2419
	add	eax, eax
2413
	lea	edi, [breakpoints + eax + eax*2]
2420
	lea	edi, [breakpoints + eax + eax*2]
2414
	pop	eax
2421
	pop	eax
2415
	test	byte [edi+4], 1
2422
	test	byte [edi+4], 1
2416
	jz	.err
2423
	jz	.err
2417
	call	show_break_info
2424
	call	show_break_info
2418
.ret:
2425
.ret:
2419
	ret
2426
	ret
2420
.err:
2427
.err:
2421
	mov	esi, aInvalidBreak
2428
	mov	esi, aInvalidBreak
2422
	jmp	put_message
2429
	jmp	put_message
2423
.listall:
2430
.listall:
2424
	mov	edi, breakpoints
2431
	mov	edi, breakpoints
2425
	xor	eax, eax
2432
	xor	eax, eax
2426
@@:
2433
@@:
2427
	test	byte [edi+4], 1
2434
	test	byte [edi+4], 1
2428
	jz	.cont
2435
	jz	.cont
2429
	push	edi eax
2436
	push	edi eax
2430
	call	show_break_info
2437
	call	show_break_info
2431
	pop	eax edi
2438
	pop	eax edi
2432
.cont:
2439
.cont:
2433
	add	edi, 6
2440
	add	edi, 6
2434
	inc	eax
2441
	inc	eax
2435
	cmp	eax, breakpoints_n
2442
	cmp	eax, breakpoints_n
2436
	jb	@b
2443
	jb	@b
2437
	ret
2444
	ret
2438
 
2445
 
2439
show_break_info:
2446
show_break_info:
2440
	push	edi
2447
	push	edi
2441
	test	byte [edi+4], 8
2448
	test	byte [edi+4], 8
2442
	jnz	.dr
2449
	jnz	.dr
2443
	push	dword [edi]
2450
	push	dword [edi]
2444
	push	eax
2451
	push	eax
2445
	mov	esi, aBreakNum
2452
	mov	esi, aBreakNum
2446
	call	put_message_nodraw
2453
	call	put_message_nodraw
2447
	jmp	.cmn
2454
	jmp	.cmn
2448
.dr:
2455
.dr:
2449
	push	eax
2456
	push	eax
2450
	mov	esi, aMemBreak1
2457
	mov	esi, aMemBreak1
2451
	call	put_message_nodraw
2458
	call	put_message_nodraw
2452
	pop	edi
2459
	pop	edi
2453
	push	edi
2460
	push	edi
2454
	mov	esi, aMemBreak2
2461
	mov	esi, aMemBreak2
2455
	test	byte [edi+5], 2
2462
	test	byte [edi+5], 2
2456
	jz	@f
2463
	jz	@f
2457
	mov	esi, aMemBreak3
2464
	mov	esi, aMemBreak3
2458
@@:
2465
@@:
2459
	call	put_message_nodraw
2466
	call	put_message_nodraw
2460
	pop	edi
2467
	pop	edi
2461
	push	edi
2468
	push	edi
2462
	mov	esi, aMemBreak6
2469
	mov	esi, aMemBreak6
2463
	test	byte [edi+5], 8
2470
	test	byte [edi+5], 8
2464
	jnz	@f
2471
	jnz	@f
2465
	mov	esi, aMemBreak5
2472
	mov	esi, aMemBreak5
2466
	test	byte [edi+5], 4
2473
	test	byte [edi+5], 4
2467
	jnz	@f
2474
	jnz	@f
2468
	mov	esi, aMemBreak4
2475
	mov	esi, aMemBreak4
2469
@@:
2476
@@:
2470
	call	put_message_nodraw
2477
	call	put_message_nodraw
2471
	pop	edi
2478
	pop	edi
2472
	push	edi
2479
	push	edi
2473
	push	dword [edi]
2480
	push	dword [edi]
2474
	mov	esi, aMemBreak7
2481
	mov	esi, aMemBreak7
2475
	call	put_message_nodraw
2482
	call	put_message_nodraw
2476
.cmn:
2483
.cmn:
2477
	pop	edi
2484
	pop	edi
2478
	test	byte [edi+4], 2
2485
	test	byte [edi+4], 2
2479
	jz	@f
2486
	jz	@f
2480
	push	edi
2487
	push	edi
2481
	mov	esi, aDisabled
2488
	mov	esi, aDisabled
2482
	call	put_message_nodraw
2489
	call	put_message_nodraw
2483
	pop	edi
2490
	pop	edi
2484
@@:
2491
@@:
2485
	test	byte [edi+4], 4
2492
	test	byte [edi+4], 4
2486
	jz	@f
2493
	jz	@f
2487
	mov	esi, aOneShot
2494
	mov	esi, aOneShot
2488
	call	put_message_nodraw
2495
	call	put_message_nodraw
2489
@@:
2496
@@:
2490
	mov	esi, newline
2497
	mov	esi, newline
2491
	jmp	put_message
2498
	jmp	put_message
2492
 
2499
 
2493
add_breakpoint:
2500
add_breakpoint:
2494
; in: eax=address, bl=flags
2501
; in: eax=address, bl=flags
2495
; out: CF=1 => error, CF=0 => eax=breakpoint number
2502
; out: CF=1 => error, CF=0 => eax=breakpoint number
2496
	xor	ecx, ecx
2503
	xor	ecx, ecx
2497
	mov	edi, breakpoints
2504
	mov	edi, breakpoints
2498
@@:
2505
@@:
2499
	test	byte [edi+4], 1
2506
	test	byte [edi+4], 1
2500
	jz	.found
2507
	jz	.found
2501
	add	edi, 6
2508
	add	edi, 6
2502
	inc	ecx
2509
	inc	ecx
2503
	cmp	ecx, breakpoints_n
2510
	cmp	ecx, breakpoints_n
2504
	jb	@b
2511
	jb	@b
2505
	stc
2512
	stc
2506
	ret
2513
	ret
2507
.found:
2514
.found:
2508
	stosd
2515
	stosd
2509
	xchg	eax, ecx
2516
	xchg	eax, ecx
2510
	mov	[edi], bl
2517
	mov	[edi], bl
2511
	test	bl, 2
2518
	test	bl, 2
2512
	jnz	@f
2519
	jnz	@f
2513
	or	byte [edi], 2
2520
	or	byte [edi], 2
2514
	push	eax
2521
	push	eax
2515
	call	enable_breakpoint
2522
	call	enable_breakpoint
2516
	pop	eax
2523
	pop	eax
2517
@@:
2524
@@:
2518
	clc
2525
	clc
2519
	ret
2526
	ret
2520
 
2527
 
2521
clear_breakpoint:
2528
clear_breakpoint:
2522
	cmp	eax, breakpoints_n
2529
	cmp	eax, breakpoints_n
2523
	jae	.ret
2530
	jae	.ret
2524
	mov	ecx, 4
2531
	mov	ecx, 4
2525
	inc	eax
2532
	inc	eax
2526
.1:
2533
.1:
2527
	cmp	[drx_break-4+ecx*4], eax
2534
	cmp	[drx_break-4+ecx*4], eax
2528
	jnz	@f
2535
	jnz	@f
2529
	and	[drx_break-4+ecx*4], 0
2536
	and	[drx_break-4+ecx*4], 0
2530
@@:	loop	.1
2537
@@:	loop	.1
2531
	dec	eax
2538
	dec	eax
2532
	push	eax
2539
	push	eax
2533
	add	eax, eax
2540
	add	eax, eax
2534
	lea	edi, [breakpoints + eax + eax*2 + 4]
2541
	lea	edi, [breakpoints + eax + eax*2 + 4]
2535
	test	byte [edi], 1
2542
	test	byte [edi], 1
2536
	pop	eax
2543
	pop	eax
2537
	jz	.ret
2544
	jz	.ret
2538
	push	edi
2545
	push	edi
2539
	call	disable_breakpoint
2546
	call	disable_breakpoint
2540
	pop	edi
2547
	pop	edi
2541
	mov	byte [edi], 0
2548
	mov	byte [edi], 0
2542
.ret:
2549
.ret:
2543
	ret
2550
	ret
2544
 
2551
 
2545
disable_breakpoint:
2552
disable_breakpoint:
2546
	cmp	eax, breakpoints_n
2553
	cmp	eax, breakpoints_n
2547
	jae	.ret
2554
	jae	.ret
2548
	add	eax, eax
2555
	add	eax, eax
2549
	lea	edi, [breakpoints + eax + eax*2 + 5]
2556
	lea	edi, [breakpoints + eax + eax*2 + 5]
2550
	test	byte [edi-1], 1
2557
	test	byte [edi-1], 1
2551
	jz	.ret
2558
	jz	.ret
2552
	test	byte [edi-1], 2
2559
	test	byte [edi-1], 2
2553
	jnz	.ret
2560
	jnz	.ret
2554
	or	byte [edi-1], 2
2561
	or	byte [edi-1], 2
2555
	test	byte [edi-1], 8
2562
	test	byte [edi-1], 8
2556
	jnz	.dr
2563
	jnz	.dr
2557
	push	esi
2564
	push	esi
2558
	push	7
2565
	push	7
2559
	pop	ebx
2566
	pop	ebx
2560
	push	69
2567
	push	69
2561
	pop	eax
2568
	pop	eax
2562
	mov	ecx, [debuggee_pid]
2569
	mov	ecx, [debuggee_pid]
2563
	xor	edx, edx
2570
	xor	edx, edx
2564
	inc	edx
2571
	inc	edx
2565
	mov	esi, [edi-5]
2572
	mov	esi, [edi-5]
2566
	int	40h
2573
	int	40h
2567
	pop	esi
2574
	pop	esi
2568
.ret:
2575
.ret:
2569
	ret
2576
	ret
2570
.dr:
2577
.dr:
2571
	mov	dl, [edi]
2578
	mov	dl, [edi]
2572
	shr	dl, 6
2579
	shr	dl, 6
2573
	mov	dh, 80h
2580
	mov	dh, 80h
2574
	push	69
2581
	push	69
2575
	pop	eax
2582
	pop	eax
2576
	push	9
2583
	push	9
2577
	pop	ebx
2584
	pop	ebx
2578
	mov	ecx, [debuggee_pid]
2585
	mov	ecx, [debuggee_pid]
2579
	int	40h
2586
	int	40h
2580
	ret
2587
	ret
2581
 
2588
 
2582
enable_breakpoint:
2589
enable_breakpoint:
2583
	push	esi
2590
	push	esi
2584
	cmp	eax, breakpoints_n
2591
	cmp	eax, breakpoints_n
2585
	jae	.ret
2592
	jae	.ret
2586
	add	eax, eax
2593
	add	eax, eax
2587
	lea	edi, [breakpoints + eax + eax*2 + 5]
2594
	lea	edi, [breakpoints + eax + eax*2 + 5]
2588
	test	byte [edi-1], 1
2595
	test	byte [edi-1], 1
2589
	jz	.ret
2596
	jz	.ret
2590
	test	byte [edi-1], 2
2597
	test	byte [edi-1], 2
2591
	jz	.ret
2598
	jz	.ret
2592
	and	byte [edi-1], not 2
2599
	and	byte [edi-1], not 2
2593
	test	byte [edi-1], 8
2600
	test	byte [edi-1], 8
2594
	jnz	.dr
2601
	jnz	.dr
2595
	push	6
2602
	push	6
2596
	pop	ebx
2603
	pop	ebx
2597
	push	69
2604
	push	69
2598
	pop	eax
2605
	pop	eax
2599
	mov	esi, [edi-5]
2606
	mov	esi, [edi-5]
2600
	mov	ecx, [debuggee_pid]
2607
	mov	ecx, [debuggee_pid]
2601
	xor	edx, edx
2608
	xor	edx, edx
2602
	inc	edx
2609
	inc	edx
2603
	int	40h
2610
	int	40h
2604
	dec	eax
2611
	dec	eax
2605
	jnz	.err
2612
	jnz	.err
2606
	mov	al, 69
2613
	mov	al, 69
2607
	push	0xCC
2614
	push	0xCC
2608
	mov	edi, esp
2615
	mov	edi, esp
2609
	inc	ebx
2616
	inc	ebx
2610
	int	40h
2617
	int	40h
2611
	pop	eax
2618
	pop	eax
2612
.ret:
2619
.ret:
2613
	pop	esi
2620
	pop	esi
2614
	ret
2621
	ret
2615
.err:
2622
.err:
2616
	or	byte [edi-1], 2
2623
	or	byte [edi-1], 2
2617
	mov	esi, aBreakErr
2624
	mov	esi, aBreakErr
2618
	call	put_message
2625
	call	put_message
2619
	pop	esi
2626
	pop	esi
2620
	ret
2627
	ret
2621
.dr:
2628
.dr:
2622
	push	9
2629
	push	9
2623
	pop	ebx
2630
	pop	ebx
2624
	push	69
2631
	push	69
2625
	pop	eax
2632
	pop	eax
2626
	mov	esi, [edi-5]
2633
	mov	esi, [edi-5]
2627
	mov	ecx, [debuggee_pid]
2634
	mov	ecx, [debuggee_pid]
2628
	mov	dl, [edi]
2635
	mov	dl, [edi]
2629
	shr	dl, 6
2636
	shr	dl, 6
2630
	mov	dh, [edi]
2637
	mov	dh, [edi]
2631
	and	dh, 0xF
2638
	and	dh, 0xF
2632
	int	40h
2639
	int	40h
2633
	test	eax, eax
2640
	test	eax, eax
2634
	jnz	.err
2641
	jnz	.err
2635
	pop	esi
2642
	pop	esi
2636
	ret
2643
	ret
2637
 
2644
 
2638
find_breakpoint:
2645
find_breakpoint:
2639
	xor	ecx, ecx
2646
	xor	ecx, ecx
2640
	xchg	eax, ecx
2647
	xchg	eax, ecx
2641
	mov	edi, breakpoints
2648
	mov	edi, breakpoints
2642
@@:
2649
@@:
2643
	test	byte [edi+4], 1
2650
	test	byte [edi+4], 1
2644
	jz	.cont
2651
	jz	.cont
2645
	test	byte [edi+4], 8
2652
	test	byte [edi+4], 8
2646
	jnz	.cont
2653
	jnz	.cont
2647
	cmp	[edi], ecx
2654
	cmp	[edi], ecx
2648
	jz	.found
2655
	jz	.found
2649
.cont:
2656
.cont:
2650
	add	edi, 6
2657
	add	edi, 6
2651
	inc	eax
2658
	inc	eax
2652
	cmp	eax, breakpoints_n
2659
	cmp	eax, breakpoints_n
2653
	jb	@b
2660
	jb	@b
2654
	or	eax, -1
2661
	or	eax, -1
2655
.found:
2662
.found:
2656
	ret
2663
	ret
2657
 
2664
 
2658
find_enabled_breakpoint:
2665
find_enabled_breakpoint:
2659
	xor	ecx, ecx
2666
	xor	ecx, ecx
2660
	xchg	eax, ecx
2667
	xchg	eax, ecx
2661
	mov	edi, breakpoints
2668
	mov	edi, breakpoints
2662
@@:
2669
@@:
2663
	test	byte [edi+4], 1
2670
	test	byte [edi+4], 1
2664
	jz	.cont
2671
	jz	.cont
2665
	test	byte [edi+4], 2 or 8
2672
	test	byte [edi+4], 2 or 8
2666
	jnz	.cont
2673
	jnz	.cont
2667
	cmp	[edi], ecx
2674
	cmp	[edi], ecx
2668
	jz	.found
2675
	jz	.found
2669
.cont:
2676
.cont:
2670
	add	edi, 6
2677
	add	edi, 6
2671
	inc	eax
2678
	inc	eax
2672
	cmp	eax, breakpoints_n
2679
	cmp	eax, breakpoints_n
2673
	jb	@b
2680
	jb	@b
2674
	or	eax, -1
2681
	or	eax, -1
2675
.found:
2682
.found:
2676
	ret
2683
	ret
2677
 
2684
 
2678
OnUnpack:
2685
OnUnpack:
2679
; program must be loaded - checked when command was parsed
2686
; program must be loaded - checked when command was parsed
2680
; program must be stopped
2687
; program must be stopped
2681
	mov	esi, aRunningErr
2688
	mov	esi, aRunningErr
2682
	cmp	[bSuspended], 0
2689
	cmp	[bSuspended], 0
2683
	jz	put_message
2690
	jz	put_message
2684
; all breakpoints must be disabled
2691
; all breakpoints must be disabled
2685
	mov	edi, breakpoints
2692
	mov	edi, breakpoints
2686
@@:
2693
@@:
2687
	test	byte [edi+4], 1
2694
	test	byte [edi+4], 1
2688
	jz	.cont
2695
	jz	.cont
2689
	test	byte [edi+4], 2
2696
	test	byte [edi+4], 2
2690
	jnz	.cont
2697
	jnz	.cont
2691
	mov	esi, aEnabledBreakErr
2698
	mov	esi, aEnabledBreakErr
2692
	jmp	put_message
2699
	jmp	put_message
2693
.cont:
2700
.cont:
2694
	add	edi, 6
2701
	add	edi, 6
2695
	cmp	edi, breakpoints+breakpoints_n*6
2702
	cmp	edi, breakpoints+breakpoints_n*6
2696
	jb	@b
2703
	jb	@b
2697
; ok, now do it
2704
; ok, now do it
2698
; set breakpoint on 0xC dword access
2705
; set breakpoint on 0xC dword access
2699
	push	9
2706
	push	9
2700
	pop	ebx
2707
	pop	ebx
2701
	mov	ecx, [debuggee_pid]
2708
	mov	ecx, [debuggee_pid]
2702
	mov	dx, 1111b*256
2709
	mov	dx, 1111b*256
2703
	push	0xC
2710
	push	0xC
2704
	pop	esi
2711
	pop	esi
2705
@@:
2712
@@:
2706
	push	69
2713
	push	69
2707
	pop	eax
2714
	pop	eax
2708
	int	40h
2715
	int	40h
2709
	test	eax, eax
2716
	test	eax, eax
2710
	jz	.breakok
2717
	jz	.breakok
2711
	inc	edx
2718
	inc	edx
2712
	cmp	dl, 4
2719
	cmp	dl, 4
2713
	jb	@b
2720
	jb	@b
2714
.breakok:
2721
.breakok:
2715
	call	GoOn
2722
	call	GoOn
2716
; now wait for event
2723
; now wait for event
2717
.wait:
2724
.wait:
2718
	push	10
2725
	push	10
2719
	pop	eax
2726
	pop	eax
2720
	int	40h
2727
	int	40h
2721
	dec	eax
2728
	dec	eax
2722
	jz	.redraw
2729
	jz	.redraw
2723
	dec	eax
2730
	dec	eax
2724
	jz	.key
2731
	jz	.key
2725
	dec	eax
2732
	dec	eax
2726
	jnz	.debug
2733
	jnz	.debug
2727
; button; we have only one button, close
2734
; button; we have only one button, close
2728
	or	eax, -1
2735
	or	eax, -1
2729
	int	40h
2736
	int	40h
2730
.redraw:
2737
.redraw:
2731
	call	draw_window
2738
	call	draw_window
2732
	jmp	.wait
2739
	jmp	.wait
2733
.key:
2740
.key:
2734
	mov	al, 2
2741
	mov	al, 2
2735
	int	40h
2742
	int	40h
2736
	cmp	ah, 3	; Ctrl+C
2743
	cmp	ah, 3	; Ctrl+C
2737
	jnz	.wait
2744
	jnz	.wait
2738
.userbreak:
2745
.userbreak:
2739
	mov	esi, aInterrupted
2746
	mov	esi, aInterrupted
2740
.x1:
2747
.x1:
2741
	push	edx esi
2748
	push	edx esi
2742
	call	put_message
2749
	call	put_message
2743
	pop	esi edx
2750
	pop	esi edx
2744
	or	dh, 80h
2751
	or	dh, 80h
2745
	push	69
2752
	push	69
2746
	pop	eax
2753
	pop	eax
2747
	push	9
2754
	push	9
2748
	pop	ebx
2755
	pop	ebx
2749
	mov	ecx, [debuggee_pid]
2756
	mov	ecx, [debuggee_pid]
2750
	int	40h
2757
	int	40h
2751
	cmp	esi, aUnpacked
2758
	cmp	esi, aUnpacked
2752
	jnz	OnSuspend
2759
	jnz	OnSuspend
2753
	jmp	AfterSuspend
2760
	jmp	AfterSuspend
2754
.debug:
2761
.debug:
2755
	cmp	[dbgbuflen], 4*3
2762
	cmp	[dbgbuflen], 4*3
2756
	jnz	.notour
2763
	jnz	.notour
2757
	cmp	dword [dbgbuf], 3
2764
	cmp	dword [dbgbuf], 3
2758
	jnz	.notour
2765
	jnz	.notour
2759
	test	byte [dbgbuf+8], 1
2766
	test	byte [dbgbuf+8], 1
2760
	jnz	.our
2767
	jnz	.our
2761
.notour:
2768
.notour:
2762
	mov	esi, aInterrupted
2769
	mov	esi, aInterrupted
2763
	push	edx
2770
	push	edx
2764
	call	put_message
2771
	call	put_message
2765
	pop	edx
2772
	pop	edx
2766
	or	dh, 80h
2773
	or	dh, 80h
2767
	push	69
2774
	push	69
2768
	pop	eax
2775
	pop	eax
2769
	push	9
2776
	push	9
2770
	pop	ebx
2777
	pop	ebx
2771
	mov	ecx, [debuggee_pid]
2778
	mov	ecx, [debuggee_pid]
2772
	int	40h
2779
	int	40h
2773
	jmp	debugmsg
2780
	jmp	debugmsg
2774
.our:
2781
.our:
2775
	and	[dbgbuflen], 0
2782
	and	[dbgbuflen], 0
2776
	push	edx
2783
	push	edx
2777
	call	get_context
2784
	call	get_context
2778
	push	eax
2785
	push	eax
2779
	mov	al, 69
2786
	mov	al, 69
2780
	mov	bl, 6
2787
	mov	bl, 6
2781
	mov	ecx, [debuggee_pid]
2788
	mov	ecx, [debuggee_pid]
2782
	mov	edi, esp
2789
	mov	edi, esp
2783
	push	4
2790
	push	4
2784
	pop	edx
2791
	pop	edx
2785
	push	0xC
2792
	push	0xC
2786
	pop	esi
2793
	pop	esi
2787
	int	40h
2794
	int	40h
2788
	pop	eax
2795
	pop	eax
2789
	pop	edx
2796
	pop	edx
2790
	cmp	eax, [_eip]
2797
	cmp	eax, [_eip]
2791
	jz	.done
2798
	jz	.done
2792
	call	DoResume
2799
	call	DoResume
2793
	jmp	.wait
2800
	jmp	.wait
2794
.done:
2801
.done:
2795
	mov	esi, aUnpacked
2802
	mov	esi, aUnpacked
2796
	jmp	.x1
2803
	jmp	.x1
2797
 
2804
 
2798
disasm_get_byte:
2805
disasm_get_byte:
2799
; out: al=byte
2806
; out: al=byte
2800
	push	ecx
2807
	push	ecx
2801
	mov	ecx, [disasm_cur_pos]
2808
	mov	ecx, [disasm_cur_pos]
2802
	sub	ecx, [disasm_start_pos]
2809
	sub	ecx, [disasm_start_pos]
2803
	cmp	ecx, [disasm_buf_size]
2810
	cmp	ecx, [disasm_buf_size]
2804
	jae	disasm_err
2811
	jae	disasm_err
2805
	mov	al, [disasm_buffer+ecx]
2812
	mov	al, [disasm_buffer+ecx]
2806
	pop	ecx
2813
	pop	ecx
2807
	inc	[disasm_cur_pos]
2814
	inc	[disasm_cur_pos]
2808
	ret
2815
	ret
2809
disasm_get_word:
2816
disasm_get_word:
2810
	push	ecx
2817
	push	ecx
2811
	mov	ecx, [disasm_cur_pos]
2818
	mov	ecx, [disasm_cur_pos]
2812
	sub	ecx, [disasm_start_pos]
2819
	sub	ecx, [disasm_start_pos]
2813
	inc	ecx
2820
	inc	ecx
2814
	cmp	ecx, [disasm_buf_size]
2821
	cmp	ecx, [disasm_buf_size]
2815
	jae	disasm_err
2822
	jae	disasm_err
2816
	mov	ax, word [disasm_buffer-1+ecx]
2823
	mov	ax, word [disasm_buffer-1+ecx]
2817
	pop	ecx
2824
	pop	ecx
2818
	add	[disasm_cur_pos], 2
2825
	add	[disasm_cur_pos], 2
2819
	ret
2826
	ret
2820
disasm_get_dword:
2827
disasm_get_dword:
2821
	push	ecx
2828
	push	ecx
2822
	mov	ecx, [disasm_cur_pos]
2829
	mov	ecx, [disasm_cur_pos]
2823
	sub	ecx, [disasm_start_pos]
2830
	sub	ecx, [disasm_start_pos]
2824
	add	ecx, 3
2831
	add	ecx, 3
2825
	cmp	ecx, [disasm_buf_size]
2832
	cmp	ecx, [disasm_buf_size]
2826
	jae	disasm_err
2833
	jae	disasm_err
2827
	mov	eax, dword [disasm_buffer-3+ecx]
2834
	mov	eax, dword [disasm_buffer-3+ecx]
2828
	pop	ecx
2835
	pop	ecx
2829
	add	[disasm_cur_pos], 4
2836
	add	[disasm_cur_pos], 4
2830
	ret
2837
	ret
2831
 
2838
 
2832
disasm_err:
2839
disasm_err:
2833
	mov	esp, ebp
2840
	mov	esp, ebp
2834
stc_ret:
2841
stc_ret:
2835
	stc
2842
	stc
2836
	ret
2843
	ret
2837
disasm_ret:
2844
disasm_ret:
2838
	mov	esp, ebp
2845
	mov	esp, ebp
2839
	and	byte [edi], 0
2846
	and	byte [edi], 0
2840
	ret
2847
	ret
2841
 
2848
 
2842
disasm_instr:
2849
disasm_instr:
2843
	mov	ebp, esp
2850
	mov	ebp, esp
2844
	cmp	[debuggee_pid], 0
2851
	cmp	[debuggee_pid], 0
2845
	jz	stc_ret
2852
	jz	stc_ret
2846
	mov	edi, disasm_string
2853
	mov	edi, disasm_string
2847
	xor	ecx, ecx
2854
	xor	ecx, ecx
2848
; ecx=flags
2855
; ecx=flags
2849
disasm_loop1:
2856
disasm_loop1:
2850
	xor	eax, eax
2857
	xor	eax, eax
2851
	call	disasm_get_byte
2858
	call	disasm_get_byte
2852
	jmp	dword [disasm_table_1 + eax*4]
2859
	jmp	dword [disasm_table_1 + eax*4]
2853
 
2860
 
2854
cop0:
2861
cop0:
2855
clock:
2862
clock:
2856
crepnz:
2863
crepnz:
2857
crep:
2864
crep:
2858
csegcs:
2865
csegcs:
2859
csegds:
2866
csegds:
2860
cseges:
2867
cseges:
2861
csegss:
2868
csegss:
2862
csegfs:
2869
csegfs:
2863
cseggs:
2870
cseggs:
2864
	call	@f
2871
	call	@f
2865
	db	0x2E,3,'cs:'
2872
	db	0x2E,3,'cs:'
2866
	db	0x36,3,'ss:'
2873
	db	0x36,3,'ss:'
2867
	db	0x3E,3,'ds:'
2874
	db	0x3E,3,'ds:'
2868
	db	0x26,3,'es:'
2875
	db	0x26,3,'es:'
2869
	db	0x64,3,'fs:'
2876
	db	0x64,3,'fs:'
2870
	db	0x65,3,'gs:'
2877
	db	0x65,3,'gs:'
2871
	db	0x06,10,'push    es'
2878
	db	0x06,10,'push    es'
2872
	db	0x07,10,'pop     es'
2879
	db	0x07,10,'pop     es'
2873
	db	0x0E,10,'push    cs'
2880
	db	0x0E,10,'push    cs'
2874
	db	0x16,10,'push    ss'
2881
	db	0x16,10,'push    ss'
2875
	db	0x17,10,'pop     ss'
2882
	db	0x17,10,'pop     ss'
2876
	db	0x1E,10,'push    ds'
2883
	db	0x1E,10,'push    ds'
2877
	db	0x1F,10,'pop     ds'
2884
	db	0x1F,10,'pop     ds'
2878
	db	0x27,3,'daa'
2885
	db	0x27,3,'daa'
2879
	db	0x2F,3,'das'
2886
	db	0x2F,3,'das'
2880
	db	0x37,3,'aaa'
2887
	db	0x37,3,'aaa'
2881
	db	0x3F,3,'aas'
2888
	db	0x3F,3,'aas'
2882
	db	0x60,6,0,'pusha'
2889
	db	0x60,6,0,'pusha'
2883
	db	0x61,5,0,'popa'
2890
	db	0x61,5,0,'popa'
2884
	db	0x90,3,'nop'
2891
	db	0x90,3,'nop'
2885
	db	0x9B,5,'fwait'
2892
	db	0x9B,5,'fwait'
2886
	db	0x9C,6,0,'pushf'
2893
	db	0x9C,6,0,'pushf'
2887
	db	0x9D,5,0,'popf'
2894
	db	0x9D,5,0,'popf'
2888
	db	0x9E,4,'sahf'
2895
	db	0x9E,4,'sahf'
2889
	db	0x9F,4,'lahf'
2896
	db	0x9F,4,'lahf'
2890
	db	0xA4,5,'movsb'
2897
	db	0xA4,5,'movsb'
2891
	db	0xA5,5,0,'movs'
2898
	db	0xA5,5,0,'movs'
2892
	db	0xA6,5,'cmpsb'
2899
	db	0xA6,5,'cmpsb'
2893
	db	0xA7,5,0,'cmps'
2900
	db	0xA7,5,0,'cmps'
2894
	db	0xAA,5,'stosb'
2901
	db	0xAA,5,'stosb'
2895
	db	0xAB,5,0,'stos'
2902
	db	0xAB,5,0,'stos'
2896
	db	0xAC,5,'lodsb'
2903
	db	0xAC,5,'lodsb'
2897
	db	0xAD,5,0,'lods'
2904
	db	0xAD,5,0,'lods'
2898
	db	0xAE,5,'scasb'
2905
	db	0xAE,5,'scasb'
2899
	db	0xAF,5,0,'scas'
2906
	db	0xAF,5,0,'scas'
2900
	db	0xC3,3,'ret'
2907
	db	0xC3,3,'ret'
2901
	db	0xC9,5,'leave'
2908
	db	0xC9,5,'leave'
2902
	db	0xCC,4,'int3'
2909
	db	0xCC,4,'int3'
2903
	db	0xF0,4,'lock'
2910
	db	0xF0,4,'lock'
2904
	db	0xF2,5,'repnz'
2911
	db	0xF2,5,'repnz'
2905
	db	0xF3,6,'rep(z)'
2912
	db	0xF3,6,'rep(z)'
2906
	db	0xF5,3,'cmc'
2913
	db	0xF5,3,'cmc'
2907
	db	0xF8,3,'clc'
2914
	db	0xF8,3,'clc'
2908
	db	0xF9,3,'stc'
2915
	db	0xF9,3,'stc'
2909
	db	0xFA,3,'cli'
2916
	db	0xFA,3,'cli'
2910
	db	0xFB,3,'sti'
2917
	db	0xFB,3,'sti'
2911
	db	0xFC,3,'cld'
2918
	db	0xFC,3,'cld'
2912
	db	0xFD,3,'std'
2919
	db	0xFD,3,'std'
-
 
2920
csysenter:
-
 
2921
csyscall:
-
 
2922
ccpuid:
-
 
2923
crdtsc:
-
 
2924
	call	@f
-
 
2925
	db	0x05,7,'syscall'
-
 
2926
	db	0x31,5,'rdtsc'
-
 
2927
	db	0x34,8,'sysenter'
-
 
2928
	db	0xA2,5,'cpuid'
2913
@@:
2929
@@:
2914
	pop	esi
2930
	pop	esi
2915
@@:
2931
@@:
2916
	cmp	al, [esi]
2932
	cmp	al, [esi]
2917
	jz	.found
2933
	jz	.found
2918
	inc	esi
2934
	inc	esi
2919
	movzx	edx, byte [esi]
2935
	movzx	edx, byte [esi]
2920
	inc	esi
2936
	inc	esi
2921
	add	esi, edx
2937
	add	esi, edx
2922
	jmp	@b
2938
	jmp	@b
2923
.found:
2939
.found:
2924
	inc	esi
2940
	inc	esi
2925
	lodsb
2941
	lodsb
2926
	cmp	byte [esi], 0
2942
	cmp	byte [esi], 0
2927
	jz	@f
2943
	jz	@f
2928
	movzx	ecx, al
2944
	movzx	ecx, al
2929
disasm_1:
2945
disasm_1:
2930
	rep	movsb
2946
	rep	movsb
2931
	and	byte [edi], 0
2947
	and	byte [edi], 0
2932
	ret
2948
	ret
2933
@@:
2949
@@:
2934
	mov	dl, ch
2950
	mov	dl, ch
2935
	movzx	ecx, al
2951
	movzx	ecx, al
2936
	dec	ecx
2952
	dec	ecx
2937
	inc	esi
2953
	inc	esi
2938
	rep	movsb
2954
	rep	movsb
2939
	test	dl, 1
2955
	test	dl, 1
2940
	mov	al, 'w'
2956
	mov	al, 'w'
2941
	jnz	@f
2957
	jnz	@f
2942
	mov	al, 'd'
2958
	mov	al, 'd'
2943
@@:	stosb
2959
@@:	stosb
2944
	and	byte [edi], 0
2960
	and	byte [edi], 0
2945
	ret
2961
	ret
2946
 
2962
 
2947
c67:
2963
c67:
2948
	or	ch, 2
2964
	or	ch, 2
2949
	jmp	disasm_loop1
2965
	jmp	disasm_loop1
2950
c66:
2966
c66:
2951
	or	ch, 1
2967
	or	ch, 1
2952
	jmp	disasm_loop1
2968
	jmp	disasm_loop1
2953
 
2969
 
2954
center:
2970
center:
2955
caam:
2971
caam:
2956
cxlat:
2972
cxlat:
2957
crdtsc:
-
 
2958
csysenter:
-
 
2959
ccpuid:
-
 
2960
ccmpxchg:
2973
ccmpxchg:
2961
cbsf:
2974
cbsf:
2962
cbsr:
2975
cbsr:
2963
ccmpxchg8b:
2976
ccmpxchg8b:
2964
cunk:
2977
cunk:
2965
cerr:
2978
cerr:
2966
	mov	eax, '???'
2979
	mov	eax, '???'
2967
	stosd
2980
	stosd
2968
	clc
2981
	clc
2969
	ret
2982
	ret
2970
 
2983
 
2971
cF:
2984
cF:
2972
	call	disasm_get_byte
2985
	call	disasm_get_byte
2973
	jmp	dword [disasm_table_2 + eax*4]
2986
	jmp	dword [disasm_table_2 + eax*4]
2974
 
2987
 
2975
macro disasm_set_modew
2988
macro disasm_set_modew
2976
{
2989
{
2977
	test	al, 1
2990
	test	al, 1
2978
	jz	@f
2991
	jz	@f
2979
	or	ch, 80h
2992
	or	ch, 80h
2980
@@:
2993
@@:
2981
}
2994
}
2982
 
2995
 
2983
cmov2:
2996
cmov2:
2984
	disasm_set_modew
2997
	disasm_set_modew
2985
; mov r/m,i
2998
; mov r/m,i
2986
	call	disasm_get_byte
2999
	call	disasm_get_byte
2987
	dec	[disasm_cur_pos]
3000
	dec	[disasm_cur_pos]
2988
	test	al, 00111000b
3001
	test	al, 00111000b
2989
	jnz	cunk
3002
	jnz	cunk
2990
	mov	eax, 'mov '
3003
	mov	eax, 'mov '
2991
	stosd
3004
	stosd
2992
	mov	eax, '    '
3005
	mov	eax, '    '
2993
	stosd
3006
	stosd
2994
	call	disasm_readrmop
3007
	call	disasm_readrmop
2995
	mov	ax, ', '
3008
	mov	ax, ', '
2996
	stosw
3009
	stosw
2997
	xor	eax, eax
3010
	xor	eax, eax
2998
	test	ch, 80h
3011
	test	ch, 80h
2999
	jnz	.1
3012
	jnz	.1
3000
	call	disasm_get_byte
3013
	call	disasm_get_byte
3001
	jmp	.3
3014
	jmp	.3
3002
.1:
3015
.1:
3003
	test	ch, 1
3016
	test	ch, 1
3004
	jnz	.2
3017
	jnz	.2
3005
	call	disasm_get_dword
3018
	call	disasm_get_dword
3006
	jmp	.3
3019
	jmp	.3
3007
.2:
3020
.2:
3008
	call	disasm_get_word
3021
	call	disasm_get_word
3009
.3:
3022
.3:
3010
	call	disasm_write_num
3023
	call	disasm_write_num
3011
	and	byte [edi], 0
3024
	and	byte [edi], 0
3012
	ret
3025
	ret
3013
 
3026
 
3014
cret2:
3027
cret2:
3015
	mov	eax, 'ret '
3028
	mov	eax, 'ret '
3016
	stosd
3029
	stosd
3017
	mov	eax, '    '
3030
	mov	eax, '    '
3018
	stosd
3031
	stosd
3019
	xor	eax, eax
3032
	xor	eax, eax
3020
	jmp	cmov2.2
3033
	jmp	cmov2.2
3021
 
3034
 
3022
disasm_write_num:
3035
disasm_write_num:
3023
	push	ecx eax
3036
	push	ecx eax
3024
	inc	edi
3037
	inc	edi
3025
@@:
3038
@@:
3026
	mov	ecx, eax
3039
	mov	ecx, eax
3027
	shr	eax, 4
3040
	shr	eax, 4
3028
	jz	@f
3041
	jz	@f
3029
	inc	edi
3042
	inc	edi
3030
	jmp	@b
3043
	jmp	@b
3031
@@:
3044
@@:
3032
	pop	eax
3045
	pop	eax
3033
	cmp	ecx, 10
3046
	cmp	ecx, 10
3034
	jb	@f
3047
	jb	@f
3035
	inc	edi
3048
	inc	edi
3036
@@:
3049
@@:
3037
	push	edi eax
3050
	push	edi eax
3038
@@:
3051
@@:
3039
	mov	ecx, eax
3052
	mov	ecx, eax
3040
	and	al, 0xF
3053
	and	al, 0xF
3041
	cmp	al, 10
3054
	cmp	al, 10
3042
	sbb	al, 69h
3055
	sbb	al, 69h
3043
	das
3056
	das
3044
	dec	edi
3057
	dec	edi
3045
	mov	[edi], al
3058
	mov	[edi], al
3046
	mov	eax, ecx
3059
	mov	eax, ecx
3047
	shr	eax, 4
3060
	shr	eax, 4
3048
	jnz	@b
3061
	jnz	@b
3049
	cmp	ecx, 10
3062
	cmp	ecx, 10
3050
	jb	@f
3063
	jb	@f
3051
	mov	byte [edi-1], '0'
3064
	mov	byte [edi-1], '0'
3052
@@:
3065
@@:
3053
	pop	eax edi ecx
3066
	pop	eax edi ecx
3054
	cmp	eax, 10
3067
	cmp	eax, 10
3055
	jb	@f
3068
	jb	@f
3056
	mov	byte [edi], 'h'
3069
	mov	byte [edi], 'h'
3057
	inc	edi
3070
	inc	edi
3058
@@:
3071
@@:
3059
	ret
3072
	ret
3060
 
3073
 
3061
label disasm_regs32 dword
3074
label disasm_regs32 dword
3062
label disasm_regs dword
3075
label disasm_regs dword
3063
	db	'eax',0
3076
	db	'eax',0
3064
	db	'ecx',0
3077
	db	'ecx',0
3065
	db	'edx',0
3078
	db	'edx',0
3066
	db	'ebx',0
3079
	db	'ebx',0
3067
	db	'esp',0
3080
	db	'esp',0
3068
	db	'ebp',0
3081
	db	'ebp',0
3069
	db	'esi',0
3082
	db	'esi',0
3070
	db	'edi',0
3083
	db	'edi',0
3071
disasm_regs16	dw	'ax','cx','dx','bx','sp','bp','si','di'
3084
disasm_regs16	dw	'ax','cx','dx','bx','sp','bp','si','di'
3072
disasm_regs8	dw	'al','cl','dl','bl','ah','ch','dh','bh'
3085
disasm_regs8	dw	'al','cl','dl','bl','ah','ch','dh','bh'
3073
disasm_scale	db	'1248'
3086
disasm_scale	db	'1248'
3074
disasm_readrmop:
3087
disasm_readrmop:
3075
	call	disasm_get_byte
3088
	call	disasm_get_byte
3076
	test	ch, 40h
3089
	test	ch, 40h
3077
	jnz	.skip_size
3090
	jnz	.skip_size
3078
	push	eax
3091
	push	eax
3079
	and	al, 0xC0
3092
	and	al, 0xC0
3080
	cmp	al, 0xC0
3093
	cmp	al, 0xC0
3081
	pop	eax
3094
	pop	eax
3082
	jz	.skip_size
3095
	jz	.skip_size
3083
	test	ch, 80h
3096
	test	ch, 80h
3084
	jz	.byte
3097
	jz	.byte
3085
	test	ch, 1
3098
	test	ch, 1
3086
	jnz	.word
3099
	jnz	.word
3087
	mov	dword [edi], 'dwor'
3100
	mov	dword [edi], 'dwor'
3088
	mov	byte [edi+4], 'd'
3101
	mov	byte [edi+4], 'd'
3089
	inc	edi
3102
	inc	edi
3090
	jmp	@f
3103
	jmp	@f
3091
.byte:
3104
.byte:
3092
	test	ch, 20h
3105
	test	ch, 20h
3093
	jz	.qb
3106
	jz	.qb
3094
	mov	byte [edi], 't'
3107
	mov	byte [edi], 't'
3095
	inc	edi
3108
	inc	edi
3096
.qb:
3109
.qb:
3097
	mov	dword [edi], 'byte'
3110
	mov	dword [edi], 'byte'
3098
	jmp	@f
3111
	jmp	@f
3099
.word:
3112
.word:
3100
	test	ch, 20h
3113
	test	ch, 20h
3101
	jz	.qw
3114
	jz	.qw
3102
	mov	byte [edi], 'q'
3115
	mov	byte [edi], 'q'
3103
	inc	edi
3116
	inc	edi
3104
.qw:
3117
.qw:
3105
	mov	dword [edi], 'word'
3118
	mov	dword [edi], 'word'
3106
@@:
3119
@@:
3107
	mov	byte [edi+4], ' '
3120
	mov	byte [edi+4], ' '
3108
	add	edi, 5
3121
	add	edi, 5
3109
.skip_size:
3122
.skip_size:
3110
	test	ch, 2
3123
	test	ch, 2
3111
	jnz	disasm_readrmop16
3124
	jnz	disasm_readrmop16
3112
	push	ecx
3125
	push	ecx
3113
	movzx	ecx, al
3126
	movzx	ecx, al
3114
	and	eax, 7
3127
	and	eax, 7
3115
	shr	ecx, 6
3128
	shr	ecx, 6
3116
	jz	.vmod0
3129
	jz	.vmod0
3117
	jp	.vmod3
3130
	jp	.vmod3
3118
	mov	byte [edi], '['
3131
	mov	byte [edi], '['
3119
	inc	edi
3132
	inc	edi
3120
	cmp	al, 4
3133
	cmp	al, 4
3121
	jz	.sib1
3134
	jz	.sib1
3122
	mov	eax, [disasm_regs+eax*4]
3135
	mov	eax, [disasm_regs+eax*4]
3123
	stosd
3136
	stosd
3124
	dec	edi
3137
	dec	edi
3125
	jmp	@f
3138
	jmp	@f
3126
.sib1:
3139
.sib1:
3127
	call	.parse_sib
3140
	call	.parse_sib
3128
@@:
3141
@@:
3129
	mov	al, '+'
3142
	mov	al, '+'
3130
	stosb
3143
	stosb
3131
	dec	ecx
3144
	dec	ecx
3132
	jz	.vmod1
3145
	jz	.vmod1
3133
	call	disasm_get_dword
3146
	call	disasm_get_dword
3134
	jmp	@f
3147
	jmp	@f
3135
.vmod1:
3148
.vmod1:
3136
	call	disasm_get_byte
3149
	call	disasm_get_byte
3137
	movsx	eax, al
3150
	movsx	eax, al
3138
@@:
3151
@@:
3139
	test	eax, eax
3152
	test	eax, eax
3140
	jns	.2
3153
	jns	.2
3141
	neg	eax
3154
	neg	eax
3142
	mov	byte [edi-1], '-'
3155
	mov	byte [edi-1], '-'
3143
.2:
3156
.2:
3144
	call	disasm_write_num
3157
	call	disasm_write_num
3145
	mov	al, ']'
3158
	mov	al, ']'
3146
	stosb
3159
	stosb
3147
	pop	ecx
3160
	pop	ecx
3148
	ret
3161
	ret
3149
.vmod3:
3162
.vmod3:
3150
	pop	ecx
3163
	pop	ecx
3151
	test	ch, 80h
3164
	test	ch, 80h
3152
	jz	.vmod3_byte
3165
	jz	.vmod3_byte
3153
	test	ch, 1
3166
	test	ch, 1
3154
	jnz	.vmod3_word
3167
	jnz	.vmod3_word
3155
	test	ch, 20h
3168
	test	ch, 20h
3156
	jnz	.vmod3_sti
3169
	jnz	.vmod3_sti
3157
	mov	eax, [disasm_regs32+eax*4]
3170
	mov	eax, [disasm_regs32+eax*4]
3158
	stosd
3171
	stosd
3159
	dec	edi
3172
	dec	edi
3160
	ret
3173
	ret
3161
.vmod3_byte:
3174
.vmod3_byte:
3162
	mov	ax, [disasm_regs8+eax*2]
3175
	mov	ax, [disasm_regs8+eax*2]
3163
@@:
3176
@@:
3164
	stosw
3177
	stosw
3165
	ret
3178
	ret
3166
.vmod3_word:
3179
.vmod3_word:
3167
	mov	ax, [disasm_regs16+eax*2]
3180
	mov	ax, [disasm_regs16+eax*2]
3168
	jmp	@b
3181
	jmp	@b
3169
.vmod3_sti:
3182
.vmod3_sti:
3170
	mov	word [edi], 'st'
3183
	mov	word [edi], 'st'
3171
	add	al, '0'
3184
	add	al, '0'
3172
	mov	byte [edi+2], al
3185
	mov	byte [edi+2], al
3173
	add	edi, 3
3186
	add	edi, 3
3174
	ret
3187
	ret
3175
.vmod0:
3188
.vmod0:
3176
	mov	byte [edi], '['
3189
	mov	byte [edi], '['
3177
	inc	edi
3190
	inc	edi
3178
	cmp	al, 4
3191
	cmp	al, 4
3179
	jz	.sib2
3192
	jz	.sib2
3180
	cmp	al, 5
3193
	cmp	al, 5
3181
	jz	.ofs32
3194
	jz	.ofs32
3182
	mov	eax, [disasm_regs+eax*4]
3195
	mov	eax, [disasm_regs+eax*4]
3183
	stosd
3196
	stosd
3184
	mov	byte [edi-1], ']'
3197
	mov	byte [edi-1], ']'
3185
	pop	ecx
3198
	pop	ecx
3186
	ret
3199
	ret
3187
.ofs32:
3200
.ofs32:
3188
	call	disasm_get_dword
3201
	call	disasm_get_dword
3189
	jmp	.2
3202
	jmp	.2
3190
.sib2:
3203
.sib2:
3191
	call	.parse_sib
3204
	call	.parse_sib
3192
	mov	al, ']'
3205
	mov	al, ']'
3193
	stosb
3206
	stosb
3194
	pop	ecx
3207
	pop	ecx
3195
	ret
3208
	ret
3196
.parse_sib:
3209
.parse_sib:
3197
	call	disasm_get_byte
3210
	call	disasm_get_byte
3198
	push	edx
3211
	push	edx
3199
	mov	dl, al
3212
	mov	dl, al
3200
	mov	dh, 0
3213
	mov	dh, 0
3201
	and	eax, 7
3214
	and	eax, 7
3202
	cmp	al, 5
3215
	cmp	al, 5
3203
	jnz	@f
3216
	jnz	@f
3204
	jecxz	.sib0
3217
	jecxz	.sib0
3205
@@:
3218
@@:
3206
	mov	eax, [disasm_regs+eax*4]
3219
	mov	eax, [disasm_regs+eax*4]
3207
	stosd
3220
	stosd
3208
	dec	edi
3221
	dec	edi
3209
	mov	dh, 1
3222
	mov	dh, 1
3210
.sib0:
3223
.sib0:
3211
	mov	al, dl
3224
	mov	al, dl
3212
	shr	eax, 3
3225
	shr	eax, 3
3213
	and	eax, 7
3226
	and	eax, 7
3214
	cmp	al, 4
3227
	cmp	al, 4
3215
	jz	.sibret
3228
	jz	.sibret
3216
	test	dh, dh
3229
	test	dh, dh
3217
	jz	@f
3230
	jz	@f
3218
	mov	byte [edi], '+'
3231
	mov	byte [edi], '+'
3219
	inc	edi
3232
	inc	edi
3220
@@:
3233
@@:
3221
	mov	eax, [disasm_regs+eax*4]
3234
	mov	eax, [disasm_regs+eax*4]
3222
	stosd
3235
	stosd
3223
	dec	edi
3236
	dec	edi
3224
	shr	dl, 6
3237
	shr	dl, 6
3225
	jz	@f
3238
	jz	@f
3226
	mov	al, '*'
3239
	mov	al, '*'
3227
	stosb
3240
	stosb
3228
	movzx	eax, dl
3241
	movzx	eax, dl
3229
	mov	al, [disasm_scale+eax]
3242
	mov	al, [disasm_scale+eax]
3230
	stosb
3243
	stosb
3231
@@:
3244
@@:
3232
.sibret:
3245
.sibret:
3233
	test	dh, dh
3246
	test	dh, dh
3234
	jnz	.sibret2
3247
	jnz	.sibret2
3235
	call	disasm_get_dword
3248
	call	disasm_get_dword
3236
	cmp	byte [edi-1], '['
3249
	cmp	byte [edi-1], '['
3237
	jz	@f
3250
	jz	@f
3238
	mov	byte [edi], '+'
3251
	mov	byte [edi], '+'
3239
	test	eax, eax
3252
	test	eax, eax
3240
	jns	.sibns
3253
	jns	.sibns
3241
	neg	eax
3254
	neg	eax
3242
	mov	byte [edi], '-'
3255
	mov	byte [edi], '-'
3243
.sibns:
3256
.sibns:
3244
	inc	edi
3257
	inc	edi
3245
@@:
3258
@@:
3246
	call	disasm_write_num
3259
	call	disasm_write_num
3247
.sibret2:
3260
.sibret2:
3248
	pop	edx
3261
	pop	edx
3249
	ret
3262
	ret
3250
 
3263
 
3251
disasm_rm16_1	dd	'bxsi','bxdi','bpsi','bpdi'
3264
disasm_rm16_1	dd	'bxsi','bxdi','bpsi','bpdi'
3252
disasm_rm16_2	dw	'si','di','bp','bx'
3265
disasm_rm16_2	dw	'si','di','bp','bx'
3253
disasm_readrmop16:
3266
disasm_readrmop16:
3254
	push	ecx
3267
	push	ecx
3255
	movzx	ecx, al
3268
	movzx	ecx, al
3256
	and	eax, 7
3269
	and	eax, 7
3257
	shr	ecx, 6
3270
	shr	ecx, 6
3258
	jz	.vmod0
3271
	jz	.vmod0
3259
	jp	disasm_readrmop.vmod3	; mod=3 is the same in 16- and 32-bit code
3272
	jp	disasm_readrmop.vmod3	; mod=3 is the same in 16- and 32-bit code
3260
; 1 or 2
3273
; 1 or 2
3261
	mov	byte [edi], '['
3274
	mov	byte [edi], '['
3262
	inc	edi
3275
	inc	edi
3263
	cmp	al, 4
3276
	cmp	al, 4
3264
	jae	@f
3277
	jae	@f
3265
	mov	eax, [disasm_rm16_1+eax*4]
3278
	mov	eax, [disasm_rm16_1+eax*4]
3266
	stosw
3279
	stosw
3267
	mov	al, '+'
3280
	mov	al, '+'
3268
	stosb
3281
	stosb
3269
	shr	eax, 16
3282
	shr	eax, 16
3270
	jmp	.1
3283
	jmp	.1
3271
@@:
3284
@@:
3272
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
3285
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
3273
.1:
3286
.1:
3274
	stosw
3287
	stosw
3275
	mov	al, '+'
3288
	mov	al, '+'
3276
	stosb
3289
	stosb
3277
	xor	eax, eax
3290
	xor	eax, eax
3278
	dec	ecx
3291
	dec	ecx
3279
	jnz	.2
3292
	jnz	.2
3280
	call	disasm_get_byte
3293
	call	disasm_get_byte
3281
	cbw
3294
	cbw
3282
	jmp	@f
3295
	jmp	@f
3283
.2:
3296
.2:
3284
	call	disasm_get_word
3297
	call	disasm_get_word
3285
@@:
3298
@@:
3286
	test	ax, ax
3299
	test	ax, ax
3287
	jns	@f
3300
	jns	@f
3288
	mov	byte [edi-1], '-'
3301
	mov	byte [edi-1], '-'
3289
	neg	ax
3302
	neg	ax
3290
@@:
3303
@@:
3291
	call	disasm_write_num
3304
	call	disasm_write_num
3292
.done1:
3305
.done1:
3293
	mov	al, ']'
3306
	mov	al, ']'
3294
	stosb
3307
	stosb
3295
	pop	ecx
3308
	pop	ecx
3296
	ret
3309
	ret
3297
.vmod0:
3310
.vmod0:
3298
	mov	byte [edi], '['
3311
	mov	byte [edi], '['
3299
	inc	edi
3312
	inc	edi
3300
	cmp	al, 6
3313
	cmp	al, 6
3301
	jz	.ofs16
3314
	jz	.ofs16
3302
	cmp	al, 4
3315
	cmp	al, 4
3303
	jae	@f
3316
	jae	@f
3304
	mov	eax, [disasm_rm16_1+eax*4]
3317
	mov	eax, [disasm_rm16_1+eax*4]
3305
	stosw
3318
	stosw
3306
	mov	al, '+'
3319
	mov	al, '+'
3307
	stosb
3320
	stosb
3308
	shr	eax, 16
3321
	shr	eax, 16
3309
	jmp	.3
3322
	jmp	.3
3310
@@:
3323
@@:
3311
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
3324
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
3312
.3:
3325
.3:
3313
	stosw
3326
	stosw
3314
	jmp	.done1
3327
	jmp	.done1
3315
.ofs16:
3328
.ofs16:
3316
	xor	eax, eax
3329
	xor	eax, eax
3317
	call	disasm_get_word
3330
	call	disasm_get_word
3318
	call	disasm_write_num
3331
	call	disasm_write_num
3319
	jmp	.done1
3332
	jmp	.done1
3320
 
3333
 
3321
cpush21:
3334
cpush21:
3322
	mov	eax, 'push'
3335
	mov	eax, 'push'
3323
	stosd
3336
	stosd
3324
	mov	eax, '    '
3337
	mov	eax, '    '
3325
	stosd
3338
	stosd
3326
disasm_i32:
3339
disasm_i32:
3327
	call	disasm_get_dword
3340
	call	disasm_get_dword
3328
	call	disasm_write_num
3341
	call	disasm_write_num
3329
	and	byte [edi], 0
3342
	and	byte [edi], 0
3330
	ret
3343
	ret
3331
 
3344
 
3332
cpush22:
3345
cpush22:
3333
	mov	eax, 'push'
3346
	mov	eax, 'push'
3334
	stosd
3347
	stosd
3335
	mov	eax, '    '
3348
	mov	eax, '    '
3336
	stosd
3349
	stosd
3337
	call	disasm_get_byte
3350
	call	disasm_get_byte
3338
	movsx	eax, al
3351
	movsx	eax, al
3339
	call	disasm_write_num
3352
	call	disasm_write_num
3340
	and	byte [edi], 0
3353
	and	byte [edi], 0
3341
	ret
3354
	ret
3342
 
3355
 
3343
cinc1:
3356
cinc1:
3344
; inc reg32
3357
; inc reg32
3345
cdec1:
3358
cdec1:
3346
; dec reg32
3359
; dec reg32
3347
cpush1:
3360
cpush1:
3348
; push reg32
3361
; push reg32
3349
cpop1:
3362
cpop1:
3350
; pop reg32
3363
; pop reg32
3351
cbswap:
3364
cbswap:
3352
; bswap reg32
3365
; bswap reg32
3353
	mov	edx, eax
3366
	mov	edx, eax
3354
	and	edx, 7
3367
	and	edx, 7
3355
	shr	eax, 3
3368
	shr	eax, 3
3356
	sub	al, 8
3369
	sub	al, 8
3357
	mov	esi, 'inc '
3370
	mov	esi, 'inc '
3358
	jz	@f
3371
	jz	@f
3359
	mov	esi, 'dec '
3372
	mov	esi, 'dec '
3360
	dec	al
3373
	dec	al
3361
	jz	@f
3374
	jz	@f
3362
	mov	esi, 'push'
3375
	mov	esi, 'push'
3363
	dec	al
3376
	dec	al
3364
	jz	@f
3377
	jz	@f
3365
	mov	esi, 'pop '
3378
	mov	esi, 'pop '
3366
	dec	al
3379
	dec	al
3367
	jz	@f
3380
	jz	@f
3368
	mov	esi, 'bswa'
3381
	mov	esi, 'bswa'
3369
@@:
3382
@@:
3370
	xchg	eax, esi
3383
	xchg	eax, esi
3371
	stosd
3384
	stosd
3372
	mov	eax, '    '
3385
	mov	eax, '    '
3373
	jz	@f
3386
	jz	@f
3374
	mov	al, 'p'
3387
	mov	al, 'p'
3375
@@:
3388
@@:
3376
	stosd
3389
	stosd
3377
	xchg	eax, edx
3390
	xchg	eax, edx
3378
	call	disasm_write_reg1632
3391
	call	disasm_write_reg1632
3379
	and	byte [edi], 0
3392
	and	byte [edi], 0
3380
	ret
3393
	ret
3381
 
3394
 
3382
cxchg1:
3395
cxchg1:
3383
; xchg eax,reg32
3396
; xchg eax,reg32
3384
	and	eax, 7
3397
	and	eax, 7
3385
	xchg	eax, edx
3398
	xchg	eax, edx
3386
	mov	eax, 'xchg'
3399
	mov	eax, 'xchg'
3387
	stosd
3400
	stosd
3388
	mov	eax, '    '
3401
	mov	eax, '    '
3389
	stosd
3402
	stosd
3390
	xor	eax, eax
3403
	xor	eax, eax
3391
	call	disasm_write_reg1632
3404
	call	disasm_write_reg1632
3392
	mov	ax, ', '
3405
	mov	ax, ', '
3393
	stosw
3406
	stosw
3394
	xchg	eax, edx
3407
	xchg	eax, edx
3395
	call	disasm_write_reg1632
3408
	call	disasm_write_reg1632
3396
	and	byte [edi], 0
3409
	and	byte [edi], 0
3397
	ret
3410
	ret
3398
 
3411
 
3399
cint:
3412
cint:
3400
	mov	eax, 'int '
3413
	mov	eax, 'int '
3401
	stosd
3414
	stosd
3402
	mov	eax, '    '
3415
	mov	eax, '    '
3403
	stosd
3416
	stosd
3404
disasm_i8u:
3417
disasm_i8u:
3405
	xor	eax, eax
3418
	xor	eax, eax
3406
	call	disasm_get_byte
3419
	call	disasm_get_byte
3407
	call	disasm_write_num
3420
	call	disasm_write_num
3408
	and	byte [edi], 0
3421
	and	byte [edi], 0
3409
	ret
3422
	ret
3410
 
3423
 
3411
cmov11:
3424
cmov11:
3412
; mov r8,i8
3425
; mov r8,i8
3413
	mov	ecx, eax
3426
	mov	ecx, eax
3414
	mov	eax, 'mov '
3427
	mov	eax, 'mov '
3415
	stosd
3428
	stosd
3416
	mov	eax, '    '
3429
	mov	eax, '    '
3417
	stosd
3430
	stosd
3418
	and	ecx, 7
3431
	and	ecx, 7
3419
	mov	ax, [disasm_regs8+ecx*2]
3432
	mov	ax, [disasm_regs8+ecx*2]
3420
	stosw
3433
	stosw
3421
	mov	ax, ', '
3434
	mov	ax, ', '
3422
	stosw
3435
	stosw
3423
	jmp	disasm_i8u
3436
	jmp	disasm_i8u
3424
 
3437
 
3425
cmov12:
3438
cmov12:
3426
; mov r32,i32
3439
; mov r32,i32
3427
	xchg	eax, edx
3440
	xchg	eax, edx
3428
	mov	eax, 'mov '
3441
	mov	eax, 'mov '
3429
	stosd
3442
	stosd
3430
	mov	eax, '    '
3443
	mov	eax, '    '
3431
	stosd
3444
	stosd
3432
	xchg	eax, edx
3445
	xchg	eax, edx
3433
	and	eax, 7
3446
	and	eax, 7
3434
	call	disasm_write_reg1632
3447
	call	disasm_write_reg1632
3435
	mov	ax, ', '
3448
	mov	ax, ', '
3436
	stosw
3449
	stosw
3437
	jmp	cmov2.1
3450
	jmp	cmov2.1
3438
 
3451
 
3439
disasm_shifts	dd	'rol ','ror ','rcl ','rcr ','shl ','shr ','sal ','sar '
3452
disasm_shifts	dd	'rol ','ror ','rcl ','rcr ','shl ','shr ','sal ','sar '
3440
cshift2:
3453
cshift2:
3441
; shift r/m,1 = D0/D1
3454
; shift r/m,1 = D0/D1
3442
cshift3:
3455
cshift3:
3443
; shift r/m,cl = D2/D3
3456
; shift r/m,cl = D2/D3
3444
	disasm_set_modew
3457
	disasm_set_modew
3445
	mov	dl, al
3458
	mov	dl, al
3446
	call	disasm_get_byte
3459
	call	disasm_get_byte
3447
	dec	[disasm_cur_pos]
3460
	dec	[disasm_cur_pos]
3448
	shr	al, 3
3461
	shr	al, 3
3449
	and	eax, 7
3462
	and	eax, 7
3450
	mov	eax, [disasm_shifts+eax*4]
3463
	mov	eax, [disasm_shifts+eax*4]
3451
	stosd
3464
	stosd
3452
	mov	eax, '    '
3465
	mov	eax, '    '
3453
	stosd
3466
	stosd
3454
	call	disasm_readrmop
3467
	call	disasm_readrmop
3455
	cmp	dl, 0xD2
3468
	cmp	dl, 0xD2
3456
	jb	.s1
3469
	jb	.s1
3457
	mov	eax, ', cl'
3470
	mov	eax, ', cl'
3458
	stosd
3471
	stosd
3459
	and	byte [edi], 0
3472
	and	byte [edi], 0
3460
	ret
3473
	ret
3461
.s1:
3474
.s1:
3462
	mov	eax, ', 1'
3475
	mov	eax, ', 1'
3463
	stosd
3476
	stosd
3464
	clc
3477
	clc
3465
	ret
3478
	ret
3466
 
3479
 
3467
cshift1:
3480
cshift1:
3468
; shift r/m,i8 = C0/C1
3481
; shift r/m,i8 = C0/C1
3469
	disasm_set_modew
3482
	disasm_set_modew
3470
	call	disasm_get_byte
3483
	call	disasm_get_byte
3471
	dec	[disasm_cur_pos]
3484
	dec	[disasm_cur_pos]
3472
	shr	al, 3
3485
	shr	al, 3
3473
	and	eax, 7
3486
	and	eax, 7
3474
	mov	eax, [disasm_shifts+eax*4]
3487
	mov	eax, [disasm_shifts+eax*4]
3475
	stosd
3488
	stosd
3476
	mov	eax, '    '
3489
	mov	eax, '    '
3477
	stosd
3490
	stosd
3478
	call	disasm_readrmop
3491
	call	disasm_readrmop
3479
	mov	ax, ', '
3492
	mov	ax, ', '
3480
	stosw
3493
	stosw
3481
	jmp	disasm_i8u
3494
	jmp	disasm_i8u
3482
 
3495
 
3483
 
3496
 
3484
cmov3:
3497
cmov3:
3485
; A0: mov al,[ofs32]
3498
; A0: mov al,[ofs32]
3486
; A1: mov ax/eax,[ofs32]
3499
; A1: mov ax/eax,[ofs32]
3487
; A2: mov [ofs32],al
3500
; A2: mov [ofs32],al
3488
; A3: mov [ofs32],ax/eax
3501
; A3: mov [ofs32],ax/eax
3489
	mov	edx, 'mov '
3502
	mov	edx, 'mov '
3490
	xchg	eax, edx
3503
	xchg	eax, edx
3491
	stosd
3504
	stosd
3492
	mov	eax, '    '
3505
	mov	eax, '    '
3493
	stosd
3506
	stosd
3494
	test	dl, 2
3507
	test	dl, 2
3495
	jnz	.1
3508
	jnz	.1
3496
	call	.write_acc
3509
	call	.write_acc
3497
	mov	ax, ', '
3510
	mov	ax, ', '
3498
	stosw
3511
	stosw
3499
	call	.write_ofs32
3512
	call	.write_ofs32
3500
	jmp	.2
3513
	jmp	.2
3501
.1:
3514
.1:
3502
	call	.write_ofs32
3515
	call	.write_ofs32
3503
	mov	ax, ', '
3516
	mov	ax, ', '
3504
	stosw
3517
	stosw
3505
	call	.write_acc
3518
	call	.write_acc
3506
.2:	and	byte [edi], 0
3519
.2:	and	byte [edi], 0
3507
	ret
3520
	ret
3508
.write_acc:
3521
.write_acc:
3509
	test	dl, 1
3522
	test	dl, 1
3510
	jz	.8bit
3523
	jz	.8bit
3511
	test	ch, 1
3524
	test	ch, 1
3512
	jnz	.16bit
3525
	jnz	.16bit
3513
	mov	eax, 'eax'
3526
	mov	eax, 'eax'
3514
	stosd
3527
	stosd
3515
	dec	edi
3528
	dec	edi
3516
	ret
3529
	ret
3517
.16bit:
3530
.16bit:
3518
	mov	ax, 'ax'
3531
	mov	ax, 'ax'
3519
	stosw
3532
	stosw
3520
	ret
3533
	ret
3521
.8bit:
3534
.8bit:
3522
	mov	ax, 'al'
3535
	mov	ax, 'al'
3523
	stosw
3536
	stosw
3524
	ret
3537
	ret
3525
.write_ofs32:
3538
.write_ofs32:
3526
	mov	al, '['
3539
	mov	al, '['
3527
	stosb
3540
	stosb
3528
	call	disasm_get_dword
3541
	call	disasm_get_dword
3529
	call	disasm_write_num
3542
	call	disasm_write_num
3530
	mov	al, ']'
3543
	mov	al, ']'
3531
	stosb
3544
	stosb
3532
	ret
3545
	ret
3533
 
3546
 
3534
disasm_write_reg:
3547
disasm_write_reg:
3535
	test	ch, 80h
3548
	test	ch, 80h
3536
	jnz	disasm_write_reg1632
3549
	jnz	disasm_write_reg1632
3537
	mov	ax, [disasm_regs8+eax*2]
3550
	mov	ax, [disasm_regs8+eax*2]
3538
	stosw
3551
	stosw
3539
	ret
3552
	ret
3540
disasm_write_reg1632:
3553
disasm_write_reg1632:
3541
	test	ch, 1
3554
	test	ch, 1
3542
	jnz	@f
3555
	jnz	@f
3543
	mov	eax, [disasm_regs32+eax*4]
3556
	mov	eax, [disasm_regs32+eax*4]
3544
	stosd
3557
	stosd
3545
	dec	edi
3558
	dec	edi
3546
	ret
3559
	ret
3547
@@:
3560
@@:
3548
	mov	ax, [disasm_regs16+eax*2]
3561
	mov	ax, [disasm_regs16+eax*2]
3549
	stosw
3562
	stosw
3550
	ret
3563
	ret
3551
 
3564
 
3552
cmovzx:		; 0F B6/B7
3565
cmovzx:		; 0F B6/B7
3553
cmovsx:		; 0F BE/BF
3566
cmovsx:		; 0F BE/BF
3554
	mov	edx, eax
3567
	mov	edx, eax
3555
	disasm_set_modew
3568
	disasm_set_modew
3556
	mov	eax, 'movz'
3569
	mov	eax, 'movz'
3557
	cmp	dl, 0xB8
3570
	cmp	dl, 0xB8
3558
	jb	@f
3571
	jb	@f
3559
	mov	eax, 'movs'
3572
	mov	eax, 'movs'
3560
@@:
3573
@@:
3561
	stosd
3574
	stosd
3562
	mov	eax, 'x   '
3575
	mov	eax, 'x   '
3563
	stosd
3576
	stosd
3564
	call	disasm_get_byte
3577
	call	disasm_get_byte
3565
	dec	[disasm_cur_pos]
3578
	dec	[disasm_cur_pos]
3566
	shr	al, 3
3579
	shr	al, 3
3567
	and	eax, 7
3580
	and	eax, 7
3568
	call	disasm_write_reg1632
3581
	call	disasm_write_reg1632
3569
	mov	ax, ', '
3582
	mov	ax, ', '
3570
	stosw
3583
	stosw
3571
	or	ch, 1	; 2nd operand - 8 or 16 bits
3584
	or	ch, 1	; 2nd operand - 8 or 16 bits
3572
	call	disasm_readrmop
3585
	call	disasm_readrmop
3573
	and	byte [edi], 0
3586
	and	byte [edi], 0
3574
	ret
3587
	ret
3575
 
3588
 
3576
disasm_op2cmds	dd 'add ','or  ','adc ','sbb ','and ','sub ','xor ','cmp '
3589
disasm_op2cmds	dd 'add ','or  ','adc ','sbb ','and ','sub ','xor ','cmp '
3577
cop21:
3590
cop21:
3578
	disasm_set_modew
3591
	disasm_set_modew
3579
	mov	esi, 'test'
3592
	mov	esi, 'test'
3580
	cmp	al, 0A8h
3593
	cmp	al, 0A8h
3581
	jae	@f
3594
	jae	@f
3582
	shr	al, 3
3595
	shr	al, 3
3583
	and	eax, 7
3596
	and	eax, 7
3584
	mov	esi, [disasm_op2cmds+eax*4]
3597
	mov	esi, [disasm_op2cmds+eax*4]
3585
@@:
3598
@@:
3586
	xchg	eax, esi
3599
	xchg	eax, esi
3587
	stosd
3600
	stosd
3588
	mov	eax, '    '
3601
	mov	eax, '    '
3589
	stosd
3602
	stosd
3590
	test	ch, 80h
3603
	test	ch, 80h
3591
	jnz	.1632
3604
	jnz	.1632
3592
	mov	eax, 'al, '
3605
	mov	eax, 'al, '
3593
	stosd
3606
	stosd
3594
	jmp	disasm_i8u
3607
	jmp	disasm_i8u
3595
.1632:
3608
.1632:
3596
	test	ch, 1
3609
	test	ch, 1
3597
	jnz	.16
3610
	jnz	.16
3598
	mov	eax, 'eax,'
3611
	mov	eax, 'eax,'
3599
	stosd
3612
	stosd
3600
	mov	al, ' '
3613
	mov	al, ' '
3601
	stosb
3614
	stosb
3602
	call	disasm_get_dword
3615
	call	disasm_get_dword
3603
	jmp	.x
3616
	jmp	.x
3604
.16:
3617
.16:
3605
	mov	eax, 'ax, '
3618
	mov	eax, 'ax, '
3606
	stosd
3619
	stosd
3607
	xor	eax, eax
3620
	xor	eax, eax
3608
	call	disasm_get_word
3621
	call	disasm_get_word
3609
.x:
3622
.x:
3610
	call	disasm_write_num
3623
	call	disasm_write_num
3611
	and	byte [edi], 0
3624
	and	byte [edi], 0
3612
	ret
3625
	ret
3613
 
3626
 
3614
cop22:
3627
cop22:
3615
	disasm_set_modew
3628
	disasm_set_modew
3616
	or	ch, 40h
3629
	or	ch, 40h
3617
	mov	edx, eax
3630
	mov	edx, eax
3618
	mov	esi, 'lea '
3631
	mov	esi, 'lea '
3619
	cmp	al, 8Dh
3632
	cmp	al, 8Dh
3620
	jz	@f
3633
	jz	@f
3621
	mov	esi, 'imul'
3634
	mov	esi, 'imul'
3622
	cmp	al, 0xAF
3635
	cmp	al, 0xAF
3623
	jz	@f
3636
	jz	@f
3624
	mov	esi, 'mov '
3637
	mov	esi, 'mov '
3625
	cmp	al, 88h
3638
	cmp	al, 88h
3626
	jae	@f
3639
	jae	@f
3627
	mov	esi, 'xchg'
3640
	mov	esi, 'xchg'
3628
	cmp	al, 86h
3641
	cmp	al, 86h
3629
	jae	@f
3642
	jae	@f
3630
	mov	esi, 'test'
3643
	mov	esi, 'test'
3631
	cmp	al, 84h
3644
	cmp	al, 84h
3632
	jae	@f
3645
	jae	@f
3633
	shr	al, 3
3646
	shr	al, 3
3634
	and	eax, 7
3647
	and	eax, 7
3635
	mov	esi, [disasm_op2cmds+eax*4]
3648
	mov	esi, [disasm_op2cmds+eax*4]
3636
@@:
3649
@@:
3637
	xchg	eax, esi
3650
	xchg	eax, esi
3638
	stosd
3651
	stosd
3639
	mov	eax, '    '
3652
	mov	eax, '    '
3640
	stosd
3653
	stosd
3641
	call	disasm_get_byte
3654
	call	disasm_get_byte
3642
	dec	[disasm_cur_pos]
3655
	dec	[disasm_cur_pos]
3643
	shr	al, 3
3656
	shr	al, 3
3644
	and	eax, 7
3657
	and	eax, 7
3645
	cmp	dl, 0x8D
3658
	cmp	dl, 0x8D
3646
	jz	@f
3659
	jz	@f
3647
	cmp	dl, 0x86
3660
	cmp	dl, 0x86
3648
	jz	@f
3661
	jz	@f
3649
	cmp	dl, 0x87
3662
	cmp	dl, 0x87
3650
	jz	@f
3663
	jz	@f
3651
	test	dl, 2
3664
	test	dl, 2
3652
	jz	.d0
3665
	jz	.d0
3653
@@:
3666
@@:
3654
	call	disasm_write_reg
3667
	call	disasm_write_reg
3655
	mov	ax, ', '
3668
	mov	ax, ', '
3656
	stosw
3669
	stosw
3657
	call	disasm_readrmop
3670
	call	disasm_readrmop
3658
	and	byte [edi], 0
3671
	and	byte [edi], 0
3659
	ret
3672
	ret
3660
.d0:
3673
.d0:
3661
	push	eax
3674
	push	eax
3662
	call	disasm_readrmop
3675
	call	disasm_readrmop
3663
	mov	ax, ', '
3676
	mov	ax, ', '
3664
	stosw
3677
	stosw
3665
	pop	eax
3678
	pop	eax
3666
	call	disasm_write_reg
3679
	call	disasm_write_reg
3667
	and	byte [edi], 0
3680
	and	byte [edi], 0
3668
	ret
3681
	ret
3669
 
3682
 
3670
cop23:
3683
cop23:
3671
	disasm_set_modew
3684
	disasm_set_modew
3672
	xchg	eax, edx
3685
	xchg	eax, edx
3673
	call	disasm_get_byte
3686
	call	disasm_get_byte
3674
	dec	[disasm_cur_pos]
3687
	dec	[disasm_cur_pos]
3675
	shr	eax, 3
3688
	shr	eax, 3
3676
	and	eax, 7
3689
	and	eax, 7
3677
	mov	eax, [disasm_op2cmds+eax*4]
3690
	mov	eax, [disasm_op2cmds+eax*4]
3678
ctest:
3691
ctest:
3679
	stosd
3692
	stosd
3680
	mov	eax, '    '
3693
	mov	eax, '    '
3681
	stosd
3694
	stosd
3682
	call	disasm_readrmop
3695
	call	disasm_readrmop
3683
	mov	ax, ', '
3696
	mov	ax, ', '
3684
	stosw
3697
	stosw
3685
	test	ch, 80h
3698
	test	ch, 80h
3686
	jz	.i8
3699
	jz	.i8
3687
	cmp	dl, 83h
3700
	cmp	dl, 83h
3688
	jz	.i8
3701
	jz	.i8
3689
	test	ch, 1
3702
	test	ch, 1
3690
	jnz	.i16
3703
	jnz	.i16
3691
	call	disasm_get_dword
3704
	call	disasm_get_dword
3692
	jmp	.ic
3705
	jmp	.ic
3693
.i8:
3706
.i8:
3694
	xor	eax, eax
3707
	xor	eax, eax
3695
	call	disasm_get_byte
3708
	call	disasm_get_byte
3696
	cmp	dl, 83h
3709
	cmp	dl, 83h
3697
	jnz	.ic
3710
	jnz	.ic
3698
	movsx	eax, al
3711
	movsx	eax, al
3699
	jmp	.ic
3712
	jmp	.ic
3700
.i16:
3713
.i16:
3701
	xor	eax, eax
3714
	xor	eax, eax
3702
	call	disasm_get_word
3715
	call	disasm_get_word
3703
.ic:
3716
.ic:
3704
	call	disasm_write_num
3717
	call	disasm_write_num
3705
	and	byte [edi], 0
3718
	and	byte [edi], 0
3706
	ret
3719
	ret
3707
 
3720
 
3708
cbtx1:
3721
cbtx1:
3709
; btx r/m,i8 = 0F BA
3722
; btx r/m,i8 = 0F BA
3710
	or	ch, 80h
3723
	or	ch, 80h
3711
	call	disasm_get_byte
3724
	call	disasm_get_byte
3712
	dec	[disasm_cur_pos]
3725
	dec	[disasm_cur_pos]
3713
	shr	al, 3
3726
	shr	al, 3
3714
	and	eax, 7
3727
	and	eax, 7
3715
	cmp	al, 4
3728
	cmp	al, 4
3716
	jb	cunk
3729
	jb	cunk
3717
	mov	eax, [btx1codes+eax*4-4*4]
3730
	mov	eax, [btx1codes+eax*4-4*4]
3718
	stosd
3731
	stosd
3719
	mov	eax, '    '
3732
	mov	eax, '    '
3720
	stosd
3733
	stosd
3721
	call	disasm_readrmop
3734
	call	disasm_readrmop
3722
	mov	ax, ', '
3735
	mov	ax, ', '
3723
	stosw
3736
	stosw
3724
	jmp	disasm_i8u
3737
	jmp	disasm_i8u
3725
btx1codes	dd	'bt  ','bts ','btr ','btc '
3738
btx1codes	dd	'bt  ','bts ','btr ','btc '
3726
cbtx2:
3739
cbtx2:
3727
; btx r/m,r = 0F 101xx011 (A3,AB,B3,BB)
3740
; btx r/m,r = 0F 101xx011 (A3,AB,B3,BB)
3728
	shr	al, 3
3741
	shr	al, 3
3729
	and	eax, 3
3742
	and	eax, 3
3730
	mov	eax, [btx1codes+eax*4]
3743
	mov	eax, [btx1codes+eax*4]
3731
	stosd
3744
	stosd
3732
	mov	eax, '    '
3745
	mov	eax, '    '
3733
	stosd
3746
	stosd
3734
	or	ch, 0xC0
3747
	or	ch, 0xC0
3735
	call	disasm_get_byte
3748
	call	disasm_get_byte
3736
	dec	[disasm_cur_pos]
3749
	dec	[disasm_cur_pos]
3737
	shr	al, 3
3750
	shr	al, 3
3738
	and	eax, 7
3751
	and	eax, 7
3739
	push	eax
3752
	push	eax
3740
	call	disasm_readrmop
3753
	call	disasm_readrmop
3741
	mov	ax, ', '
3754
	mov	ax, ', '
3742
	stosw
3755
	stosw
3743
	pop	eax
3756
	pop	eax
3744
	call	disasm_write_reg1632
3757
	call	disasm_write_reg1632
3745
	and	byte [edi], 0
3758
	and	byte [edi], 0
3746
	ret
3759
	ret
3747
 
3760
 
3748
csetcc:
3761
csetcc:
3749
	and	eax, 0xF
3762
	and	eax, 0xF
3750
	mov	ax, [disasm_jcc_codes + eax*2]
3763
	mov	ax, [disasm_jcc_codes + eax*2]
3751
	mov	dword [edi], 'setc'
3764
	mov	dword [edi], 'setc'
3752
	add	edi, 3
3765
	add	edi, 3
3753
	stosw
3766
	stosw
3754
	mov	ax, '  '
3767
	mov	ax, '  '
3755
	stosw
3768
	stosw
3756
	stosb
3769
	stosb
3757
	call	disasm_readrmop
3770
	call	disasm_readrmop
3758
	and	byte [edi], 0
3771
	and	byte [edi], 0
3759
	ret
3772
	ret
3760
 
3773
 
3761
disasm_jcc_codes dw 'o ','no','b ','ae','z ','nz','be','a ','s ','ns','p ','np','l ','ge','le','g '
3774
disasm_jcc_codes dw 'o ','no','b ','ae','z ','nz','be','a ','s ','ns','p ','np','l ','ge','le','g '
3762
cjcc1:
3775
cjcc1:
3763
cjmp2:
3776
cjmp2:
3764
	cmp	al, 0xEB
3777
	cmp	al, 0xEB
3765
	jz	.1
3778
	jz	.1
3766
	and	eax, 0xF
3779
	and	eax, 0xF
3767
	mov	ax, [disasm_jcc_codes + eax*2]
3780
	mov	ax, [disasm_jcc_codes + eax*2]
3768
	jmp	.2
3781
	jmp	.2
3769
.1:
3782
.1:
3770
	mov	ax, 'mp'
3783
	mov	ax, 'mp'
3771
.2:
3784
.2:
3772
	mov	byte [edi], 'j'
3785
	mov	byte [edi], 'j'
3773
	inc	edi
3786
	inc	edi
3774
	stosw
3787
	stosw
3775
	mov	eax, '    '
3788
	mov	eax, '    '
3776
	stosb
3789
	stosb
3777
	stosd
3790
	stosd
3778
	call	disasm_get_byte
3791
	call	disasm_get_byte
3779
	movsx	eax, al
3792
	movsx	eax, al
3780
disasm_rva:
3793
disasm_rva:
3781
	add	eax, [disasm_cur_pos]
3794
	add	eax, [disasm_cur_pos]
3782
	call	disasm_write_num
3795
	call	disasm_write_num
3783
	and	byte [edi], 0
3796
	and	byte [edi], 0
3784
	ret
3797
	ret
3785
 
3798
 
3786
ccall1:
3799
ccall1:
3787
cjmp1:
3800
cjmp1:
3788
cjcc2:
3801
cjcc2:
3789
	mov	edx, 'call'
3802
	mov	edx, 'call'
3790
	cmp	al, 0xE8
3803
	cmp	al, 0xE8
3791
	jz	@f
3804
	jz	@f
3792
	mov	edx, 'jmp '
3805
	mov	edx, 'jmp '
3793
	cmp	al, 0xE9
3806
	cmp	al, 0xE9
3794
	jz	@f
3807
	jz	@f
3795
	mov	edx, '    '
3808
	mov	edx, '    '
3796
	and	eax, 0xF
3809
	and	eax, 0xF
3797
	mov	dx, [disasm_jcc_codes+eax*2]
3810
	mov	dx, [disasm_jcc_codes+eax*2]
3798
	shl	edx, 8
3811
	shl	edx, 8
3799
	mov	dl, 'j'
3812
	mov	dl, 'j'
3800
@@:
3813
@@:
3801
	xchg	eax, edx
3814
	xchg	eax, edx
3802
	stosd
3815
	stosd
3803
	mov	eax, '    '
3816
	mov	eax, '    '
3804
	stosd
3817
	stosd
3805
	call	disasm_get_dword
3818
	call	disasm_get_dword
3806
	jmp	disasm_rva
3819
	jmp	disasm_rva
3807
 
3820
 
3808
op11codes	dd	'test',0,'not ','neg ','mul ','imul','div ','idiv'
3821
op11codes	dd	'test',0,'not ','neg ','mul ','imul','div ','idiv'
3809
op12codes	dd	'inc ','dec ','call',0,'jmp ',0,'push',0
3822
op12codes	dd	'inc ','dec ','call',0,'jmp ',0,'push',0
3810
cop1:
3823
cop1:
3811
	disasm_set_modew
3824
	disasm_set_modew
3812
	xchg	eax, edx
3825
	xchg	eax, edx
3813
	call	disasm_get_byte
3826
	call	disasm_get_byte
3814
	dec	[disasm_cur_pos]
3827
	dec	[disasm_cur_pos]
3815
	shr	al, 3
3828
	shr	al, 3
3816
	and	eax, 7
3829
	and	eax, 7
3817
	cmp	dl, 0xFE
3830
	cmp	dl, 0xFE
3818
	jnz	@f
3831
	jnz	@f
3819
	cmp	al, 1
3832
	cmp	al, 1
3820
	ja	cunk
3833
	ja	cunk
3821
@@:
3834
@@:
3822
	and	edx, 8
3835
	and	edx, 8
3823
	add	eax, edx
3836
	add	eax, edx
3824
	mov	eax, [op11codes+eax*4]
3837
	mov	eax, [op11codes+eax*4]
3825
	test	eax, eax
3838
	test	eax, eax
3826
	jz	cunk
3839
	jz	cunk
3827
	cmp	eax, 'test'
3840
	cmp	eax, 'test'
3828
	jz	ctest
3841
	jz	ctest
3829
@@:
3842
@@:
3830
	stosd
3843
	stosd
3831
	mov	eax, '    '
3844
	mov	eax, '    '
3832
	stosd
3845
	stosd
3833
	call	disasm_readrmop
3846
	call	disasm_readrmop
3834
	and	byte [edi], 0
3847
	and	byte [edi], 0
3835
	ret
3848
	ret
3836
 
3849
 
3837
cpop2:
3850
cpop2:
3838
	or	ch, 80h
3851
	or	ch, 80h
3839
	call	disasm_get_byte
3852
	call	disasm_get_byte
3840
	dec	[disasm_cur_pos]
3853
	dec	[disasm_cur_pos]
3841
	test	al, 00111000b
3854
	test	al, 00111000b
3842
	jnz	cunk
3855
	jnz	cunk
3843
	mov	eax, 'pop '
3856
	mov	eax, 'pop '
3844
	jmp	@b
3857
	jmp	@b
3845
 
3858
 
3846
cloopnz:
3859
cloopnz:
3847
	mov	eax, 'loop'
3860
	mov	eax, 'loop'
3848
	stosd
3861
	stosd
3849
	mov	eax, 'nz  '
3862
	mov	eax, 'nz  '
3850
	test	ch, 2
3863
	test	ch, 2
3851
	jz	@f
3864
	jz	@f
3852
	mov	ah, 'w'
3865
	mov	ah, 'w'
3853
@@:	jmp	cloop.cmn
3866
@@:	jmp	cloop.cmn
3854
cloopz:
3867
cloopz:
3855
	mov	eax, 'loop'
3868
	mov	eax, 'loop'
3856
	stosd
3869
	stosd
3857
	mov	eax, 'z   '
3870
	mov	eax, 'z   '
3858
	test	ch, 2
3871
	test	ch, 2
3859
	jz	@f
3872
	jz	@f
3860
	mov	eax, 'zw  '
3873
	mov	eax, 'zw  '
3861
@@:	jmp	cloop.cmn
3874
@@:	jmp	cloop.cmn
3862
 
3875
 
3863
cjcxz:
3876
cjcxz:
3864
cloop:
3877
cloop:
3865
	cmp	al, 0xE2
3878
	cmp	al, 0xE2
3866
	jz	.loop
3879
	jz	.loop
3867
	test	ch, 2
3880
	test	ch, 2
3868
	jnz	.jcxz
3881
	jnz	.jcxz
3869
	mov	eax, 'jecx'
3882
	mov	eax, 'jecx'
3870
	stosd
3883
	stosd
3871
	mov	eax, 'z   '
3884
	mov	eax, 'z   '
3872
	jmp	.cmn
3885
	jmp	.cmn
3873
.jcxz:
3886
.jcxz:
3874
	mov	eax, 'jcxz'
3887
	mov	eax, 'jcxz'
3875
	stosd
3888
	stosd
3876
	mov	eax, '    '
3889
	mov	eax, '    '
3877
	jmp	.cmn
3890
	jmp	.cmn
3878
.loop:
3891
.loop:
3879
	mov	eax, 'loop'
3892
	mov	eax, 'loop'
3880
	stosd
3893
	stosd
3881
	mov	eax, '    '
3894
	mov	eax, '    '
3882
	test	ch, 2
3895
	test	ch, 2
3883
	jz	.cmn
3896
	jz	.cmn
3884
	mov	al, 'w'
3897
	mov	al, 'w'
3885
.cmn:
3898
.cmn:
3886
	stosd
3899
	stosd
3887
	call	disasm_get_byte
3900
	call	disasm_get_byte
3888
	movsx	eax, al
3901
	movsx	eax, al
3889
	add	eax, [disasm_cur_pos]
3902
	add	eax, [disasm_cur_pos]
3890
	test	ch, 1
3903
	test	ch, 1
3891
	jz	@f
3904
	jz	@f
3892
	and	eax, 0xFFFF
3905
	and	eax, 0xFFFF
3893
@@:
3906
@@:
3894
disasm_write_num_done:
3907
disasm_write_num_done:
3895
	call	disasm_write_num
3908
	call	disasm_write_num
3896
	and	byte [edi], 0
3909
	and	byte [edi], 0
3897
	ret
3910
	ret
3898
 
3911
 
3899
cimul1:
3912
cimul1:
3900
; imul r,r/m,i
3913
; imul r,r/m,i
3901
	or	ch, 80h		; 32bit operation
3914
	or	ch, 80h		; 32bit operation
3902
	xchg	eax, edx
3915
	xchg	eax, edx
3903
	mov	eax, 'imul'
3916
	mov	eax, 'imul'
3904
	stosd
3917
	stosd
3905
	mov	eax, '    '
3918
	mov	eax, '    '
3906
	stosd
3919
	stosd
3907
	call	disasm_get_byte
3920
	call	disasm_get_byte
3908
	dec	[disasm_cur_pos]
3921
	dec	[disasm_cur_pos]
3909
	shr	al, 3
3922
	shr	al, 3
3910
	and	eax, 7
3923
	and	eax, 7
3911
	call	disasm_write_reg1632
3924
	call	disasm_write_reg1632
3912
	mov	ax, ', '
3925
	mov	ax, ', '
3913
	stosw
3926
	stosw
3914
	call	disasm_readrmop
3927
	call	disasm_readrmop
3915
	mov	ax, ', '
3928
	mov	ax, ', '
3916
	stosw
3929
	stosw
3917
	test	ch, 1
3930
	test	ch, 1
3918
	jnz	.16
3931
	jnz	.16
3919
	cmp	dl, 0x69
3932
	cmp	dl, 0x69
3920
	jz	.op32
3933
	jz	.op32
3921
	call	disasm_get_byte
3934
	call	disasm_get_byte
3922
	movsx	eax, al
3935
	movsx	eax, al
3923
	jmp	disasm_write_num_done
3936
	jmp	disasm_write_num_done
3924
.op32:
3937
.op32:
3925
	call	disasm_get_dword
3938
	call	disasm_get_dword
3926
	jmp	disasm_write_num_done
3939
	jmp	disasm_write_num_done
3927
.16:
3940
.16:
3928
	cmp	dl, 0x69
3941
	cmp	dl, 0x69
3929
	jz	.op16
3942
	jz	.op16
3930
	call	disasm_get_byte
3943
	call	disasm_get_byte
3931
	cbw
3944
	cbw
3932
	jmp	disasm_write_num_done
3945
	jmp	disasm_write_num_done
3933
.op16:
3946
.op16:
3934
	xor	eax, eax
3947
	xor	eax, eax
3935
	call	disasm_get_word
3948
	call	disasm_get_word
3936
	jmp	disasm_write_num_done
3949
	jmp	disasm_write_num_done
3937
 
3950
 
3938
cshld:
3951
cshld:
3939
cshrd:
3952
cshrd:
3940
	mov	edx, 'shld'
3953
	mov	edx, 'shld'
3941
	test	al, 8
3954
	test	al, 8
3942
	jz	@f
3955
	jz	@f
3943
	mov	edx, 'shrd'
3956
	mov	edx, 'shrd'
3944
@@:
3957
@@:
3945
	xchg	eax, edx
3958
	xchg	eax, edx
3946
	stosd
3959
	stosd
3947
	mov	eax, '    '
3960
	mov	eax, '    '
3948
	stosd
3961
	stosd
3949
	call	disasm_get_byte
3962
	call	disasm_get_byte
3950
	dec	[disasm_cur_pos]
3963
	dec	[disasm_cur_pos]
3951
	shr	al, 3
3964
	shr	al, 3
3952
	and	eax, 7
3965
	and	eax, 7
3953
	push	eax
3966
	push	eax
3954
	or	ch, 80h
3967
	or	ch, 80h
3955
	call	disasm_readrmop
3968
	call	disasm_readrmop
3956
	mov	ax, ', '
3969
	mov	ax, ', '
3957
	stosw
3970
	stosw
3958
	pop	eax
3971
	pop	eax
3959
	call	disasm_write_reg1632
3972
	call	disasm_write_reg1632
3960
	mov	ax, ', '
3973
	mov	ax, ', '
3961
	stosw
3974
	stosw
3962
	test	dl, 1
3975
	test	dl, 1
3963
	jz	disasm_i8u
3976
	jz	disasm_i8u
3964
	mov	ax, 'cl'
3977
	mov	ax, 'cl'
3965
	stosw
3978
	stosw
3966
	and	byte [edi], 0
3979
	and	byte [edi], 0
3967
	ret
3980
	ret
3968
 
3981
 
3969
ccbw:
3982
ccbw:
3970
	mov	eax, 'cbw '
3983
	mov	eax, 'cbw '
3971
	test	ch, 1
3984
	test	ch, 1
3972
	jnz	@f
3985
	jnz	@f
3973
	mov	eax, 'cwde'
3986
	mov	eax, 'cwde'
3974
@@:	stosd
3987
@@:	stosd
3975
	and	byte [edi+1], 0
3988
	and	byte [edi+1], 0
3976
	ret
3989
	ret
3977
ccwd:
3990
ccwd:
3978
	mov	eax, 'cwd '
3991
	mov	eax, 'cwd '
3979
	test	ch, 1
3992
	test	ch, 1
3980
	jnz	@b
3993
	jnz	@b
3981
	mov	eax, 'cdq '
3994
	mov	eax, 'cdq '
3982
	jmp	@b
3995
	jmp	@b
3983
 
3996
 
3984
fpuD8	dd	'add ','mul ','com ','comp','sub ','subr','div ','divr'
3997
fpuD8	dd	'add ','mul ','com ','comp','sub ','subr','div ','divr'
3985
 
3998
 
3986
cD8:
3999
cD8:
3987
	call	disasm_get_byte
4000
	call	disasm_get_byte
3988
	dec	[disasm_cur_pos]
4001
	dec	[disasm_cur_pos]
3989
	push	eax
4002
	push	eax
3990
	shr	al, 3
4003
	shr	al, 3
3991
	and	eax, 7
4004
	and	eax, 7
3992
	mov	byte [edi], 'f'
4005
	mov	byte [edi], 'f'
3993
	inc	edi
4006
	inc	edi
3994
	xchg	eax, edx
4007
	xchg	eax, edx
3995
	mov	eax, [fpuD8+edx*4]
4008
	mov	eax, [fpuD8+edx*4]
3996
	stosd
4009
	stosd
3997
	mov	ax, '  '
4010
	mov	ax, '  '
3998
	stosw
4011
	stosw
3999
	stosb
4012
	stosb
4000
	pop	eax
4013
	pop	eax
4001
	cmp	dl, 2
4014
	cmp	dl, 2
4002
	jb	.1
4015
	jb	.1
4003
	cmp	dl, 3
4016
	cmp	dl, 3
4004
	jbe	.2
4017
	jbe	.2
4005
.1:
4018
.1:
4006
	cmp	al, 0xC0
4019
	cmp	al, 0xC0
4007
	jb	.2
4020
	jb	.2
4008
	mov	eax, 'st0,'
4021
	mov	eax, 'st0,'
4009
	stosd
4022
	stosd
4010
	mov	al, ' '
4023
	mov	al, ' '
4011
	stosb
4024
	stosb
4012
.2:
4025
.2:
4013
	or	ch, 80h or 20h
4026
	or	ch, 80h or 20h
4014
	and	ch, not 1
4027
	and	ch, not 1
4015
	call	disasm_readrmop
4028
	call	disasm_readrmop
4016
	and	byte [edi], 0
4029
	and	byte [edi], 0
4017
	ret
4030
	ret
4018
 
4031
 
4019
fpuD9_2:
4032
fpuD9_2:
4020
	dq	'fchs    ','fabs    ',0,0,'ftst    ','fxam    ',0,0
4033
	dq	'fchs    ','fabs    ',0,0,'ftst    ','fxam    ',0,0
4021
	db	'fld1    fldl2t  fldl2e  fldpi   fldlg2  fldln2  fldz    '
4034
	db	'fld1    fldl2t  fldl2e  fldpi   fldlg2  fldln2  fldz    '
4022
	dq	0
4035
	dq	0
4023
	db	'f2xm1   fyl2x   fptan   fpatan  fxtract fprem1  fdecstp fincstp '
4036
	db	'f2xm1   fyl2x   fptan   fpatan  fxtract fprem1  fdecstp fincstp '
4024
	db	'fprem   fyl2xp1 fsqrt   fsincos frndint fscale  fsin    fcos    '
4037
	db	'fprem   fyl2xp1 fsqrt   fsincos frndint fscale  fsin    fcos    '
4025
fpuD9_fnop	db	'fnop    '
4038
fpuD9_fnop	db	'fnop    '
4026
cD9:
4039
cD9:
4027
	call	disasm_get_byte
4040
	call	disasm_get_byte
4028
	sub	al, 0xC0
4041
	sub	al, 0xC0
4029
	jae	.l1
4042
	jae	.l1
4030
	dec	[disasm_cur_pos]
4043
	dec	[disasm_cur_pos]
4031
	shr	al, 3
4044
	shr	al, 3
4032
	and	eax, 7
4045
	and	eax, 7
4033
	cmp	al, 7
4046
	cmp	al, 7
4034
	jnz	@f
4047
	jnz	@f
4035
	mov	eax, 'fnst'
4048
	mov	eax, 'fnst'
4036
	stosd
4049
	stosd
4037
	mov	eax, 'cw  '
4050
	mov	eax, 'cw  '
4038
	jmp	.x1
4051
	jmp	.x1
4039
@@:
4052
@@:
4040
	cmp	al, 5
4053
	cmp	al, 5
4041
	jnz	@f
4054
	jnz	@f
4042
	mov	eax, 'fldc'
4055
	mov	eax, 'fldc'
4043
	stosd
4056
	stosd
4044
	mov	eax, 'w   '
4057
	mov	eax, 'w   '
4045
.x1:
4058
.x1:
4046
	stosd
4059
	stosd
4047
	or	ch, 0C1h
4060
	or	ch, 0C1h
4048
	jmp	.cmn
4061
	jmp	.cmn
4049
@@:
4062
@@:
4050
	mov	edx, 'fld '
4063
	mov	edx, 'fld '
4051
	test	al, al
4064
	test	al, al
4052
	jz	@f
4065
	jz	@f
4053
	mov	edx, 'fst '
4066
	mov	edx, 'fst '
4054
	cmp	al, 2
4067
	cmp	al, 2
4055
	jz	@f
4068
	jz	@f
4056
	mov	edx, 'fstp'
4069
	mov	edx, 'fstp'
4057
	cmp	al, 3
4070
	cmp	al, 3
4058
	jnz	cunk
4071
	jnz	cunk
4059
@@:
4072
@@:
4060
	xchg	eax, edx
4073
	xchg	eax, edx
4061
	stosd
4074
	stosd
4062
	mov	eax, '    '
4075
	mov	eax, '    '
4063
	stosd
4076
	stosd
4064
	or	ch, 80h
4077
	or	ch, 80h
4065
	and	ch, not 1
4078
	and	ch, not 1
4066
.cmn:
4079
.cmn:
4067
	call	disasm_readrmop
4080
	call	disasm_readrmop
4068
	and	byte [edi], 0
4081
	and	byte [edi], 0
4069
	ret
4082
	ret
4070
.l1:
4083
.l1:
4071
	cmp	al, 10h
4084
	cmp	al, 10h
4072
	jae	.l2
4085
	jae	.l2
4073
	mov	edx, 'fld '
4086
	mov	edx, 'fld '
4074
	cmp	al, 8
4087
	cmp	al, 8
4075
	jb	@f
4088
	jb	@f
4076
	mov	edx, 'fxch'
4089
	mov	edx, 'fxch'
4077
@@:
4090
@@:
4078
	xchg	eax, edx
4091
	xchg	eax, edx
4079
	stosd
4092
	stosd
4080
	mov	eax, '    '
4093
	mov	eax, '    '
4081
	stosd
4094
	stosd
4082
	xchg	eax, edx
4095
	xchg	eax, edx
4083
	and	al, 7
4096
	and	al, 7
4084
	add	al, '0'
4097
	add	al, '0'
4085
	shl	eax, 16
4098
	shl	eax, 16
4086
	mov	ax, 'st'
4099
	mov	ax, 'st'
4087
	stosd
4100
	stosd
4088
	clc
4101
	clc
4089
	ret
4102
	ret
4090
.l2:
4103
.l2:
4091
	cmp	al, 0x10
4104
	cmp	al, 0x10
4092
	jnz	@f
4105
	jnz	@f
4093
	mov	esi, fpuD9_fnop
4106
	mov	esi, fpuD9_fnop
4094
	jmp	.l3
4107
	jmp	.l3
4095
@@:
4108
@@:
4096
	sub	al, 0x20
4109
	sub	al, 0x20
4097
	jb	cerr
4110
	jb	cerr
4098
	lea	esi, [fpuD9_2+eax*8]
4111
	lea	esi, [fpuD9_2+eax*8]
4099
	cmp	byte [esi], 0
4112
	cmp	byte [esi], 0
4100
	jz	cerr
4113
	jz	cerr
4101
.l3:
4114
.l3:
4102
	movsd
4115
	movsd
4103
	movsd
4116
	movsd
4104
	and	byte [edi-1], 0
4117
	and	byte [edi-1], 0
4105
	ret
4118
	ret
4106
 
4119
 
4107
cDA:
4120
cDA:
4108
	call	disasm_get_byte
4121
	call	disasm_get_byte
4109
	cmp	al, 0xC0
4122
	cmp	al, 0xC0
4110
	jae	cunk
4123
	jae	cunk
4111
	dec	[disasm_cur_pos]
4124
	dec	[disasm_cur_pos]
4112
	shr	al, 3
4125
	shr	al, 3
4113
	and	eax, 7
4126
	and	eax, 7
4114
	mov	word [edi], 'fi'
4127
	mov	word [edi], 'fi'
4115
	inc	edi
4128
	inc	edi
4116
	inc	edi
4129
	inc	edi
4117
	mov	eax, [fpuD8+eax*4]
4130
	mov	eax, [fpuD8+eax*4]
4118
	stosd
4131
	stosd
4119
	mov	ax, '  '
4132
	mov	ax, '  '
4120
	stosw
4133
	stosw
4121
	or	ch, 80h
4134
	or	ch, 80h
4122
	and	ch, not 1	; 32-bit operand
4135
	and	ch, not 1	; 32-bit operand
4123
	call	disasm_readrmop
4136
	call	disasm_readrmop
4124
	and	byte [edi], 0
4137
	and	byte [edi], 0
4125
	ret
4138
	ret
4126
 
4139
 
4127
fpuDB	dd	'ild ',0,'ist ','istp',0,'ld  ',0,'stp '
4140
fpuDB	dd	'ild ',0,'ist ','istp',0,'ld  ',0,'stp '
4128
cDB:
4141
cDB:
4129
	call	disasm_get_byte
4142
	call	disasm_get_byte
4130
	cmp	al, 0xC0
4143
	cmp	al, 0xC0
4131
	jae	.1
4144
	jae	.1
4132
	dec	[disasm_cur_pos]
4145
	dec	[disasm_cur_pos]
4133
	shr	al, 3
4146
	shr	al, 3
4134
	and	eax, 7
4147
	and	eax, 7
4135
	xchg	eax, edx
4148
	xchg	eax, edx
4136
	mov	eax, [fpuDB+edx*4]
4149
	mov	eax, [fpuDB+edx*4]
4137
	test	eax, eax
4150
	test	eax, eax
4138
	jz	cerr
4151
	jz	cerr
4139
	mov	byte [edi], 'f'
4152
	mov	byte [edi], 'f'
4140
	inc	edi
4153
	inc	edi
4141
	stosd
4154
	stosd
4142
	mov	ax, '  '
4155
	mov	ax, '  '
4143
	stosw
4156
	stosw
4144
	stosb
4157
	stosb
4145
	or	ch, 80h
4158
	or	ch, 80h
4146
	and	ch, not 1	; 32-bit operand
4159
	and	ch, not 1	; 32-bit operand
4147
	cmp	dl, 4
4160
	cmp	dl, 4
4148
	jb	@f
4161
	jb	@f
4149
	or	ch, 20h
4162
	or	ch, 20h
4150
	and	ch, not 80h	; 80-bit operand
4163
	and	ch, not 80h	; 80-bit operand
4151
@@:
4164
@@:
4152
	call	disasm_readrmop
4165
	call	disasm_readrmop
4153
	and	byte [edi], 0
4166
	and	byte [edi], 0
4154
	ret
4167
	ret
4155
.1:
4168
.1:
4156
	cmp	al, 0xE3
4169
	cmp	al, 0xE3
4157
	jnz	cunk
4170
	jnz	cunk
4158
	mov	eax, 'fnin'
4171
	mov	eax, 'fnin'
4159
	stosd
4172
	stosd
4160
	mov	eax, 'it'
4173
	mov	eax, 'it'
4161
	stosd
4174
	stosd
4162
	dec	edi
4175
	dec	edi
4163
	ret		; CF cleared
4176
	ret		; CF cleared
4164
 
4177
 
4165
fpuDC	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
4178
fpuDC	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
4166
cDC:
4179
cDC:
4167
	call	disasm_get_byte
4180
	call	disasm_get_byte
4168
	cmp	al, 0xC0
4181
	cmp	al, 0xC0
4169
	jae	.1
4182
	jae	.1
4170
	dec	[disasm_cur_pos]
4183
	dec	[disasm_cur_pos]
4171
	shr	al, 3
4184
	shr	al, 3
4172
	and	eax, 7
4185
	and	eax, 7
4173
	mov	byte [edi], 'f'
4186
	mov	byte [edi], 'f'
4174
	inc	edi
4187
	inc	edi
4175
	mov	eax, [fpuD8+eax*4]
4188
	mov	eax, [fpuD8+eax*4]
4176
	stosd
4189
	stosd
4177
	mov	ax, '  '
4190
	mov	ax, '  '
4178
	stosw
4191
	stosw
4179
	stosb
4192
	stosb
4180
	or	ch, 0A1h	; qword
4193
	or	ch, 0A1h	; qword
4181
	call	disasm_readrmop
4194
	call	disasm_readrmop
4182
	and	byte [edi], 0
4195
	and	byte [edi], 0
4183
	ret
4196
	ret
4184
.1:
4197
.1:
4185
	mov	dl, al
4198
	mov	dl, al
4186
	shr	al, 3
4199
	shr	al, 3
4187
	and	eax, 7
4200
	and	eax, 7
4188
	mov	eax, [fpuDC+eax*4]
4201
	mov	eax, [fpuDC+eax*4]
4189
	test	eax, eax
4202
	test	eax, eax
4190
	jz	cerr
4203
	jz	cerr
4191
	mov	byte [edi], 'f'
4204
	mov	byte [edi], 'f'
4192
	inc	edi
4205
	inc	edi
4193
	stosd
4206
	stosd
4194
	mov	eax, '   s'
4207
	mov	eax, '   s'
4195
	stosd
4208
	stosd
4196
	mov	al, 't'
4209
	mov	al, 't'
4197
	stosb
4210
	stosb
4198
	and	edx, 7
4211
	and	edx, 7
4199
	lea	eax, [edx+'0']
4212
	lea	eax, [edx+'0']
4200
	stosb
4213
	stosb
4201
	mov	eax, ', st'
4214
	mov	eax, ', st'
4202
	stosd
4215
	stosd
4203
	mov	ax, '0'
4216
	mov	ax, '0'
4204
	stosw
4217
	stosw
4205
	ret	; CF cleared
4218
	ret	; CF cleared
4206
 
4219
 
4207
fpuDD	dd	'fld ',0,'fst ','fstp',0,0,0,0
4220
fpuDD	dd	'fld ',0,'fst ','fstp',0,0,0,0
4208
fpuDD_2	dq	'ffree   ',0,'fst     ','fstp    ','fucom   ','fucomp  ',0,0
4221
fpuDD_2	dq	'ffree   ',0,'fst     ','fstp    ','fucom   ','fucomp  ',0,0
4209
cDD:
4222
cDD:
4210
	call	disasm_get_byte
4223
	call	disasm_get_byte
4211
	cmp	al, 0xC0
4224
	cmp	al, 0xC0
4212
	jae	.1
4225
	jae	.1
4213
	dec	[disasm_cur_pos]
4226
	dec	[disasm_cur_pos]
4214
	shr	al, 3
4227
	shr	al, 3
4215
	and	eax, 7
4228
	and	eax, 7
4216
	xchg	eax, edx
4229
	xchg	eax, edx
4217
	mov	eax, [fpuDD+edx*4]
4230
	mov	eax, [fpuDD+edx*4]
4218
	test	eax, eax
4231
	test	eax, eax
4219
	jz	cunk
4232
	jz	cunk
4220
	stosd
4233
	stosd
4221
	mov	eax, '    '
4234
	mov	eax, '    '
4222
	stosd
4235
	stosd
4223
	or	ch, 0A1h	; qword operand
4236
	or	ch, 0A1h	; qword operand
4224
	call	disasm_readrmop
4237
	call	disasm_readrmop
4225
	and	byte [edi], 0
4238
	and	byte [edi], 0
4226
	ret
4239
	ret
4227
.1:
4240
.1:
4228
	push	eax
4241
	push	eax
4229
	shr	al, 3
4242
	shr	al, 3
4230
	and	eax, 7
4243
	and	eax, 7
4231
	xchg	eax, edx
4244
	xchg	eax, edx
4232
	mov	eax, dword [fpuDD_2+edx*8]
4245
	mov	eax, dword [fpuDD_2+edx*8]
4233
	test	eax, eax
4246
	test	eax, eax
4234
	jz	cerr
4247
	jz	cerr
4235
	stosd
4248
	stosd
4236
	mov	eax, dword [fpuDD_2+4+edx*8]
4249
	mov	eax, dword [fpuDD_2+4+edx*8]
4237
	stosd
4250
	stosd
4238
	mov	ax, 'st'
4251
	mov	ax, 'st'
4239
	stosw
4252
	stosw
4240
	pop	eax
4253
	pop	eax
4241
	and	al, 7
4254
	and	al, 7
4242
	add	al, '0'
4255
	add	al, '0'
4243
	stosb
4256
	stosb
4244
	and	byte [edi], 0
4257
	and	byte [edi], 0
4245
	ret
4258
	ret
4246
 
4259
 
4247
fpuDE	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
4260
fpuDE	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
4248
cDE:
4261
cDE:
4249
	call	disasm_get_byte
4262
	call	disasm_get_byte
4250
	cmp	al, 0xC0
4263
	cmp	al, 0xC0
4251
	jae	.1
4264
	jae	.1
4252
	dec	[disasm_cur_pos]
4265
	dec	[disasm_cur_pos]
4253
	mov	word [edi], 'fi'
4266
	mov	word [edi], 'fi'
4254
	inc	edi
4267
	inc	edi
4255
	inc	edi
4268
	inc	edi
4256
	shr	al, 3
4269
	shr	al, 3
4257
	and	eax, 7
4270
	and	eax, 7
4258
	mov	eax, [fpuD8+eax*4]
4271
	mov	eax, [fpuD8+eax*4]
4259
	stosd
4272
	stosd
4260
	mov	ax, '  '
4273
	mov	ax, '  '
4261
	stosw
4274
	stosw
4262
	or	ch, 81h		; force 16-bit
4275
	or	ch, 81h		; force 16-bit
4263
	call	disasm_readrmop
4276
	call	disasm_readrmop
4264
	and	byte [edi], 0
4277
	and	byte [edi], 0
4265
	ret
4278
	ret
4266
.1:
4279
.1:
4267
	push	eax
4280
	push	eax
4268
	shr	al, 3
4281
	shr	al, 3
4269
	and	eax, 7
4282
	and	eax, 7
4270
	xchg	eax, edx
4283
	xchg	eax, edx
4271
	mov	eax, [fpuDE+edx*4]
4284
	mov	eax, [fpuDE+edx*4]
4272
	test	eax, eax
4285
	test	eax, eax
4273
	jz	.fcompp
4286
	jz	.fcompp
4274
	mov	byte [edi], 'f'
4287
	mov	byte [edi], 'f'
4275
	inc	edi
4288
	inc	edi
4276
	stosd
4289
	stosd
4277
	mov	al, 'p'
4290
	mov	al, 'p'
4278
	cmp	byte [edi-1], ' '
4291
	cmp	byte [edi-1], ' '
4279
	jnz	@f
4292
	jnz	@f
4280
	mov	byte [edi-1], al
4293
	mov	byte [edi-1], al
4281
	mov	al, ' '
4294
	mov	al, ' '
4282
@@:	stosb
4295
@@:	stosb
4283
	mov	eax, '  st'
4296
	mov	eax, '  st'
4284
	stosd
4297
	stosd
4285
	pop	eax
4298
	pop	eax
4286
	and	al, 7
4299
	and	al, 7
4287
	add	al, '0'
4300
	add	al, '0'
4288
	stosb
4301
	stosb
4289
	mov	ax, ', '
4302
	mov	ax, ', '
4290
	stosw
4303
	stosw
4291
	mov	eax, 'st0'
4304
	mov	eax, 'st0'
4292
	stosd
4305
	stosd
4293
	ret	; CF cleared
4306
	ret	; CF cleared
4294
.fcompp:
4307
.fcompp:
4295
	pop	eax
4308
	pop	eax
4296
	cmp	al, 0xD9
4309
	cmp	al, 0xD9
4297
	jnz	cerr
4310
	jnz	cerr
4298
	mov	eax, 'fcom'
4311
	mov	eax, 'fcom'
4299
	stosd
4312
	stosd
4300
	mov	ax, 'pp'
4313
	mov	ax, 'pp'
4301
	stosw
4314
	stosw
4302
	and	byte [edi], 0
4315
	and	byte [edi], 0
4303
	ret
4316
	ret
4304
 
4317
 
4305
fpuDF	dd	'ild ',0,'ist ','istp','bld ','ild ','bstp','istp'
4318
fpuDF	dd	'ild ',0,'ist ','istp','bld ','ild ','bstp','istp'
4306
 
4319
 
4307
cDF:
4320
cDF:
4308
	call	disasm_get_byte
4321
	call	disasm_get_byte
4309
	cmp	al, 0xC0
4322
	cmp	al, 0xC0
4310
	jae	.1
4323
	jae	.1
4311
	dec	[disasm_cur_pos]
4324
	dec	[disasm_cur_pos]
4312
	shr	al, 3
4325
	shr	al, 3
4313
	and	eax, 7
4326
	and	eax, 7
4314
	xchg	eax, edx
4327
	xchg	eax, edx
4315
	mov	eax, [fpuDF+edx*4]
4328
	mov	eax, [fpuDF+edx*4]
4316
	test	eax, eax
4329
	test	eax, eax
4317
	jz	cerr
4330
	jz	cerr
4318
	mov	byte [edi], 'f'
4331
	mov	byte [edi], 'f'
4319
	inc	edi
4332
	inc	edi
4320
	stosd
4333
	stosd
4321
	mov	ax, '  '
4334
	mov	ax, '  '
4322
	stosw
4335
	stosw
4323
	stosb
4336
	stosb
4324
	or	ch, 81h		; force 16-bit operand
4337
	or	ch, 81h		; force 16-bit operand
4325
	cmp	dl, 4
4338
	cmp	dl, 4
4326
	jb	@f
4339
	jb	@f
4327
	or	ch, 20h
4340
	or	ch, 20h
4328
	test	dl, 1
4341
	test	dl, 1
4329
	jnz	@f
4342
	jnz	@f
4330
	or	ch, 40h
4343
	or	ch, 40h
4331
@@:
4344
@@:
4332
	call	disasm_readrmop
4345
	call	disasm_readrmop
4333
	and	byte [edi], 0
4346
	and	byte [edi], 0
4334
	ret
4347
	ret
4335
.1:
4348
.1:
4336
	cmp	al, 0xE0
4349
	cmp	al, 0xE0
4337
	jnz	cunk
4350
	jnz	cunk
4338
	mov	eax, 'fnst'
4351
	mov	eax, 'fnst'
4339
	stosd
4352
	stosd
4340
	mov	eax, 'sw  '
4353
	mov	eax, 'sw  '
4341
	stosd
4354
	stosd
4342
	mov	ax, 'ax'
4355
	mov	ax, 'ax'
4343
	stosw
4356
	stosw
4344
	and	byte [edi], 0
4357
	and	byte [edi], 0
4345
	ret
4358
	ret
4346
 
4359
 
4347
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4360
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4348
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4361
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4349
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4362
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4350
 
4363
 
4351
caption_str db 'Kolibri Debugger',0
4364
caption_str db 'Kolibri Debugger',0
4352
caption_len = $ - caption_str
4365
caption_len = $ - caption_str
4353
begin_str db	'Kolibri Debugger, version 0.2',10
4366
begin_str db	'Kolibri Debugger, version 0.2',10
4354
	db	'Hint: type "help" for help, "quit" for quit'
4367
	db	'Hint: type "help" for help, "quit" for quit'
4355
newline	db	10,0
4368
newline	db	10,0
4356
prompt	db	'> ',0
4369
prompt	db	'> ',0
4357
 
4370
 
4358
help_groups:
4371
help_groups:
4359
	dd	aControl, 0, 0, help_control_msg
4372
	dd	aControl, 0, 0, help_control_msg
4360
	db	0
4373
	db	0
4361
	dd	aData, 0, 0, help_data_msg
4374
	dd	aData, 0, 0, help_data_msg
4362
	db	0
4375
	db	0
4363
	dd	aBreakpoints, 0, 0, help_breaks_msg
4376
	dd	aBreakpoints, 0, 0, help_breaks_msg
4364
	db	0
4377
	db	0
4365
; flags field:
4378
; flags field:
4366
; &1: command may be called without parameters
4379
; &1: command may be called without parameters
4367
; &2: command may be called with parameters
4380
; &2: command may be called with parameters
4368
; &4: command may be called without loaded program
4381
; &4: command may be called without loaded program
4369
; &8: command may be called with loaded program
4382
; &8: command may be called with loaded program
4370
commands:
4383
commands:
4371
	dd	_aH, OnHelp, HelpSyntax, HelpHelp
4384
	dd	_aH, OnHelp, HelpSyntax, HelpHelp
4372
	db	0Fh
4385
	db	0Fh
4373
	dd	aHelp, OnHelp, HelpSyntax, HelpHelp
4386
	dd	aHelp, OnHelp, HelpSyntax, HelpHelp
4374
	db	0Fh
4387
	db	0Fh
4375
	dd	aQuit, OnQuit, QuitSyntax, QuitHelp
4388
	dd	aQuit, OnQuit, QuitSyntax, QuitHelp
4376
	db	0Dh
4389
	db	0Dh
4377
	dd	aLoad, OnLoad, LoadSyntax, LoadHelp
4390
	dd	aLoad, OnLoad, LoadSyntax, LoadHelp
4378
	db	6
4391
	db	6
4379
	dd	aReload, OnReload, ReloadSyntax, ReloadHelp
4392
	dd	aReload, OnReload, ReloadSyntax, ReloadHelp
4380
	db	0Dh
4393
	db	0Dh
4381
	dd	aTerminate, OnTerminate, TerminateSyntax, TerminateHelp
4394
	dd	aTerminate, OnTerminate, TerminateSyntax, TerminateHelp
4382
	db	9
4395
	db	9
4383
	dd	aDetach, OnDetach, DetachSyntax, DetachHelp
4396
	dd	aDetach, OnDetach, DetachSyntax, DetachHelp
4384
	db	9
4397
	db	9
4385
	dd	aSuspend, OnSuspend, SuspendSyntax, SuspendHelp
4398
	dd	aSuspend, OnSuspend, SuspendSyntax, SuspendHelp
4386
	db	9
4399
	db	9
4387
	dd	aResume, OnResume, ResumeSyntax, ResumeHelp
4400
	dd	aResume, OnResume, ResumeSyntax, ResumeHelp
4388
	db	0Bh
4401
	db	0Bh
4389
	dd	aStep, OnStep, StepSyntax, StepHelp
4402
	dd	aStep, OnStep, StepSyntax, StepHelp
4390
	db	9
4403
	db	9
4391
	dd	aProceed, OnProceed, ProceedSyntax, ProceedHelp
4404
	dd	aProceed, OnProceed, ProceedSyntax, ProceedHelp
4392
	db	9
4405
	db	9
4393
	dd	aCalc, OnCalc, CalcSyntax, CalcHelp
4406
	dd	aCalc, OnCalc, CalcSyntax, CalcHelp
4394
	db	0Eh
4407
	db	0Eh
4395
	dd	aDump, OnDump, DumpSyntax, DumpHelp
4408
	dd	aDump, OnDump, DumpSyntax, DumpHelp
4396
	db	0Bh
4409
	db	0Bh
4397
	dd	aUnassemble, OnUnassemble, UnassembleSyntax, UnassembleHelp
4410
	dd	aUnassemble, OnUnassemble, UnassembleSyntax, UnassembleHelp
4398
	db	0Bh
4411
	db	0Bh
4399
	dd	aBp, OnBp, BpSyntax, BpHelp
4412
	dd	aBp, OnBp, BpSyntax, BpHelp
4400
	db	0Ah
4413
	db	0Ah
4401
	dd	aBpm, OnBpmb, BpmSyntax, BpmHelp
4414
	dd	aBpm, OnBpmb, BpmSyntax, BpmHelp
4402
	db	0Ah
4415
	db	0Ah
4403
	dd	aBpmb, OnBpmb, BpmSyntax, BpmHelp
4416
	dd	aBpmb, OnBpmb, BpmSyntax, BpmHelp
4404
	db	0Ah
4417
	db	0Ah
4405
	dd	aBpmw, OnBpmw, BpmSyntax, BpmHelp
4418
	dd	aBpmw, OnBpmw, BpmSyntax, BpmHelp
4406
	db	0Ah
4419
	db	0Ah
4407
	dd	aBpmd, OnBpmd, BpmSyntax, BpmHelp
4420
	dd	aBpmd, OnBpmd, BpmSyntax, BpmHelp
4408
	db	0Ah
4421
	db	0Ah
4409
	dd	aBl, OnBl, BlSyntax, BlHelp
4422
	dd	aBl, OnBl, BlSyntax, BlHelp
4410
	db	0Bh
4423
	db	0Bh
4411
	dd	aBc, OnBc, BcSyntax, BcHelp
4424
	dd	aBc, OnBc, BcSyntax, BcHelp
4412
	db	0Ah
4425
	db	0Ah
4413
	dd	aBd, OnBd, BdSyntax, BdHelp
4426
	dd	aBd, OnBd, BdSyntax, BdHelp
4414
	db	0Ah
4427
	db	0Ah
4415
	dd	aBe, OnBe, BeSyntax, BeHelp
4428
	dd	aBe, OnBe, BeSyntax, BeHelp
4416
	db	0Ah
4429
	db	0Ah
4417
	dd	aReg, OnReg, RSyntax, RHelp
4430
	dd	aReg, OnReg, RSyntax, RHelp
4418
	db	0Ah
4431
	db	0Ah
4419
	dd	aUnpack, OnUnpack, UnpackSyntax, UnpackHelp
4432
	dd	aUnpack, OnUnpack, UnpackSyntax, UnpackHelp
4420
	db	9
4433
	db	9
4421
	dd	0
4434
	dd	0
4422
aHelp	db	5,'help',0
4435
aHelp	db	5,'help',0
4423
_aH	db	2,'h',0
4436
_aH	db	2,'h',0
4424
HelpHelp db	'Help on specified function',10
4437
HelpHelp db	'Help on specified function',10
4425
HelpSyntax db	'Usage: h or help [group | command]',10,0
4438
HelpSyntax db	'Usage: h or help [group | command]',10,0
4426
 
4439
 
4427
help_msg db	'List of known command groups:',10
4440
help_msg db	'List of known command groups:',10
4428
	db	'"help control"     - display list of control commands',10
4441
	db	'"help control"     - display list of control commands',10
4429
	db	'"help data"        - display list of commands concerning data',10
4442
	db	'"help data"        - display list of commands concerning data',10
4430
	db	'"help breakpoints" - display list of commands concerning breakpoints',10,0
4443
	db	'"help breakpoints" - display list of commands concerning breakpoints',10,0
4431
aControl db	8,'control',0
4444
aControl db	8,'control',0
4432
help_control_msg db	'List of control commands:',10
4445
help_control_msg db	'List of control commands:',10
4433
	db	'h = help             - help',10
4446
	db	'h = help             - help',10
4434
	db	'quit                 - exit from debugger',10
4447
	db	'quit                 - exit from debugger',10
4435
	db	'load  [params] - load program for debugging',10
4448
	db	'load  [params] - load program for debugging',10
4436
	db	'reload               - reload debugging program',10
4449
	db	'reload               - reload debugging program',10
4437
	db	'terminate            - terminate loaded program',10
4450
	db	'terminate            - terminate loaded program',10
4438
	db	'detach               - detach from debugging program',10
4451
	db	'detach               - detach from debugging program',10
4439
	db	'stop                 - suspend execution of debugging program',10
4452
	db	'stop                 - suspend execution of debugging program',10
4440
	db	'g []     - go on (resume execution of debugging program)',10
4453
	db	'g []     - go on (resume execution of debugging program)',10
4441
	db	's =         - program step',10
4454
	db	's =         - program step',10
4442
	db	'p =         - program wide step',10
4455
	db	'p =         - program wide step',10
4443
	db	'unpack               - try to bypass unpacker code (heuristic)',10,0
4456
	db	'unpack               - try to bypass unpacker code (heuristic)',10,0
4444
aData	db	5,'data',0
4457
aData	db	5,'data',0
4445
help_data_msg db	'List of data commands:',10
4458
help_data_msg db	'List of data commands:',10
4446
	db	'?        - calculate value of expression',10
4459
	db	'?        - calculate value of expression',10
4447
	db	'd []     - dump data at given address',10
4460
	db	'd []     - dump data at given address',10
4448
	db	'u []     - unassemble instructions at given address',10
4461
	db	'u []     - unassemble instructions at given address',10
4449
	db	'r   or',10
4462
	db	'r   or',10
4450
	db	'r = - set register value',10,0
4463
	db	'r = - set register value',10,0
4451
aBreakpoints db 12,'breakpoints',0
4464
aBreakpoints db 12,'breakpoints',0
4452
help_breaks_msg db	'List of breakpoints commands:',10
4465
help_breaks_msg db	'List of breakpoints commands:',10
4453
	db	'bp       - set breakpoint on execution',10
4466
	db	'bp       - set breakpoint on execution',10
4454
	db	'bpm[b|w|d]   - set breakpoint on memory access',10
4467
	db	'bpm[b|w|d]   - set breakpoint on memory access',10
4455
	db	'bl []        - breakpoint(s) info',10
4468
	db	'bl []        - breakpoint(s) info',10
4456
	db	'bc ...       - clear breakpoint',10
4469
	db	'bc ...       - clear breakpoint',10
4457
	db	'bd ...       - disable breakpoint',10
4470
	db	'bd ...       - disable breakpoint',10
4458
	db	'be ...       - enable breakpoint',10,0
4471
	db	'be ...       - enable breakpoint',10,0
4459
 
4472
 
4460
aQuit	db	5,'quit',0
4473
aQuit	db	5,'quit',0
4461
QuitHelp db	'Quit from debugger',10
4474
QuitHelp db	'Quit from debugger',10
4462
QuitSyntax db	'Usage: quit',10,0
4475
QuitSyntax db	'Usage: quit',10,0
4463
 
4476
 
4464
aLoad	db	5,'load',0
4477
aLoad	db	5,'load',0
4465
LoadHelp db	'Load program for debugging',10
4478
LoadHelp db	'Load program for debugging',10
4466
LoadSyntax db	'Usage: load  [parameters]',10,0
4479
LoadSyntax db	'Usage: load  [parameters]',10,0
4467
 
4480
 
4468
aReload db	7,'reload',0
4481
aReload db	7,'reload',0
4469
ReloadHelp db	'Reload debugging program (restart debug session)',10
4482
ReloadHelp db	'Reload debugging program (restart debug session)',10
4470
ReloadSyntax db	'Usage: reload',10,0
4483
ReloadSyntax db	'Usage: reload',10,0
4471
 
4484
 
4472
aTerminate db	10,'terminate',0
4485
aTerminate db	10,'terminate',0
4473
TerminateHelp db 'Terminate debugged program',10
4486
TerminateHelp db 'Terminate debugged program',10
4474
TerminateSyntax db 'Usage: terminate',10,0
4487
TerminateSyntax db 'Usage: terminate',10,0
4475
 
4488
 
4476
aDetach	db	7,'detach',0
4489
aDetach	db	7,'detach',0
4477
DetachHelp db	'Detach from debugged program',10
4490
DetachHelp db	'Detach from debugged program',10
4478
DetachSyntax db	'Usage: detach',10,0
4491
DetachSyntax db	'Usage: detach',10,0
4479
 
4492
 
4480
aSuspend db	5,'stop',0
4493
aSuspend db	5,'stop',0
4481
SuspendHelp db	'Suspend execution of debugged program',10
4494
SuspendHelp db	'Suspend execution of debugged program',10
4482
SuspendSyntax db 'Usage: stop',10,0
4495
SuspendSyntax db 'Usage: stop',10,0
4483
 
4496
 
4484
aResume db	2,'g',0
4497
aResume db	2,'g',0
4485
ResumeHelp db	'Go (resume execution of debugged program)',10
4498
ResumeHelp db	'Go (resume execution of debugged program)',10
4486
ResumeSyntax db	'Usage: g',10
4499
ResumeSyntax db	'Usage: g',10
4487
	db	'   or: g  - wait until specified address is reached',10,0
4500
	db	'   or: g  - wait until specified address is reached',10,0
4488
 
4501
 
4489
aStep	db	2,'s',0
4502
aStep	db	2,'s',0
4490
StepHelp db	'Make step in debugged program',10
4503
StepHelp db	'Make step in debugged program',10
4491
StepSyntax db	'Usage: s',10,0
4504
StepSyntax db	'Usage: s',10,0
4492
 
4505
 
4493
aProceed db	2,'p',0
4506
aProceed db	2,'p',0
4494
ProceedHelp db	'Make wide step in debugged program (step over CALL, REPxx, LOOP)',10
4507
ProceedHelp db	'Make wide step in debugged program (step over CALL, REPxx, LOOP)',10
4495
ProceedSyntax db 'Usage: p',10,0
4508
ProceedSyntax db 'Usage: p',10,0
4496
 
4509
 
4497
aDump	db	2,'d',0
4510
aDump	db	2,'d',0
4498
DumpHelp db	'Dump data of debugged program',10
4511
DumpHelp db	'Dump data of debugged program',10
4499
DumpSyntax db	'Usage: d  - dump data at specified address',10
4512
DumpSyntax db	'Usage: d  - dump data at specified address',10
4500
	db	'   or: d              - continue current dump',10,0
4513
	db	'   or: d              - continue current dump',10,0
4501
 
4514
 
4502
aCalc	db	2,'?',0
4515
aCalc	db	2,'?',0
4503
CalcHelp db	'Calculate value of expression',10
4516
CalcHelp db	'Calculate value of expression',10
4504
CalcSyntax db	'Usage: ? ',10,0
4517
CalcSyntax db	'Usage: ? ',10,0
4505
 
4518
 
4506
aUnassemble db	2,'u',0
4519
aUnassemble db	2,'u',0
4507
UnassembleHelp db 'Unassemble',10
4520
UnassembleHelp db 'Unassemble',10
4508
UnassembleSyntax:
4521
UnassembleSyntax:
4509
	db	'Usage: u  - unassemble instructions at specified address',10
4522
	db	'Usage: u  - unassemble instructions at specified address',10
4510
	db	'   or: u              - continue current unassemble screen',10,0
4523
	db	'   or: u              - continue current unassemble screen',10,0
4511
 
4524
 
4512
aReg	db	2,'r',0
4525
aReg	db	2,'r',0
4513
RHelp	db	'Set register value',10
4526
RHelp	db	'Set register value',10
4514
RSyntax:
4527
RSyntax:
4515
	db	'Usage: r  ',10
4528
	db	'Usage: r  ',10
4516
	db	'   or: r = - set value of  to ',10,0
4529
	db	'   or: r = - set value of  to ',10,0
4517
 
4530
 
4518
aBp	db	3,'bp',0
4531
aBp	db	3,'bp',0
4519
BpHelp	db	'set BreakPoint on execution',10
4532
BpHelp	db	'set BreakPoint on execution',10
4520
BpSyntax db	'Usage: bp ',10,0
4533
BpSyntax db	'Usage: bp ',10,0
4521
 
4534
 
4522
aBpm	db	4,'bpm',0
4535
aBpm	db	4,'bpm',0
4523
aBpmb	db	5,'bpmb',0
4536
aBpmb	db	5,'bpmb',0
4524
aBpmw	db	5,'bpmw',0
4537
aBpmw	db	5,'bpmw',0
4525
aBpmd	db	5,'bpmd',0
4538
aBpmd	db	5,'bpmd',0
4526
BpmHelp	db	'set BreakPoint on Memory access',10
4539
BpmHelp	db	'set BreakPoint on Memory access',10
4527
	db	'Maximum 4 breakpoints of this type are allowed',10
4540
	db	'Maximum 4 breakpoints of this type are allowed',10
4528
	db	'Note that for this breaks debugger is activated after access',10
4541
	db	'Note that for this breaks debugger is activated after access',10
4529
BpmSyntax db	'Usage: bpmb [w] ',10
4542
BpmSyntax db	'Usage: bpmb [w] ',10
4530
	db	'       bpmw [w] ',10
4543
	db	'       bpmw [w] ',10
4531
	db	'       bpmd [w] ',10
4544
	db	'       bpmd [w] ',10
4532
	db	'       bpm is synonym for bpmd',10
4545
	db	'       bpm is synonym for bpmd',10
4533
	db	'"w" means break only on writes (default is on read/write)',10,0
4546
	db	'"w" means break only on writes (default is on read/write)',10,0
4534
 
4547
 
4535
aBl	db	3,'bl',0
4548
aBl	db	3,'bl',0
4536
BlHelp	db	'Breakpoint List',10
4549
BlHelp	db	'Breakpoint List',10
4537
BlSyntax db	'Usage: bl          - list all breakpoints',10
4550
BlSyntax db	'Usage: bl          - list all breakpoints',10
4538
	db	'       bl  - display info on particular breakpoint',10,0
4551
	db	'       bl  - display info on particular breakpoint',10,0
4539
 
4552
 
4540
aBc	db	3,'bc',0
4553
aBc	db	3,'bc',0
4541
BcHelp	db	'Breakpoint Clear',10
4554
BcHelp	db	'Breakpoint Clear',10
4542
BcSyntax db	'Usage: bc ',10
4555
BcSyntax db	'Usage: bc ',10
4543
	db	'Examples: bc 2',10
4556
	db	'Examples: bc 2',10
4544
	db	'          bc 1 3 4 A',10,0
4557
	db	'          bc 1 3 4 A',10,0
4545
 
4558
 
4546
aBd	db	3,'bd',0
4559
aBd	db	3,'bd',0
4547
BdHelp	db	'Breakpoint Disable',10
4560
BdHelp	db	'Breakpoint Disable',10
4548
BdSyntax db	'Usage: bd ',10
4561
BdSyntax db	'Usage: bd ',10
4549
	db	'Examples: bd 2',10
4562
	db	'Examples: bd 2',10
4550
	db	'          bd 1 3 4 A',10,0
4563
	db	'          bd 1 3 4 A',10,0
4551
 
4564
 
4552
aBe	db	3,'be',0
4565
aBe	db	3,'be',0
4553
BeHelp	db	'Breakpoint Enable',10
4566
BeHelp	db	'Breakpoint Enable',10
4554
BeSyntax db	'Usage: be ',10
4567
BeSyntax db	'Usage: be ',10
4555
	db	'Examples: be 2',10
4568
	db	'Examples: be 2',10
4556
	db	'          be 1 3 4 A',10,0
4569
	db	'          be 1 3 4 A',10,0
4557
 
4570
 
4558
aUnpack	db	7,'unpack',0
4571
aUnpack	db	7,'unpack',0
4559
UnpackHelp db	'Try to bypass unpacker code',10
4572
UnpackHelp db	'Try to bypass unpacker code',10
4560
UnpackSyntax db	'Usage: unpack',10,0
4573
UnpackSyntax db	'Usage: unpack',10,0
4561
 
4574
 
4562
aUnknownCommand db 'Unknown command',10,0
4575
aUnknownCommand db 'Unknown command',10,0
4563
 
4576
 
4564
load_err_msg	db	'Cannot load program. ',0
4577
load_err_msg	db	'Cannot load program. ',0
4565
unk_err_msg	db	'Unknown error code -%4X',10,0
4578
unk_err_msg	db	'Unknown error code -%4X',10,0
4566
load_err_msgs:
4579
load_err_msgs:
4567
	dd	.1, 0, .3, 0, .5, .6, 0, 0, .9, .A, 0, 0, 0, 0, 0, 0
4580
	dd	.1, 0, .3, 0, .5, .6, 0, 0, .9, .A, 0, 0, 0, 0, 0, 0
4568
	dd	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .1E, .1F, .20
4581
	dd	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .1E, .1F, .20
4569
.1		db	'HD undefined.',10,0
4582
.1		db	'HD undefined.',10,0
4570
.3		db	'Unknown FS.',10,0
4583
.3		db	'Unknown FS.',10,0
4571
.5		db	'File not found.',10,0
4584
.5		db	'File not found.',10,0
4572
.6		db	'Unexpected EOF.',10,0
4585
.6		db	'Unexpected EOF.',10,0
4573
.9		db	'FAT table corrupted.',10,0
4586
.9		db	'FAT table corrupted.',10,0
4574
.A		db	'Access denied.',10,0
4587
.A		db	'Access denied.',10,0
4575
.1E		db	'No memory.',10,0
4588
.1E		db	'No memory.',10,0
4576
.1F		db	'Not Menuet/Kolibri executable.',10,0
4589
.1F		db	'Not Menuet/Kolibri executable.',10,0
4577
.20		db	'Too many processes.',10,0
4590
.20		db	'Too many processes.',10,0
4578
load_succ_msg	db	'Program loaded successfully! PID=%4X. Use "g" to run.',10,0
4591
load_succ_msg	db	'Program loaded successfully! PID=%4X. Use "g" to run.',10,0
4579
need_debuggee	db	'No program loaded. Use "load" command.',10,0
4592
need_debuggee	db	'No program loaded. Use "load" command.',10,0
4580
aAlreadyLoaded	db	'Program is already loaded. Use "terminate" or "detach" commands',10,0
4593
aAlreadyLoaded	db	'Program is already loaded. Use "terminate" or "detach" commands',10,0
4581
terminated_msg	db	'Program terminated.',10,0
4594
terminated_msg	db	'Program terminated.',10,0
4582
aException	db	'Debugged program caused an exception %2X. '
4595
aException	db	'Debugged program caused an exception %2X. '
4583
aSuspended	db	'Suspended',10,0
4596
aSuspended	db	'Suspended',10,0
4584
aContinued	db	'Continuing',10,0
4597
aContinued	db	'Continuing',10,0
4585
aRunningErr	db	'Program is running',10,0
4598
aRunningErr	db	'Program is running',10,0
4586
read_mem_err	db	'ERROR: cannot read process memory!!!',10,0
4599
read_mem_err	db	'ERROR: cannot read process memory!!!',10,0
4587
aBreakpointLimitExceeded db 'Breakpoint limit exceeded',10,0
4600
aBreakpointLimitExceeded db 'Breakpoint limit exceeded',10,0
4588
aBreakErr	db	'Cannot activate breakpoint, it will be disabled',10,0
4601
aBreakErr	db	'Cannot activate breakpoint, it will be disabled',10,0
4589
aDuplicateBreakpoint db	'Duplicate breakpoint',10,0
4602
aDuplicateBreakpoint db	'Duplicate breakpoint',10,0
4590
aInvalidBreak	db	'Invalid breakpoint number',10,0
4603
aInvalidBreak	db	'Invalid breakpoint number',10,0
4591
OnBeErrMsg	db	'There is already enabled breakpoint on this address',10,0
4604
OnBeErrMsg	db	'There is already enabled breakpoint on this address',10,0
4592
aBreakNum	db	'%2X: at %8X',0
4605
aBreakNum	db	'%2X: at %8X',0
4593
aMemBreak1	db	'%2X: on ',0
4606
aMemBreak1	db	'%2X: on ',0
4594
aMemBreak2	db	'read from ',0
4607
aMemBreak2	db	'read from ',0
4595
aMemBreak3	db	'access of ',0
4608
aMemBreak3	db	'access of ',0
4596
aMemBreak4	db	'byte',0
4609
aMemBreak4	db	'byte',0
4597
aMemBreak5	db	'word',0
4610
aMemBreak5	db	'word',0
4598
aMemBreak6	db	'dword',0
4611
aMemBreak6	db	'dword',0
4599
aMemBreak7	db	' at %8X',0
4612
aMemBreak7	db	' at %8X',0
4600
aOneShot	db	', one-shot',0
4613
aOneShot	db	', one-shot',0
4601
aDisabled	db	', disabled',0
4614
aDisabled	db	', disabled',0
4602
aBreakStop	db	'Breakpoint #%2X',10,0
4615
aBreakStop	db	'Breakpoint #%2X',10,0
4603
aUserBreak	db	'int3 command at %8X',10,0
4616
aUserBreak	db	'int3 command at %8X',10,0
4604
;dbgmsg_str	db	'Debug message for process %4X.',10,0
4617
;dbgmsg_str	db	'Debug message for process %4X.',10,0
4605
aInvAddr	db	'Invalid address',10,0
4618
aInvAddr	db	'Invalid address',10,0
4606
NoPrgLoaded_str	db	'No program loaded'
4619
NoPrgLoaded_str	db	'No program loaded'
4607
NoPrgLoaded_len = $ - NoPrgLoaded_str
4620
NoPrgLoaded_len = $ - NoPrgLoaded_str
4608
aRunning	db	'Running'
4621
aRunning	db	'Running'
4609
aPaused		db	'Paused'
4622
aPaused		db	'Paused'
4610
aPoint		db	0x1C
4623
aPoint		db	0x1C
4611
aMinus		db	'-'
4624
aMinus		db	'-'
4612
aColon		db	':'
4625
aColon		db	':'
4613
aQuests		db	'??'
4626
aQuests		db	'??'
4614
aDots		db	'...'
4627
aDots		db	'...'
4615
aParseError	db	'Parse error',10,0
4628
aParseError	db	'Parse error',10,0
4616
aDivByZero	db	'Division by 0',10,0
4629
aDivByZero	db	'Division by 0',10,0
4617
calc_string	db	'%8X',10,0
4630
calc_string	db	'%8X',10,0
4618
aUnaligned	db	'Unaligned address',10,0
4631
aUnaligned	db	'Unaligned address',10,0
4619
aEnabledBreakErr db	'Enabled breakpoints are not allowed',10,0
4632
aEnabledBreakErr db	'Enabled breakpoints are not allowed',10,0
4620
aInterrupted	db	'Interrupted',10,0
4633
aInterrupted	db	'Interrupted',10,0
4621
aUnpacked	db	'Unpacked successful!',10,0
4634
aUnpacked	db	'Unpacked successful!',10,0
4622
aPacked1	db	'Program is probably packed with ',0
4635
aPacked1	db	'Program is probably packed with ',0
4623
aPacked2	db	'.',10,'Try to unpack automatically? [y/n]: ',0
4636
aPacked2	db	'.',10,'Try to unpack automatically? [y/n]: ',0
4624
aY_str		db	'y',10,0
4637
aY_str		db	'y',10,0
4625
aN_str		db	'n',10,0
4638
aN_str		db	'n',10,0
4626
mxp_nrv_name	db	'mxp_nrv',0
4639
mxp_nrv_name	db	'mxp_nrv',0
4627
mxp_name	db	'mxp',0
4640
mxp_name	db	'mxp',0
4628
mxp_lzo_name	db	'mxp_lzo',0
4641
mxp_lzo_name	db	'mxp_lzo',0
4629
mtappack_name	db	'mtappack',0
4642
mtappack_name	db	'mtappack',0
4630
flags		db	'CPAZSDO'
4643
flags		db	'CPAZSDO'
4631
flags_bits	db	0,2,4,6,7,10,11
4644
flags_bits	db	0,2,4,6,7,10,11
4632
regs_strs:
4645
regs_strs:
4633
	db	'EAX='
4646
	db	'EAX='
4634
	db	'EBX='
4647
	db	'EBX='
4635
	db	'ECX='
4648
	db	'ECX='
4636
	db	'EDX='
4649
	db	'EDX='
4637
	db	'ESI='
4650
	db	'ESI='
4638
	db	'EDI='
4651
	db	'EDI='
4639
	db	'EBP='
4652
	db	'EBP='
4640
	db	'ESP='
4653
	db	'ESP='
4641
	db	'EIP='
4654
	db	'EIP='
4642
	db	'EFLAGS='
4655
	db	'EFLAGS='
4643
 
4656
 
4644
debuggee_pid	dd	0
4657
debuggee_pid	dd	0
4645
bSuspended	db	0
4658
bSuspended	db	0
4646
bAfterGo	db	0
4659
bAfterGo	db	0
4647
temp_break	dd	0
4660
temp_break	dd	0
4648
 
4661
 
4649
disasm_table_1:
4662
disasm_table_1:
4650
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 0x
4663
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 0x
4651
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cF
4664
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cF
4652
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 1x
4665
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 1x
4653
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0
4666
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0
4654
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cseges,cop0		; 2x
4667
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cseges,cop0		; 2x
4655
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegcs,cop0
4668
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegcs,cop0
4656
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegss,cop0		; 3x
4669
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegss,cop0		; 3x
4657
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegds,cop0
4670
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegds,cop0
4658
	dd	cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1		; 4x
4671
	dd	cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1		; 4x
4659
	dd	cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1
4672
	dd	cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1
4660
	dd	cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1		; 5x
4673
	dd	cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1		; 5x
4661
	dd	cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1
4674
	dd	cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1
4662
	dd	cop0,  cop0,  cunk,  cunk,  csegfs,cseggs,c66,   c67		; 6x
4675
	dd	cop0,  cop0,  cunk,  cunk,  csegfs,cseggs,c66,   c67		; 6x
4663
	dd	cpush21,cimul1,cpush22,cimul1,cunk,cunk,  cunk,  cunk
4676
	dd	cpush21,cimul1,cpush22,cimul1,cunk,cunk,  cunk,  cunk
4664
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1		; 7x
4677
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1		; 7x
4665
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1
4678
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1
4666
	dd	cop23, cop23, cop23, cop23, cop22, cop22, cop22, cop22		; 8x
4679
	dd	cop23, cop23, cop23, cop23, cop22, cop22, cop22, cop22		; 8x
4667
	dd	cop22, cop22, cop22, cop22, cunk,  cop22, cunk,  cpop2
4680
	dd	cop22, cop22, cop22, cop22, cunk,  cop22, cunk,  cpop2
4668
	dd	cop0,  cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1		; 9x
4681
	dd	cop0,  cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1		; 9x
4669
	dd	ccbw,  ccwd,  cunk,  cop0,  cop0,  cop0,  cop0,  cop0
4682
	dd	ccbw,  ccwd,  cunk,  cop0,  cop0,  cop0,  cop0,  cop0
4670
	dd	cmov3, cmov3, cmov3, cmov3, cop0,  cop0,  cop0,  cop0		; Ax
4683
	dd	cmov3, cmov3, cmov3, cmov3, cop0,  cop0,  cop0,  cop0		; Ax
4671
	dd	cop21, cop21, cop0,  cop0,  cop0,  cop0,  cop0,  cop0
4684
	dd	cop21, cop21, cop0,  cop0,  cop0,  cop0,  cop0,  cop0
4672
	dd	cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11		; Bx
4685
	dd	cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11		; Bx
4673
	dd	cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12
4686
	dd	cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12
4674
	dd	cshift1,cshift1,cret2,cop0, cunk,  cunk,  cmov2, cmov2		; Cx
4687
	dd	cshift1,cshift1,cret2,cop0, cunk,  cunk,  cmov2, cmov2		; Cx
4675
	dd	center,cop0,  cunk,  cunk,  cop0,  cint,  cunk,  cunk
4688
	dd	center,cop0,  cunk,  cunk,  cop0,  cint,  cunk,  cunk
4676
	dd	cshift2,cshift2,cshift3,cshift3,caam,cunk,cunk,  cxlat		; Dx
4689
	dd	cshift2,cshift2,cshift3,cshift3,caam,cunk,cunk,  cxlat		; Dx
4677
	dd	cD8,   cD9,   cDA,   cDB,   cDC,   cDD,   cDE,   cDF
4690
	dd	cD8,   cD9,   cDA,   cDB,   cDC,   cDD,   cDE,   cDF
4678
	dd	cloopnz,cloopz,cloop,cjcxz, cunk,  cunk,  cunk,  cunk		; Ex
4691
	dd	cloopnz,cloopz,cloop,cjcxz, cunk,  cunk,  cunk,  cunk		; Ex
4679
	dd	ccall1,cjmp1, cunk,  cjmp2, cunk,  cunk,  cunk,  cunk
4692
	dd	ccall1,cjmp1, cunk,  cjmp2, cunk,  cunk,  cunk,  cunk
4680
	dd	clock, cunk,  crepnz,crep,  cunk,  cop0,  cop1,  cop1		; Fx
4693
	dd	clock, cunk,  crepnz,crep,  cunk,  cop0,  cop1,  cop1		; Fx
4681
	dd	cop0,  cop0,  cop0,  cop0,  cop0,  cop0,  cop1,  cop1
4694
	dd	cop0,  cop0,  cop0,  cop0,  cop0,  cop0,  cop1,  cop1
4682
 
4695
 
4683
disasm_table_2:
4696
disasm_table_2:
4684
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 0x
4697
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  csyscall,cunk,cunk		; 0x
4685
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4698
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4686
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 1x
4699
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 1x
4687
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4700
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4688
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 2x
4701
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 2x
4689
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4702
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4690
	dd	cunk,  crdtsc,cunk,  cunk,  csysenter,cunk,cunk, cunk		; 3x
4703
	dd	cunk,  crdtsc,cunk,  cunk,  csysenter,cunk,cunk, cunk		; 3x
4691
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4704
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4692
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 4x
4705
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 4x
4693
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4706
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4694
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 5x
4707
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 5x
4695
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4708
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4696
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 6x
4709
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 6x
4697
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4710
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4698
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 7x
4711
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 7x
4699
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4712
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4700
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2		; 8x
4713
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2		; 8x
4701
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2
4714
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2
4702
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc		; 9x
4715
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc		; 9x
4703
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc
4716
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc
4704
	dd	cunk,  cunk,  ccpuid,cbtx2, cshld, cshld, cunk,  cunk		; Ax
4717
	dd	cunk,  cunk,  ccpuid,cbtx2, cshld, cshld, cunk,  cunk		; Ax
4705
	dd	cunk,  cunk,  cunk,  cbtx2, cshrd, cshrd, cunk,  cop22
4718
	dd	cunk,  cunk,  cunk,  cbtx2, cshrd, cshrd, cunk,  cop22
4706
	dd	ccmpxchg,ccmpxchg,cunk,cbtx2,cunk, cunk,  cmovzx,cmovzx		; Bx
4719
	dd	ccmpxchg,ccmpxchg,cunk,cbtx2,cunk, cunk,  cmovzx,cmovzx		; Bx
4707
	dd	cunk,  cunk,  cbtx1, cbtx2, cbsf,  cbsr,  cmovsx,cmovsx
4720
	dd	cunk,  cunk,  cbtx1, cbtx2, cbsf,  cbsr,  cmovsx,cmovsx
4708
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  ccmpxchg8b	; Cx
4721
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  ccmpxchg8b	; Cx
4709
	dd	cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap
4722
	dd	cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap
4710
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; Dx
4723
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; Dx
4711
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4724
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4712
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; Ex
4725
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; Ex
4713
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4726
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4714
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; Fx
4727
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; Fx
4715
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4728
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
4716
 
4729
 
4717
reg_table:
4730
reg_table:
4718
	db	2,'al',0
4731
	db	2,'al',0
4719
	db	2,'cl',1
4732
	db	2,'cl',1
4720
	db	2,'dl',2
4733
	db	2,'dl',2
4721
	db	2,'bl',3
4734
	db	2,'bl',3
4722
	db	2,'ah',4
4735
	db	2,'ah',4
4723
	db	2,'ch',5
4736
	db	2,'ch',5
4724
	db	2,'dh',6
4737
	db	2,'dh',6
4725
	db	2,'bh',7
4738
	db	2,'bh',7
4726
	db	2,'ax',8
4739
	db	2,'ax',8
4727
	db	2,'cx',9
4740
	db	2,'cx',9
4728
	db	2,'dx',10
4741
	db	2,'dx',10
4729
	db	2,'bx',11
4742
	db	2,'bx',11
4730
	db	2,'sp',12
4743
	db	2,'sp',12
4731
	db	2,'bp',13
4744
	db	2,'bp',13
4732
	db	2,'si',14
4745
	db	2,'si',14
4733
	db	2,'di',15
4746
	db	2,'di',15
4734
	db	3,'eax',16
4747
	db	3,'eax',16
4735
	db	3,'ecx',17
4748
	db	3,'ecx',17
4736
	db	3,'edx',18
4749
	db	3,'edx',18
4737
	db	3,'ebx',19
4750
	db	3,'ebx',19
4738
	db	3,'esp',20
4751
	db	3,'esp',20
4739
	db	3,'ebp',21
4752
	db	3,'ebp',21
4740
	db	3,'esi',22
4753
	db	3,'esi',22
4741
	db	3,'edi',23
4754
	db	3,'edi',23
4742
	db	3,'eip',24
4755
	db	3,'eip',24
4743
	db	0
4756
	db	0
4744
 
4757
 
4745
fn70_load_block:
4758
fn70_load_block:
4746
	dd	7
4759
	dd	7
4747
	dd	1
4760
	dd	1
4748
load_params dd	0
4761
load_params dd	0
4749
	dd	0
4762
	dd	0
4750
	dd	0
4763
	dd	0
4751
i_end:
4764
i_end:
4752
loadname:
4765
loadname:
4753
	db	0
4766
	db	0
4754
	rb	255
4767
	rb	255
4755
 
4768
 
4756
prgname_ptr dd ?
4769
prgname_ptr dd ?
4757
prgname_len dd ?
4770
prgname_len dd ?
4758
 
4771
 
4759
dbgwnd		dd	?
4772
dbgwnd		dd	?
4760
 
4773
 
4761
messages	rb	messages_height*messages_width
4774
messages	rb	messages_height*messages_width
4762
messages_pos	dd	?
4775
messages_pos	dd	?
4763
 
4776
 
4764
cmdline		rb	cmdline_width+1
4777
cmdline		rb	cmdline_width+1
4765
cmdline_len	dd	?
4778
cmdline_len	dd	?
4766
cmdline_pos	dd	?
4779
cmdline_pos	dd	?
4767
curarg		dd	?
4780
curarg		dd	?
4768
 
4781
 
4769
was_temp_break	db	?
4782
was_temp_break	db	?
4770
 
4783
 
4771
dbgbufsize	dd	?
4784
dbgbufsize	dd	?
4772
dbgbuflen	dd	?
4785
dbgbuflen	dd	?
4773
dbgbuf		rb	256
4786
dbgbuf		rb	256
4774
 
4787
 
4775
needzerostart:
4788
needzerostart:
4776
 
4789
 
4777
context:
4790
context:
4778
_eip	dd	?
4791
_eip	dd	?
4779
_eflags	dd	?
4792
_eflags	dd	?
4780
_eax	dd	?
4793
_eax	dd	?
4781
_ecx	dd	?
4794
_ecx	dd	?
4782
_edx	dd	?
4795
_edx	dd	?
4783
_ebx	dd	?
4796
_ebx	dd	?
4784
_esp	dd	?
4797
_esp	dd	?
4785
_ebp	dd	?
4798
_ebp	dd	?
4786
_esi	dd	?
4799
_esi	dd	?
4787
_edi	dd	?
4800
_edi	dd	?
4788
 
4801
 
4789
oldcontext rb $-context
4802
oldcontext rb $-context
4790
 
4803
 
4791
dumpread dd	?
4804
dumpread dd	?
4792
dumppos dd	?
4805
dumppos dd	?
4793
dumpdata rb	dump_height*10h
4806
dumpdata rb	dump_height*10h
4794
 
4807
 
4795
; breakpoint structure:
4808
; breakpoint structure:
4796
; dword +0: address
4809
; dword +0: address
4797
; byte +4: flags
4810
; byte +4: flags
4798
; bit 0: 1 <=> breakpoint valid
4811
; bit 0: 1 <=> breakpoint valid
4799
; bit 1: 1 <=> breakpoint disabled
4812
; bit 1: 1 <=> breakpoint disabled
4800
; bit 2: 1 <=> one-shot breakpoint
4813
; bit 2: 1 <=> one-shot breakpoint
4801
; bit 3: 1 <=> DRx breakpoint
4814
; bit 3: 1 <=> DRx breakpoint
4802
; byte +5: overwritten byte
4815
; byte +5: overwritten byte
4803
;          for DRx breaks: flags + (index shl 6)
4816
;          for DRx breaks: flags + (index shl 6)
4804
breakpoints_n = 256
4817
breakpoints_n = 256
4805
breakpoints	rb	breakpoints_n*6
4818
breakpoints	rb	breakpoints_n*6
4806
drx_break	rd	4
4819
drx_break	rd	4
4807
 
4820
 
4808
disasm_buf_size		dd	?
4821
disasm_buf_size		dd	?
4809
 
4822
 
4810
bReload			db	?
4823
bReload			db	?
4811
 
4824
 
4812
needzeroend:
4825
needzeroend:
4813
 
4826
 
4814
disasm_buffer		rb	256
4827
disasm_buffer		rb	256
4815
disasm_start_pos	dd	?
4828
disasm_start_pos	dd	?
4816
disasm_cur_pos		dd	?
4829
disasm_cur_pos		dd	?
4817
disasm_cur_str		dd	?
4830
disasm_cur_str		dd	?
4818
disasm_string		rb	256
4831
disasm_string		rb	256
4819
 
4832
 
4820
i_param		rb	256
4833
i_param		rb	256
4821
 
4834
 
4822
; stack
4835
; stack
4823
	align	400h
4836
	align	400h
4824
	rb	400h
4837
	rb	400h
4825
used_mem:
4838
used_mem: