Subversion Repositories Kolibri OS

Rev

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

Rev 1265 Rev 1269
1
format binary
1
format binary
2
include '../../macros.inc'
2
include '../../macros.inc'
3
use32
3
use32
4
	db	'MENUET01'
4
	db	'MENUET01'
5
	dd	1
5
	dd	1
6
	dd	start
6
	dd	start
7
	dd	i_end
7
	dd	i_end
8
	dd	used_mem
8
	dd	used_mem
9
	dd	used_mem
9
	dd	used_mem
10
	dd	i_param
10
	dd	i_param
11
	dd	0
11
	dd	0
12
 
12
 
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GUI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
 
16
 
17
data_width equ 80
17
data_width equ 80
18
data_x_pos equ 12
18
data_x_pos equ 12
19
data_x_size equ data_width*6
19
data_x_size equ data_width*6
20
 
20
 
21
title_x_pos equ 30
21
title_x_pos equ 30
22
title_y_pos equ 32
22
title_y_pos equ 32
23
title_y_size equ 10
23
title_y_size equ 10
24
 
24
 
25
registers_x_pos equ data_x_pos
25
registers_x_pos equ data_x_pos
26
registers_y_pos equ (title_y_pos + title_y_size)
26
registers_y_pos equ (title_y_pos + title_y_size)
27
registers_y_size equ 30
27
registers_y_size equ 30
28
 
28
 
29
dump_y_pos equ (registers_y_pos + registers_y_size + 5)
29
dump_y_pos equ (registers_y_pos + registers_y_size + 5)
30
dump_height equ 4
30
dump_height equ 4
31
dump_y_size equ (dump_height*10)
31
dump_y_size equ (dump_height*10)
32
 
32
 
33
disasm_y_pos equ (dump_y_pos + dump_y_size + 4)
33
disasm_y_pos equ (dump_y_pos + dump_y_size + 4)
34
disasm_height equ 16
34
disasm_height equ 16
35
disasm_y_size equ (disasm_height*10)
35
disasm_y_size equ (disasm_height*10)
36
 
36
 
37
messages_width equ data_width
37
messages_width equ data_width
38
messages_height equ 12
38
messages_height equ 12
39
messages_x_pos equ data_x_pos
39
messages_x_pos equ data_x_pos
40
messages_y_pos equ (disasm_y_pos + disasm_y_size + 4)
40
messages_y_pos equ (disasm_y_pos + disasm_y_size + 4)
41
messages_x_size equ messages_width*6
41
messages_x_size equ messages_width*6
42
messages_y_size equ messages_height*10
42
messages_y_size equ messages_height*10
43
 
43
 
44
cmdline_width equ data_width
44
cmdline_width equ data_width
45
cmdline_x_pos equ data_x_pos
45
cmdline_x_pos equ data_x_pos
46
cmdline_y_pos equ (messages_y_pos + messages_y_size + 10)
46
cmdline_y_pos equ (messages_y_pos + messages_y_size + 10)
47
cmdline_x_size equ messages_x_size
47
cmdline_x_size equ messages_x_size
48
cmdline_y_size equ 10
48
cmdline_y_size equ 10
49
 
49
 
50
wnd_x_size equ (data_x_pos + messages_x_size + data_x_pos)
50
wnd_x_size equ (data_x_pos + messages_x_size + data_x_pos)
51
wnd_y_size equ (cmdline_y_pos + cmdline_y_size + data_x_pos)
51
wnd_y_size equ (cmdline_y_pos + cmdline_y_size + data_x_pos)
52
 
52
 
53
start:
53
start:
54
	mcall	68, 11
54
	mcall	68, 11
55
	mov	edi, messages
55
	mov	edi, messages
56
	mov	ecx, messages_width*messages_height
56
	mov	ecx, messages_width*messages_height
57
	mov	al, ' '
57
	mov	al, ' '
58
	rep	stosb
58
	rep	stosb
59
	xor	eax, eax
59
	xor	eax, eax
60
	mov	[messages_pos], eax
60
	mov	[messages_pos], eax
61
	mov	[cmdline_len], eax
61
	mov	[cmdline_len], eax
62
	mov	[cmdline_pos], eax
62
	mov	[cmdline_pos], eax
63
	mov	edi, needzerostart
63
	mov	edi, needzerostart
64
	mov	ecx, (needzeroend-needzerostart+3)/4
64
	mov	ecx, (needzeroend-needzerostart+3)/4
65
	rep	stosd
65
	rep	stosd
66
	mov	esi, begin_str
66
	mov	esi, begin_str
67
	call	put_message_nodraw
67
	call	put_message_nodraw
68
; set event mask - default events and debugging events
68
; set event mask - default events and debugging events
69
	push	40
69
	push	40
70
	pop	eax
70
	pop	eax
71
	mov	ebx, 0x107
71
	mov	ebx, 0x107
72
	mcall
72
	mcall
73
; set debug messages buffer
73
; set debug messages buffer
74
	mov	ecx, dbgbufsize
74
	mov	ecx, dbgbufsize
75
	mov	dword [ecx], 256
75
	mov	dword [ecx], 256
76
	xor	ebx, ebx
76
	xor	ebx, ebx
77
	mov	[ecx+4], ebx
77
	mov	[ecx+4], ebx
78
	mov	al, 69
78
	mov	al, 69
79
	mcall
79
	mcall
80
	mov	esi, i_param
80
	mov	esi, i_param
81
	call	skip_spaces
81
	call	skip_spaces
82
	test	al, al
82
	test	al, al
83
	jz	dodraw
83
	jz	dodraw
84
	push	esi
84
	push	esi
85
	call	draw_window
85
	call	draw_window
86
	pop	esi
86
	pop	esi
87
	call	OnLoadInit
87
	call	OnLoadInit
88
	jmp	waitevent
88
	jmp	waitevent
89
dodraw:
89
dodraw:
90
	call	draw_window
90
	call	draw_window
91
waitevent:
91
waitevent:
92
	push	10
92
	push	10
93
	pop	eax
93
	pop	eax
94
	mcall
94
	mcall
95
	cmp	al, 9
95
	cmp	al, 9
96
	jz	debugmsg
96
	jz	debugmsg
97
	dec	eax
97
	dec	eax
98
	jz	dodraw
98
	jz	dodraw
99
	dec	eax
99
	dec	eax
100
	jz	keypressed
100
	jz	keypressed
101
	dec	eax
101
	dec	eax
102
	jnz	waitevent
102
	jnz	waitevent
103
; button pressed - we have only one button (close)
103
; button pressed - we have only one button (close)
104
	push	-1
104
	push	-1
105
	pop	eax
105
	pop	eax
106
	mcall
106
	mcall
107
keypressed:
107
keypressed:
108
	mov	al, 2
108
	mov	al, 2
109
	mcall
109
	mcall
110
	shr	eax, 8
110
	shr	eax, 8
111
	cmp	al, 8
111
	cmp	al, 8
112
	jz	.backspace
112
	jz	.backspace
113
	cmp	al, 0xB0
113
	cmp	al, 0xB0
114
	jz	.left
114
	jz	.left
115
	cmp	al, 0xB3
115
	cmp	al, 0xB3
116
	jz	.right
116
	jz	.right
117
	cmp	al, 0x0D
117
	cmp	al, 0x0D
118
	jz	.enter
118
	jz	.enter
119
	cmp	al, 0xB6
119
	cmp	al, 0xB6
120
	jz	.del
120
	jz	.del
121
	cmp	al, 0xB4
121
	cmp	al, 0xB4
122
	jz	.home
122
	jz	.home
123
	cmp	al, 0xB5
123
	cmp	al, 0xB5
124
	jz	.end
124
	jz	.end
125
	cmp	al, 0xB1
125
	cmp	al, 0xB1
126
	jz	.down
126
	jz	.down
127
	cmp	al, 0xB2
127
	cmp	al, 0xB2
128
	jz	.up
128
	jz	.up
129
	cmp	al, 0xD8
129
	cmp	al, 0xD8
130
	jz	CtrlF7
130
	jz	CtrlF7
131
	cmp	al, 0xD9
131
	cmp	al, 0xD9
132
	jz	CtrlF8
132
	jz	CtrlF8
133
	cmp	[cmdline_len], cmdline_width
133
	cmp	[cmdline_len], cmdline_width
134
	jae	waitevent
134
	jae	waitevent
135
	push	eax
135
	push	eax
136
	call	clear_cmdline_end
136
	call	clear_cmdline_end
137
	pop	eax
137
	pop	eax
138
	mov	edi, cmdline
138
	mov	edi, cmdline
139
	mov	ecx, [cmdline_len]
139
	mov	ecx, [cmdline_len]
140
	add	edi, ecx
140
	add	edi, ecx
141
	lea	esi, [edi-1]
141
	lea	esi, [edi-1]
142
	sub	ecx, [cmdline_pos]
142
	sub	ecx, [cmdline_pos]
143
	std
143
	std
144
	rep	movsb
144
	rep	movsb
145
	cld
145
	cld
146
	stosb
146
	stosb
147
	inc	[cmdline_len]
147
	inc	[cmdline_len]
148
	call	draw_cmdline_end
148
	call	draw_cmdline_end
149
	inc	[cmdline_pos]
149
	inc	[cmdline_pos]
150
	call	draw_cursor
150
	call	draw_cursor
151
	jmp	waitevent
151
	jmp	waitevent
152
.backspace:
152
.backspace:
153
	cmp	[cmdline_pos], 0
153
	cmp	[cmdline_pos], 0
154
	jz	waitevent
154
	jz	waitevent
155
	dec	[cmdline_pos]
155
	dec	[cmdline_pos]
156
.delchar:
156
.delchar:
157
	call	clear_cmdline_end
157
	call	clear_cmdline_end
158
	mov	edi, [cmdline_pos]
158
	mov	edi, [cmdline_pos]
159
	dec	[cmdline_len]
159
	dec	[cmdline_len]
160
	mov	ecx, [cmdline_len]
160
	mov	ecx, [cmdline_len]
161
	sub	ecx, edi
161
	sub	ecx, edi
162
	add	edi, cmdline
162
	add	edi, cmdline
163
	lea	esi, [edi+1]
163
	lea	esi, [edi+1]
164
	rep	movsb
164
	rep	movsb
165
	call	draw_cmdline_end
165
	call	draw_cmdline_end
166
	call	draw_cursor
166
	call	draw_cursor
167
	jmp	waitevent
167
	jmp	waitevent
168
.del:
168
.del:
169
	mov	eax, [cmdline_pos]
169
	mov	eax, [cmdline_pos]
170
	cmp	eax, [cmdline_len]
170
	cmp	eax, [cmdline_len]
171
	jae	waitevent
171
	jae	waitevent
172
	jmp	.delchar
172
	jmp	.delchar
173
.left:
173
.left:
174
	cmp	[cmdline_pos], 0
174
	cmp	[cmdline_pos], 0
175
	jz	waitevent
175
	jz	waitevent
176
	call	hide_cursor
176
	call	hide_cursor
177
	dec	[cmdline_pos]
177
	dec	[cmdline_pos]
178
	call	draw_cursor
178
	call	draw_cursor
179
	jmp	waitevent
179
	jmp	waitevent
180
.right:
180
.right:
181
	mov	eax, [cmdline_pos]
181
	mov	eax, [cmdline_pos]
182
	cmp	eax, [cmdline_len]
182
	cmp	eax, [cmdline_len]
183
	jae	waitevent
183
	jae	waitevent
184
	call	hide_cursor
184
	call	hide_cursor
185
	inc	[cmdline_pos]
185
	inc	[cmdline_pos]
186
	call	draw_cursor
186
	call	draw_cursor
187
	jmp	waitevent
187
	jmp	waitevent
188
.home:
188
.home:
189
	call	hide_cursor
189
	call	hide_cursor
190
	and	[cmdline_pos], 0
190
	and	[cmdline_pos], 0
191
	call	draw_cursor
191
	call	draw_cursor
192
	jmp	waitevent
192
	jmp	waitevent
193
.end:
193
.end:
194
	call	hide_cursor
194
	call	hide_cursor
195
	mov	eax, [cmdline_len]
195
	mov	eax, [cmdline_len]
196
	mov	[cmdline_pos], eax
196
	mov	[cmdline_pos], eax
197
	call	draw_cursor
197
	call	draw_cursor
198
.up:
198
.up:
199
.down:
199
.down:
200
	jmp	waitevent
200
	jmp	waitevent
201
.enter:
201
.enter:
202
	mov	ecx, [cmdline_len]
202
	mov	ecx, [cmdline_len]
203
	test	ecx, ecx
203
	test	ecx, ecx
204
	jz	waitevent
204
	jz	waitevent
205
	mov	esi, cmdline
205
	mov	esi, cmdline
206
	mov	byte [esi+ecx], 0
206
	mov	byte [esi+ecx], 0
207
	and	[cmdline_pos], 0
207
	and	[cmdline_pos], 0
208
	push	esi
208
	push	esi
209
	call	clear_cmdline_end
209
	call	clear_cmdline_end
210
	call	draw_cursor
210
	call	draw_cursor
211
	pop	esi
211
	pop	esi
212
	and	[cmdline_len], 0
212
	and	[cmdline_len], 0
213
; skip leading spaces
213
; skip leading spaces
214
	call	skip_spaces
214
	call	skip_spaces
215
	cmp	al, 0
215
	cmp	al, 0
216
	jz	waitevent
216
	jz	waitevent
217
; now esi points to command
217
; now esi points to command
218
	push	esi
218
	push	esi
219
	mov	esi, prompt
219
	mov	esi, prompt
220
	call	put_message_nodraw
220
	call	put_message_nodraw
221
	pop	esi
221
	pop	esi
222
	push	esi
222
	push	esi
223
	call	put_message_nodraw
223
	call	put_message_nodraw
224
z1:	mov	esi, newline
224
z1:	mov	esi, newline
225
	call	put_message
225
	call	put_message
226
	pop	esi
226
	pop	esi
227
	push	esi
227
	push	esi
228
	call	get_arg
228
	call	get_arg
229
	mov	[curarg], esi
229
	mov	[curarg], esi
230
	pop	edi
230
	pop	edi
231
	mov	esi, commands
231
	mov	esi, commands
232
	call	find_cmd
232
	call	find_cmd
233
	mov	eax, aUnknownCommand
233
	mov	eax, aUnknownCommand
234
	jc	.x11
234
	jc	.x11
235
; check command requirements
235
; check command requirements
236
; flags field:
236
; flags field:
237
; &1: command may be called without parameters
237
; &1: command may be called without parameters
238
; &2: command may be called with parameters
238
; &2: command may be called with parameters
239
; &4: command may be called without loaded program
239
; &4: command may be called without loaded program
240
; &8: command may be called with loaded program
240
; &8: command may be called with loaded program
241
	mov	eax, [esi+8]
241
	mov	eax, [esi+8]
242
	mov	ecx, [curarg]
242
	mov	ecx, [curarg]
243
	cmp	byte [ecx], 0
243
	cmp	byte [ecx], 0
244
	jz	.noargs
244
	jz	.noargs
245
	test	byte [esi+16], 2
245
	test	byte [esi+16], 2
246
	jz	.x11
246
	jz	.x11
247
	jmp	@f
247
	jmp	@f
248
.noargs:
248
.noargs:
249
	test	byte [esi+16], 1
249
	test	byte [esi+16], 1
250
	jz	.x11
250
	jz	.x11
251
@@:
251
@@:
252
	cmp	[debuggee_pid], 0
252
	cmp	[debuggee_pid], 0
253
	jz	.nodebuggee
253
	jz	.nodebuggee
254
	mov	eax, aAlreadyLoaded
254
	mov	eax, aAlreadyLoaded
255
	test	byte [esi+16], 8
255
	test	byte [esi+16], 8
256
	jz	.x11
256
	jz	.x11
257
	jmp	.x9
257
	jmp	.x9
258
.nodebuggee:
258
.nodebuggee:
259
	mov	eax, need_debuggee
259
	mov	eax, need_debuggee
260
	test	byte [esi+16], 4
260
	test	byte [esi+16], 4
261
	jnz	.x9
261
	jnz	.x9
262
.x11:
262
.x11:
263
	xchg	esi, eax
263
	xchg	esi, eax
264
	call	put_message
264
	call	put_message
265
.x10:
265
.x10:
266
	jmp	waitevent
266
	jmp	waitevent
267
.x9:
267
.x9:
268
	call	dword [esi+4]
268
	call	dword [esi+4]
269
	jmp	.x10
269
	jmp	.x10
270
 
270
 
271
find_cmd:
271
find_cmd:
272
; all commands are case-insensitive
272
; all commands are case-insensitive
273
	push	edi
273
	push	edi
274
.x4:
274
.x4:
275
	mov	al, [edi]
275
	mov	al, [edi]
276
	cmp	al, 0
276
	cmp	al, 0
277
	jz	.x5
277
	jz	.x5
278
	cmp	al, 'A'
278
	cmp	al, 'A'
279
	jb	@f
279
	jb	@f
280
	cmp	al, 'Z'
280
	cmp	al, 'Z'
281
	ja	@f
281
	ja	@f
282
	or	al, 20h
282
	or	al, 20h
283
@@:
283
@@:
284
	stosb
284
	stosb
285
	jmp	.x4
285
	jmp	.x4
286
.x5:
286
.x5:
287
; find command
287
; find command
288
	pop	edi
288
	pop	edi
289
.x6:
289
.x6:
290
	cmp	dword [esi], 0
290
	cmp	dword [esi], 0
291
	jz	.x7
291
	jz	.x7
292
	push	esi
292
	push	esi
293
	mov	esi, [esi]
293
	mov	esi, [esi]
294
	lodsb
294
	lodsb
295
	movzx	ecx, al
295
	movzx	ecx, al
296
	push	edi
296
	push	edi
297
	repz	cmpsb
297
	repz	cmpsb
298
	pop	edi
298
	pop	edi
299
	pop	esi
299
	pop	esi
300
	jz	.x8
300
	jz	.x8
301
	add	esi, 17
301
	add	esi, 17
302
	jmp	.x6
302
	jmp	.x6
303
.x7:
303
.x7:
304
	stc
304
	stc
305
.x8:
305
.x8:
306
	ret
306
	ret
307
 
307
 
308
get_arg:
308
get_arg:
309
	lodsb
309
	lodsb
310
	cmp	al, ' '
310
	cmp	al, ' '
311
	ja	get_arg
311
	ja	get_arg
312
	mov	byte [esi-1], 0
312
	mov	byte [esi-1], 0
313
	cmp	al, 0
313
	cmp	al, 0
314
	jnz	skip_spaces
314
	jnz	skip_spaces
315
	dec	esi
315
	dec	esi
316
skip_spaces:
316
skip_spaces:
317
	lodsb
317
	lodsb
318
	cmp	al, 0
318
	cmp	al, 0
319
	jz	@f
319
	jz	@f
320
	cmp	al, ' '
320
	cmp	al, ' '
321
	jbe	skip_spaces
321
	jbe	skip_spaces
322
@@:	dec	esi
322
@@:	dec	esi
323
	ret
323
	ret
324
 
324
 
325
clear_cmdline_end:
325
clear_cmdline_end:
326
	mov	ebx, [cmdline_pos]
326
	mov	ebx, [cmdline_pos]
327
	mov	ecx, [cmdline_len]
327
	mov	ecx, [cmdline_len]
328
	sub	ecx, ebx
328
	sub	ecx, ebx
329
	push	13
329
	push	13
330
	pop	eax
330
	pop	eax
331
	imul	ebx, 6
331
	imul	ebx, 6
332
	imul	ecx, 6
332
	imul	ecx, 6
333
	inc	ecx
333
	inc	ecx
334
	add	ebx, cmdline_x_pos
334
	add	ebx, cmdline_x_pos
335
	shl	ebx, 16
335
	shl	ebx, 16
336
	or	ebx, ecx
336
	or	ebx, ecx
337
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
337
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
338
	mov	edx, 0xFFFFFF
338
	mov	edx, 0xFFFFFF
339
	mcall
339
	mcall
340
	ret
340
	ret
341
 
341
 
342
draw_cmdline:
342
draw_cmdline:
343
	xor	ebx, ebx
343
	xor	ebx, ebx
344
	jmp	@f
344
	jmp	@f
345
draw_cmdline_end:
345
draw_cmdline_end:
346
	mov	ebx, [cmdline_pos]
346
	mov	ebx, [cmdline_pos]
347
@@:
347
@@:
348
	mov	esi, [cmdline_len]
348
	mov	esi, [cmdline_len]
349
	sub	esi, ebx
349
	sub	esi, ebx
350
	push	4
350
	push	4
351
	pop	eax
351
	pop	eax
352
	xor	ecx, ecx
352
	xor	ecx, ecx
353
	lea	edx, [cmdline+ebx]
353
	lea	edx, [cmdline+ebx]
354
	imul	ebx, 6
354
	imul	ebx, 6
355
	add	ebx, cmdline_x_pos
355
	add	ebx, cmdline_x_pos
356
	shl	ebx, 16
356
	shl	ebx, 16
357
	or	ebx, cmdline_y_pos+1
357
	or	ebx, cmdline_y_pos+1
358
	mcall
358
	mcall
359
	ret
359
	ret
360
 
360
 
361
put_message_nodraw:
361
put_message_nodraw:
362
; in: esi->ASCIZ message
362
; in: esi->ASCIZ message
363
	mov	edx, [messages_pos]
363
	mov	edx, [messages_pos]
364
.m:
364
.m:
365
	lea	edi, [messages+edx]
365
	lea	edi, [messages+edx]
366
.l:
366
.l:
367
	lodsb
367
	lodsb
368
	cmp	al, 0
368
	cmp	al, 0
369
	jz	.done
369
	jz	.done
370
	call	test_scroll
370
	call	test_scroll
371
	cmp	al, 10
371
	cmp	al, 10
372
	jz	.newline
372
	jz	.newline
373
	cmp	al, '%'
373
	cmp	al, '%'
374
	jnz	@f
374
	jnz	@f
375
	cmp	dword [esp], z1
375
	cmp	dword [esp], z1
376
	jnz	.format
376
	jnz	.format
377
@@:
377
@@:
378
	stosb
378
	stosb
379
	inc	edx
379
	inc	edx
380
	jmp	.l
380
	jmp	.l
381
.newline:
381
.newline:
382
	push	edx
382
	push	edx
383
	mov	ecx, messages_width
383
	mov	ecx, messages_width
384
	xor	eax, eax
384
	xor	eax, eax
385
	xchg	eax, edx
385
	xchg	eax, edx
386
	div	ecx
386
	div	ecx
387
	xchg	eax, edx
387
	xchg	eax, edx
388
	pop	edx
388
	pop	edx
389
	test	eax, eax
389
	test	eax, eax
390
	jz	.m
390
	jz	.m
391
	sub	edx, eax
391
	sub	edx, eax
392
	add	edx, ecx
392
	add	edx, ecx
393
	jmp	.m
393
	jmp	.m
394
.done:
394
.done:
395
	mov	[messages_pos], edx
395
	mov	[messages_pos], edx
396
	ret
396
	ret
397
.format:
397
.format:
398
; at moment all format specs must be %X
398
; at moment all format specs must be %X
399
	lodsb	; get 
399
	lodsb	; get 
400
	sub	al, '0'
400
	sub	al, '0'
401
	movzx	ecx, al
401
	movzx	ecx, al
402
	lodsb
402
	lodsb
403
	pop	eax
403
	pop	eax
404
	pop	ebp
404
	pop	ebp
405
	push	eax
405
	push	eax
406
; write number in ebp with ecx digits
406
; write number in ebp with ecx digits
407
	dec	ecx
407
	dec	ecx
408
	shl	ecx, 2
408
	shl	ecx, 2
409
.writenibble:
409
.writenibble:
410
	push	ecx
410
	push	ecx
411
	call	test_scroll
411
	call	test_scroll
412
	pop	ecx
412
	pop	ecx
413
	mov	eax, ebp
413
	mov	eax, ebp
414
	shr	eax, cl
414
	shr	eax, cl
415
	and	al, 0xF
415
	and	al, 0xF
416
	cmp	al, 10
416
	cmp	al, 10
417
	sbb	al, 69h
417
	sbb	al, 69h
418
	das
418
	das
419
	stosb
419
	stosb
420
	inc	edx
420
	inc	edx
421
	sub	ecx, 4
421
	sub	ecx, 4
422
	jns	.writenibble
422
	jns	.writenibble
423
	jmp	.l
423
	jmp	.l
424
 
424
 
425
test_scroll:
425
test_scroll:
426
	cmp	edx, messages_width*messages_height
426
	cmp	edx, messages_width*messages_height
427
	jnz	.ret
427
	jnz	.ret
428
	push	esi
428
	push	esi
429
	mov	edi, messages
429
	mov	edi, messages
430
	lea	esi, [edi+messages_width]
430
	lea	esi, [edi+messages_width]
431
	mov	ecx, (messages_height-1)*messages_width/4
431
	mov	ecx, (messages_height-1)*messages_width/4
432
	rep	movsd
432
	rep	movsd
433
	push	eax
433
	push	eax
434
	mov	al, ' '
434
	mov	al, ' '
435
	push	edi
435
	push	edi
436
	push	messages_width
436
	push	messages_width
437
	pop	ecx
437
	pop	ecx
438
	sub	edx, ecx
438
	sub	edx, ecx
439
	rep	stosb
439
	rep	stosb
440
	pop	edi
440
	pop	edi
441
	pop	eax
441
	pop	eax
442
	pop	esi
442
	pop	esi
443
.ret:	ret
443
.ret:	ret
444
 
444
 
445
put_message:
445
put_message:
446
	call	put_message_nodraw
446
	call	put_message_nodraw
447
 
447
 
448
draw_messages:
448
draw_messages:
449
	push	13
449
	push	13
450
	pop	eax
450
	pop	eax
451
	mov	edx, 0xFFFFFF
451
	mov	edx, 0xFFFFFF
452
	mov	ebx, messages_x_pos*10000h+messages_x_size
452
	mov	ebx, messages_x_pos*10000h+messages_x_size
453
	mov	ecx, messages_y_pos*10000h+messages_y_size
453
	mov	ecx, messages_y_pos*10000h+messages_y_size
454
	mcall
454
	mcall
455
	mov	edx, messages
455
	mov	edx, messages
456
	push	messages_width
456
	push	messages_width
457
	pop	esi
457
	pop	esi
458
	xor	ecx, ecx
458
	xor	ecx, ecx
459
	mov	al, 4
459
	mov	al, 4
460
	mov	ebx, messages_x_pos*10000h+messages_y_pos
460
	mov	ebx, messages_x_pos*10000h+messages_y_pos
461
@@:
461
@@:
462
	mcall
462
	mcall
463
	add	edx, esi
463
	add	edx, esi
464
	add	ebx, 10
464
	add	ebx, 10
465
	cmp	edx, messages+messages_width*messages_height
465
	cmp	edx, messages+messages_width*messages_height
466
	jb	@b
466
	jb	@b
467
	ret
467
	ret
468
 
468
 
469
draw_cursor:
469
draw_cursor:
470
	push	38
470
	push	38
471
	pop	eax
471
	pop	eax
472
	mov	ecx, cmdline_y_pos*10001h+cmdline_y_size-1
472
	mov	ecx, cmdline_y_pos*10001h+cmdline_y_size-1
473
	mov	ebx, [cmdline_pos]
473
	mov	ebx, [cmdline_pos]
474
	imul	ebx, 6
474
	imul	ebx, 6
475
	add	ebx, cmdline_x_pos
475
	add	ebx, cmdline_x_pos
476
	mov	edx, ebx
476
	mov	edx, ebx
477
	shl	ebx, 16
477
	shl	ebx, 16
478
	or	ebx, edx
478
	or	ebx, edx
479
	xor	edx, edx
479
	xor	edx, edx
480
	mcall
480
	mcall
481
	ret
481
	ret
482
hide_cursor:
482
hide_cursor:
483
	mov	ebx, [cmdline_pos]
483
	mov	ebx, [cmdline_pos]
484
	push	13
484
	push	13
485
	pop	eax
485
	pop	eax
486
	imul	ebx, 6
486
	imul	ebx, 6
487
	add	ebx, cmdline_x_pos
487
	add	ebx, cmdline_x_pos
488
	shl	ebx, 16
488
	shl	ebx, 16
489
	inc	ebx
489
	inc	ebx
490
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
490
	mov	ecx, cmdline_y_pos*10000h + cmdline_y_size
491
	mov	edx, 0xFFFFFF
491
	mov	edx, 0xFFFFFF
492
	mcall
492
	mcall
493
	mov	ebx, [cmdline_pos]
493
	mov	ebx, [cmdline_pos]
494
	cmp	ebx, [cmdline_len]
494
	cmp	ebx, [cmdline_len]
495
	jae	.ret
495
	jae	.ret
496
	mov	al, 4
496
	mov	al, 4
497
	xor	ecx, ecx
497
	xor	ecx, ecx
498
	lea	edx, [cmdline+ebx]
498
	lea	edx, [cmdline+ebx]
499
	imul	ebx, 6
499
	imul	ebx, 6
500
	add	ebx, cmdline_x_pos
500
	add	ebx, cmdline_x_pos
501
	shl	ebx, 16
501
	shl	ebx, 16
502
	or	ebx, cmdline_y_pos+1
502
	or	ebx, cmdline_y_pos+1
503
	push	1
503
	push	1
504
	pop	esi
504
	pop	esi
505
	mcall
505
	mcall
506
.ret:
506
.ret:
507
	ret
507
	ret
508
 
508
 
509
redraw_title:
509
redraw_title:
510
	push	13
510
	push	13
511
	pop	eax
511
	pop	eax
512
	mov	edx, 0xFFFFFF
512
	mov	edx, 0xFFFFFF
513
	mov	ebx, title_x_pos*10000h + data_x_pos+data_x_size-title_x_pos
513
	mov	ebx, title_x_pos*10000h + data_x_pos+data_x_size-title_x_pos
514
	mov	ecx, title_y_pos*10000h + title_y_size
514
	mov	ecx, title_y_pos*10000h + title_y_size
515
	mcall
515
	mcall
516
draw_title:
516
draw_title:
517
	mov	al, 38
517
	mov	al, 38
518
	mov	ebx, (data_x_pos-2)*10000h + title_x_pos-5
518
	mov	ebx, (data_x_pos-2)*10000h + title_x_pos-5
519
	mov	ecx, (title_y_pos+5)*10001h
519
	mov	ecx, (title_y_pos+5)*10001h
520
	xor	edx, edx
520
	xor	edx, edx
521
	mcall
521
	mcall
522
	push	NoPrgLoaded_len
522
	push	NoPrgLoaded_len
523
	pop	esi
523
	pop	esi
524
	cmp	[debuggee_pid], 0
524
	cmp	[debuggee_pid], 0
525
	jz	@f
525
	jz	@f
526
	mov	esi, [prgname_len]
526
	mov	esi, [prgname_len]
527
@@:	imul	ebx, esi, 6
527
@@:	imul	ebx, esi, 6
528
	add	ebx, title_x_pos+4
528
	add	ebx, title_x_pos+4
529
	shl	ebx, 16
529
	shl	ebx, 16
530
	mov	bx, data_x_pos+data_x_size-10-5-6*7
530
	mov	bx, data_x_pos+data_x_size-10-5-6*7
531
	cmp	[bSuspended], 0
531
	cmp	[bSuspended], 0
532
	jz	@f
532
	jz	@f
533
	add	ebx, 6
533
	add	ebx, 6
534
@@:
534
@@:
535
	mcall
535
	mcall
536
	mov	ebx, (data_x_pos+data_x_size-10+4)*0x10000 + data_x_pos+data_x_size+2
536
	mov	ebx, (data_x_pos+data_x_size-10+4)*0x10000 + data_x_pos+data_x_size+2
537
	mcall
537
	mcall
538
	mov	al, 4
538
	mov	al, 4
539
	mov	ebx, title_x_pos*10000h+title_y_pos
539
	mov	ebx, title_x_pos*10000h+title_y_pos
540
	xor	ecx, ecx
540
	xor	ecx, ecx
541
	mov	edx, NoPrgLoaded_str
541
	mov	edx, NoPrgLoaded_str
542
	cmp	[debuggee_pid], 0
542
	cmp	[debuggee_pid], 0
543
	jz	@f
543
	jz	@f
544
	mov	edx, [prgname_ptr]
544
	mov	edx, [prgname_ptr]
545
@@:
545
@@:
546
	mcall
546
	mcall
547
	cmp	[debuggee_pid], 0
547
	cmp	[debuggee_pid], 0
548
	jz	.nodebuggee
548
	jz	.nodebuggee
549
	mov	ebx, (data_x_pos+data_x_size-10-6*7)*10000h + title_y_pos
549
	mov	ebx, (data_x_pos+data_x_size-10-6*7)*10000h + title_y_pos
550
	mov	edx, aRunning
550
	mov	edx, aRunning
551
	push	7
551
	push	7
552
	pop	esi
552
	pop	esi
553
	cmp	[bSuspended], 0
553
	cmp	[bSuspended], 0
554
	jz	@f
554
	jz	@f
555
	add	ebx, 6*10000h
555
	add	ebx, 6*10000h
556
	mov	edx, aPaused
556
	mov	edx, aPaused
557
	dec	esi
557
	dec	esi
558
@@:
558
@@:
559
	mcall
559
	mcall
560
	ret
560
	ret
561
.nodebuggee:
561
.nodebuggee:
562
	mov	al, 38
562
	mov	al, 38
563
	mov	ebx, (data_x_pos+data_x_size-10-6*7-5)*0x10000 + data_x_pos+data_x_size+2
563
	mov	ebx, (data_x_pos+data_x_size-10-6*7-5)*0x10000 + data_x_pos+data_x_size+2
564
	mov	ecx, (title_y_pos+5)*10001h
564
	mov	ecx, (title_y_pos+5)*10001h
565
	xor	edx, edx
565
	xor	edx, edx
566
	jmp	@b
566
	jmp	@b
567
 
567
 
568
draw_register:
568
draw_register:
569
; in: esi->value, edx->string, ecx=string len, ebx=coord
569
; in: esi->value, edx->string, ecx=string len, ebx=coord
570
	push	edx
570
	push	edx
571
	push	ecx
571
	push	ecx
572
	push	esi
572
	push	esi
573
	mov	eax, esi
573
	mov	eax, esi
574
	mov	esi, ecx
574
	mov	esi, ecx
575
; color
575
; color
576
	mov	ecx, 40808080h
576
	mov	ecx, 40808080h
577
	cmp	[debuggee_pid], 0
577
	cmp	[debuggee_pid], 0
578
	jz	.cd
578
	jz	.cd
579
	cmp	[bSuspended], 0
579
	cmp	[bSuspended], 0
580
	jz	.cd
580
	jz	.cd
581
	mov	ecx, 40000000h
581
	mov	ecx, 40000000h
582
	push	edi
582
	push	edi
583
	mov	edi, [eax]
583
	mov	edi, [eax]
584
	cmp	dword [eax+oldcontext-context], edi
584
	cmp	dword [eax+oldcontext-context], edi
585
	pop	edi
585
	pop	edi
586
	jz	.cd
586
	jz	.cd
587
	mov	ecx, 0x4000AA00
587
	mov	ecx, 0x4000AA00
588
.cd:
588
.cd:
589
	push	4
589
	push	4
590
	pop	eax
590
	pop	eax
591
	mcall
591
	mcall
592
	imul	esi, 60000h
592
	imul	esi, 60000h
593
	lea	edx, [ebx+esi]
593
	lea	edx, [ebx+esi]
594
	mov	al, 47
594
	mov	al, 47
595
	mov	ebx, 80101h
595
	mov	ebx, 80101h
596
	mov	esi, ecx
596
	mov	esi, ecx
597
	pop	ecx
597
	pop	ecx
598
	mcall
598
	mcall
599
	lea	ebx, [edx+60000h*18]
599
	lea	ebx, [edx+60000h*18]
600
	mov	esi, ecx
600
	mov	esi, ecx
601
	pop	ecx
601
	pop	ecx
602
	pop	edx
602
	pop	edx
603
	add	edx, ecx
603
	add	edx, ecx
604
	ret
604
	ret
605
draw_flag:
605
draw_flag:
606
	movzx	edi, byte [edx+7]
606
	movzx	edi, byte [edx+7]
607
	bt	[_eflags], edi
607
	bt	[_eflags], edi
608
	jc	.on
608
	jc	.on
609
	or	byte [edx], 20h
609
	or	byte [edx], 20h
610
	jmp	.onoff
610
	jmp	.onoff
611
.on:
611
.on:
612
	and	byte [edx], not 20h
612
	and	byte [edx], not 20h
613
.onoff:
613
.onoff:
614
	mov	ecx, 40808080h
614
	mov	ecx, 40808080h
615
	cmp	[debuggee_pid], 0
615
	cmp	[debuggee_pid], 0
616
	jz	.doit
616
	jz	.doit
617
	cmp	[bSuspended], 0
617
	cmp	[bSuspended], 0
618
	jz	.doit
618
	jz	.doit
619
	mov	ecx, 40000000h
619
	mov	ecx, 40000000h
620
	bt	[_eflags], edi
620
	bt	[_eflags], edi
621
	lahf
621
	lahf
622
	bt	dword [_eflags + oldcontext - context], edi
622
	bt	dword [_eflags + oldcontext - context], edi
623
	rcl	ah, 1
623
	rcl	ah, 1
624
	test	ah, 3
624
	test	ah, 3
625
	jp	.doit
625
	jp	.doit
626
	mov	ecx, 0x4000AA00
626
	mov	ecx, 0x4000AA00
627
.doit:
627
.doit:
628
	mov	ah, 0
628
	mov	ah, 0
629
	mov	edi, 0xFFFFFF
629
	mov	edi, 0xFFFFFF
630
	mcall
630
	mcall
631
	ret
631
	ret
632
 
632
 
633
draw_registers:
633
draw_registers:
634
	push	13
634
	push	13
635
	pop	eax
635
	pop	eax
636
	mov	edx, 0xFFFFFF
636
	mov	edx, 0xFFFFFF
637
	mov	ebx, data_x_pos*10000h + data_x_size
637
	mov	ebx, data_x_pos*10000h + data_x_size
638
	mov	ecx, registers_y_pos*10000h + registers_y_size
638
	mov	ecx, registers_y_pos*10000h + registers_y_size
639
	mcall
639
	mcall
640
redraw_registers:
640
redraw_registers:
641
	mov	edi, 0xFFFFFF
641
	mov	edi, 0xFFFFFF
642
	mov	esi, _eax
642
	mov	esi, _eax
643
	push	4
643
	push	4
644
	pop	ecx
644
	pop	ecx
645
	mov	edx, regs_strs
645
	mov	edx, regs_strs
646
	mov	ebx, registers_x_pos*10000h+registers_y_pos
646
	mov	ebx, registers_x_pos*10000h+registers_y_pos
647
	call	draw_register
647
	call	draw_register
648
	add	esi, _ebx-_eax
648
	add	esi, _ebx-_eax
649
	call	draw_register
649
	call	draw_register
650
	add	esi, _ecx-_ebx
650
	add	esi, _ecx-_ebx
651
	call	draw_register
651
	call	draw_register
652
	add	esi, _edx-_ecx
652
	add	esi, _edx-_ecx
653
	call	draw_register
653
	call	draw_register
654
	mov	ebx, registers_x_pos*10000h+registers_y_pos+10
654
	mov	ebx, registers_x_pos*10000h+registers_y_pos+10
655
	add	esi, _esi-_edx
655
	add	esi, _esi-_edx
656
	call	draw_register
656
	call	draw_register
657
	add	esi, _edi-_esi
657
	add	esi, _edi-_esi
658
	call	draw_register
658
	call	draw_register
659
	add	esi, _ebp-_edi
659
	add	esi, _ebp-_edi
660
	call	draw_register
660
	call	draw_register
661
	add	esi, _esp-_ebp
661
	add	esi, _esp-_ebp
662
	call	draw_register
662
	call	draw_register
663
	mov	ebx, registers_x_pos*10000h+registers_y_pos+20
663
	mov	ebx, registers_x_pos*10000h+registers_y_pos+20
664
	add	esi, _eip-_esp
664
	add	esi, _eip-_esp
665
	call	draw_register
665
	call	draw_register
666
	mov	cl, 7
666
	mov	cl, 7
667
	add	esi, _eflags-_eip
667
	add	esi, _eflags-_eip
668
	call	draw_register
668
	call	draw_register
669
	mov	al, 4
669
	mov	al, 4
670
	mov	ecx, 808080h
670
	mov	ecx, 808080h
671
	cmp	[debuggee_pid], 0
671
	cmp	[debuggee_pid], 0
672
	jz	@f
672
	jz	@f
673
	cmp	[bSuspended], 0
673
	cmp	[bSuspended], 0
674
	jz	@f
674
	jz	@f
675
	xor	ecx, ecx
675
	xor	ecx, ecx
676
@@:
676
@@:
677
	mov	edx, aColon
677
	mov	edx, aColon
678
	xor	esi, esi
678
	xor	esi, esi
679
	inc	esi
679
	inc	esi
680
	mov	ebx, (registers_x_pos+37*6)*10000h + registers_y_pos+20
680
	mov	ebx, (registers_x_pos+37*6)*10000h + registers_y_pos+20
681
	mcall
681
	mcall
682
	mov	edx, flags
682
	mov	edx, flags
683
@@:
683
@@:
684
	add	ebx, 2*6*10000h
684
	add	ebx, 2*6*10000h
685
	call	draw_flag
685
	call	draw_flag
686
	inc	edx
686
	inc	edx
687
	cmp	dl, flags_bits and 0xFF
687
	cmp	dl, flags_bits and 0xFF
688
	jnz	@b
688
	jnz	@b
689
	ret
689
	ret
690
 
690
 
691
draw_dump:
691
draw_dump:
692
	push	13
692
	push	13
693
	pop	eax
693
	pop	eax
694
	mov	edx, 0xFFFFFF
694
	mov	edx, 0xFFFFFF
695
	mov	ebx, data_x_pos*10000h + data_x_size
695
	mov	ebx, data_x_pos*10000h + data_x_size
696
	mov	ecx, dump_y_pos*10000h + dump_y_size
696
	mov	ecx, dump_y_pos*10000h + dump_y_size
697
	mcall
697
	mcall
698
redraw_dump:
698
redraw_dump:
699
; addresses
699
; addresses
700
	mov	al, 47
700
	mov	al, 47
701
	mov	ebx, 80100h
701
	mov	ebx, 80100h
702
	mov	edx, data_x_pos*10000h + dump_y_pos
702
	mov	edx, data_x_pos*10000h + dump_y_pos
703
	mov	ecx, [dumppos]
703
	mov	ecx, [dumppos]
704
	mov	edi, 0xFFFFFF
704
	mov	edi, 0xFFFFFF
705
	mov	esi, 40808080h
705
	mov	esi, 40808080h
706
	cmp	[debuggee_pid], 0
706
	cmp	[debuggee_pid], 0
707
	jz	@f
707
	jz	@f
708
	cmp	[bSuspended], 0
708
	cmp	[bSuspended], 0
709
	jz	@f
709
	jz	@f
710
	mov	esi, 40000000h
710
	mov	esi, 40000000h
711
@@:
711
@@:
712
	mcall
712
	mcall
713
	add	ecx, 10h
713
	add	ecx, 10h
714
	add	edx, 10
714
	add	edx, 10
715
	cmp	dl, dump_y_pos + dump_y_size
715
	cmp	dl, dump_y_pos + dump_y_size
716
	jb	@b
716
	jb	@b
717
; hex dump of data
717
; hex dump of data
718
	mov	ecx, dumpdata
718
	mov	ecx, dumpdata
719
	push	ecx
719
	push	ecx
720
	xor	ebx, ebx
720
	xor	ebx, ebx
721
	mov	edx, (data_x_pos+12*6)*10000h + dump_y_pos
721
	mov	edx, (data_x_pos+12*6)*10000h + dump_y_pos
722
	cmp	[dumpread], ebx
722
	cmp	[dumpread], ebx
723
	jz	.hexdumpdone1
723
	jz	.hexdumpdone1
724
.hexdumploop1:
724
.hexdumploop1:
725
	push	ebx
725
	push	ebx
726
	mov	ebx, 20101h
726
	mov	ebx, 20101h
727
	mcall
727
	mcall
728
	pop	ebx
728
	pop	ebx
729
	add	edx, 3*6*10000h
729
	add	edx, 3*6*10000h
730
	inc	ecx
730
	inc	ecx
731
	inc	ebx
731
	inc	ebx
732
	test	bl, 15
732
	test	bl, 15
733
	jz	.16
733
	jz	.16
734
	test	bl, 7
734
	test	bl, 7
735
	jnz	@f
735
	jnz	@f
736
	add	edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
736
	add	edx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
737
.16:
737
.16:
738
	add	edx, 10 - 6*(3*10h+2)*10000h
738
	add	edx, 10 - 6*(3*10h+2)*10000h
739
@@:
739
@@:
740
	cmp	ebx, [dumpread]
740
	cmp	ebx, [dumpread]
741
	jb	.hexdumploop1
741
	jb	.hexdumploop1
742
.hexdumpdone1:
742
.hexdumpdone1:
743
	mov	al, 4
743
	mov	al, 4
744
	mov	ecx, esi
744
	mov	ecx, esi
745
	xchg	ebx, edx
745
	xchg	ebx, edx
746
	push	2
746
	push	2
747
	pop	esi
747
	pop	esi
748
.hexdumploop2:
748
.hexdumploop2:
749
	cmp	edx, dump_height*10h
749
	cmp	edx, dump_height*10h
750
	jae	.hexdumpdone2
750
	jae	.hexdumpdone2
751
	push	edx
751
	push	edx
752
	mov	edx, aQuests
752
	mov	edx, aQuests
753
	mcall
753
	mcall
754
	pop	edx
754
	pop	edx
755
	add	ebx, 3*6*10000h
755
	add	ebx, 3*6*10000h
756
	inc	edx
756
	inc	edx
757
	test	dl, 15
757
	test	dl, 15
758
	jz	.16x
758
	jz	.16x
759
	test	dl, 7
759
	test	dl, 7
760
	jnz	.hexdumploop2
760
	jnz	.hexdumploop2
761
	add	ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
761
	add	ebx, 2*6*10000h - 10 + 6*(3*10h+2)*10000h
762
.16x:
762
.16x:
763
	add	ebx, 10 - 6*(3*10h+2)*10000h
763
	add	ebx, 10 - 6*(3*10h+2)*10000h
764
	jmp	.hexdumploop2
764
	jmp	.hexdumploop2
765
.hexdumpdone2:
765
.hexdumpdone2:
766
	dec	esi
766
	dec	esi
767
; colon, minus signs
767
; colon, minus signs
768
	mov	ebx, (data_x_pos+8*6)*10000h + dump_y_pos
768
	mov	ebx, (data_x_pos+8*6)*10000h + dump_y_pos
769
	mov	edx, aColon
769
	mov	edx, aColon
770
@@:
770
@@:
771
	mcall
771
	mcall
772
	add	ebx, 10
772
	add	ebx, 10
773
	cmp	bl, dump_y_pos+dump_height*10
773
	cmp	bl, dump_y_pos+dump_height*10
774
	jb	@b
774
	jb	@b
775
	mov	ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos
775
	mov	ebx, (data_x_pos+(12+3*8)*6)*10000h + dump_y_pos
776
	mov	edx, aMinus
776
	mov	edx, aMinus
777
@@:
777
@@:
778
	mcall
778
	mcall
779
	add	ebx, 10
779
	add	ebx, 10
780
	cmp	bl, dump_y_pos+dump_height*10
780
	cmp	bl, dump_y_pos+dump_height*10
781
	jb	@b
781
	jb	@b
782
; ASCII data
782
; ASCII data
783
	mov	ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos
783
	mov	ebx, (data_x_pos+(12+3*10h+2+2)*6)*10000h + dump_y_pos
784
	pop	edx
784
	pop	edx
785
	push	dump_height*10h
785
	push	dump_height*10h
786
.asciiloop:
786
.asciiloop:
787
	push	edx
787
	push	edx
788
	cmp	byte [edx], 20h
788
	cmp	byte [edx], 20h
789
	jae	@f
789
	jae	@f
790
	mov	edx, aPoint
790
	mov	edx, aPoint
791
@@:
791
@@:
792
	mcall
792
	mcall
793
	pop	edx
793
	pop	edx
794
	inc	edx
794
	inc	edx
795
	add	ebx, 6*10000h
795
	add	ebx, 6*10000h
796
	dec	dword [esp]
796
	dec	dword [esp]
797
	jz	.asciidone
797
	jz	.asciidone
798
	test	byte [esp], 15
798
	test	byte [esp], 15
799
	jnz	.asciiloop
799
	jnz	.asciiloop
800
	add	ebx, 10 - 6*10h*10000h
800
	add	ebx, 10 - 6*10h*10000h
801
	jmp	.asciiloop
801
	jmp	.asciiloop
802
.asciidone:
802
.asciidone:
803
	pop	ecx
803
	pop	ecx
804
	ret
804
	ret
805
 
805
 
806
redraw_disasm:
806
redraw_disasm:
807
;	push	13
807
;	push	13
808
;	pop	eax
808
;	pop	eax
809
;	mov	edx, 0xFFFFFF
809
;	mov	edx, 0xFFFFFF
810
;	mov	ebx, data_x_pos*10000h + data_x_size
810
;	mov	ebx, data_x_pos*10000h + data_x_size
811
;	mov	ecx, (disasm_y_pos-1)*10000h + (disasm_y_size+1)
811
;	mov	ecx, (disasm_y_pos-1)*10000h + (disasm_y_size+1)
812
;	mcall
812
;	mcall
813
draw_disasm:
813
draw_disasm:
814
	mov	eax, [disasm_start_pos]
814
	mov	eax, [disasm_start_pos]
815
	mov	[disasm_cur_pos], eax
815
	mov	[disasm_cur_pos], eax
816
	and	[disasm_cur_str], 0
816
	and	[disasm_cur_str], 0
817
.loop:
817
.loop:
818
	mov	eax, [disasm_cur_pos]
818
	mov	eax, [disasm_cur_pos]
819
	call	find_symbol
819
	call	find_symbol
820
	jc	.nosymb
820
	jc	.nosymb
821
	mov	ebx, [disasm_cur_str]
821
	mov	ebx, [disasm_cur_str]
822
	imul	ebx, 10
822
	imul	ebx, 10
-
 
823
	push	ebx
-
 
824
	lea	ecx, [ebx+disasm_y_pos-1]
-
 
825
	shl	ecx, 16
-
 
826
	mov	cl, 11
-
 
827
	mov	edx, 0xFFFFFF
-
 
828
	mov	ebx, data_x_pos*10000h + data_x_size
-
 
829
	push	13
-
 
830
	pop	eax
-
 
831
	mcall
-
 
832
	pop	ebx
-
 
833
	mov	edi, edx
823
	add	ebx, (data_x_pos+6*2)*10000h + disasm_y_pos
834
	add	ebx, (data_x_pos+6*2)*10000h+disasm_y_pos
824
	mov	edx, esi
835
	mov	edx, esi
825
@@:	lodsb
836
@@:	lodsb
826
	test	al, al
837
	test	al, al
827
	jnz	@b
838
	jnz	@b
828
	mov	byte [esi-1], ':'
839
	mov	byte [esi-1], ':'
829
	sub	esi, edx
840
	sub	esi, edx
830
	mov	ecx, 40000000h
841
	mov	ecx, 40000000h
831
	mov	edi, 0xFFFFFF
-
 
832
	push	4
-
 
833
	pop	eax
842
	mov	al, 4
834
	mcall
843
	mcall
835
	mov	byte [esi+edx-1], 0
844
	mov	byte [esi+edx-1], 0
836
	lea	esi, [esi*3]
845
	lea	esi, [esi*3]
837
	movzx	ecx, bx
846
	movzx	ecx, bx
838
	shr	ebx, 16
847
	shr	ebx, 16
839
	lea	ebx, [ebx+esi*2]
848
	lea	ebx, [ebx+esi*2]
840
	shl	ecx, 16
849
	shl	ecx, 16
841
	mov	cl, 10
850
	mov	cl, 10
842
	imul	ebx, 10001h
851
	imul	ebx, 10001h
843
	sub	bx, data_x_pos+data_x_size
852
	sub	bx, data_x_pos+data_x_size
844
	neg	bx
853
	neg	bx
845
	mov	al, 13
854
	mov	al, 13
846
	mov	edx, edi
855
	mov	edx, edi
847
	mcall
856
	mcall
848
	inc	[disasm_cur_str]
857
	inc	[disasm_cur_str]
849
	cmp	[disasm_cur_str], disasm_height
858
	cmp	[disasm_cur_str], disasm_height
850
	jae	.loopend
859
	jae	.loopend
851
.nosymb:
860
.nosymb:
852
	push	[disasm_cur_pos]
861
	push	[disasm_cur_pos]
853
	call	disasm_instr
862
	call	disasm_instr
854
	pop	ebp
863
	pop	ebp
855
	jc	.loopend
864
	jc	.loopend
856
	xor	esi, esi	; default color: black
865
	xor	esi, esi	; default color: black
857
	mov	edx, 0xFFFFFF	; default background: white
866
	mov	edx, 0xFFFFFF	; default background: white
858
	mov	ebx, data_x_pos*10000h + data_x_size
867
	mov	ebx, data_x_pos*10000h + data_x_size
859
	mov	ecx, [disasm_cur_str]
868
	mov	ecx, [disasm_cur_str]
860
	imul	ecx, 10*10000h
869
	imul	ecx, 10*10000h
861
	add	ecx, (disasm_y_pos-1)*10000h + 10
870
	add	ecx, (disasm_y_pos-1)*10000h + 10
862
	mov	eax, ebp
871
	mov	eax, ebp
863
	pushad
872
	pushad
864
	call	find_enabled_breakpoint
873
	call	find_enabled_breakpoint
865
	popad
874
	popad
866
	jnz	.nored
875
	jnz	.nored
867
	mov	edx, 0xFF0000	; use background: red
876
	mov	edx, 0xFF0000	; use background: red
868
.nored:
877
.nored:
869
	mov	eax, [_eip]
878
	mov	eax, [_eip]
870
	cmp	eax, ebp
879
	cmp	eax, ebp
871
	jnz	.noblue
880
	jnz	.noblue
872
	mov	edx, 0x0000FF	; use background: blue
881
	mov	edx, 0x0000FF	; use background: blue
873
	mov	esi, 0xFFFFFF	; on blue bgr, use white color
882
	mov	esi, 0xFFFFFF	; on blue bgr, use white color
874
.noblue:
883
.noblue:
875
	push	13
884
	push	13
876
	pop	eax
885
	pop	eax
877
	mcall
886
	mcall
878
	mov	al, 47
887
	mov	al, 47
879
	mov	ebx, 80100h
888
	mov	ebx, 80100h
880
	mov	edx, [disasm_cur_str]
889
	mov	edx, [disasm_cur_str]
881
	imul	edx, 10
890
	imul	edx, 10
882
	add	edx, data_x_pos*10000h + disasm_y_pos
891
	add	edx, data_x_pos*10000h + disasm_y_pos
883
	mov	ecx, ebp
892
	mov	ecx, ebp
884
	mcall
893
	mcall
885
	mov	al, 4
894
	mov	al, 4
886
	lea	ebx, [edx+8*6*10000h]
895
	lea	ebx, [edx+8*6*10000h]
887
	mov	ecx, esi
896
	mov	ecx, esi
888
	push	2
897
	push	2
889
	pop	esi
898
	pop	esi
890
	mov	edx, aColon
899
	mov	edx, aColon
891
	mcall
900
	mcall
892
	push	9
901
	push	9
893
	pop	edi
902
	pop	edi
894
	lea	edx, [ebx+2*6*10000h]
903
	lea	edx, [ebx+2*6*10000h]
895
	mov	esi, ecx
904
	mov	esi, ecx
896
	mov	ecx, ebp
905
	mov	ecx, ebp
897
	sub	ecx, [disasm_start_pos]
906
	sub	ecx, [disasm_start_pos]
898
	add	ecx, disasm_buffer
907
	add	ecx, disasm_buffer
899
.drawhex:
908
.drawhex:
900
	mov	al, 47
909
	mov	al, 47
901
	mov	ebx, 20101h
910
	mov	ebx, 20101h
902
	mcall
911
	mcall
903
	add	edx, 6*3*10000h
912
	add	edx, 6*3*10000h
904
	inc	ecx
913
	inc	ecx
905
	inc	ebp
914
	inc	ebp
906
	cmp	ebp, [disasm_cur_pos]
915
	cmp	ebp, [disasm_cur_pos]
907
	jae	.hexdone
916
	jae	.hexdone
908
	dec	edi
917
	dec	edi
909
	jnz	.drawhex
918
	jnz	.drawhex
910
	push	esi
919
	push	esi
911
	mov	esi, [disasm_cur_pos]
920
	mov	esi, [disasm_cur_pos]
912
	dec	esi
921
	dec	esi
913
	cmp	esi, ebp
922
	cmp	esi, ebp
914
	pop	esi
923
	pop	esi
915
	jbe	.drawhex
924
	jbe	.drawhex
916
	mov	al, 4
925
	mov	al, 4
917
	lea	ebx, [edx-6*10000h]
926
	lea	ebx, [edx-6*10000h]
918
	mov	ecx, esi
927
	mov	ecx, esi
919
	push	3
928
	push	3
920
	pop	esi
929
	pop	esi
921
	mov	edx, aDots
930
	mov	edx, aDots
922
	mcall
931
	mcall
923
	mov	esi, ecx
932
	mov	esi, ecx
924
.hexdone:
933
.hexdone:
925
	xor	eax, eax
934
	xor	eax, eax
926
	mov	edi, disasm_string
935
	mov	edi, disasm_string
927
	mov	edx, edi
936
	mov	edx, edi
928
	or	ecx, -1
937
	or	ecx, -1
929
	repnz	scasb
938
	repnz	scasb
930
	not	ecx
939
	not	ecx
931
	dec	ecx
940
	dec	ecx
932
	xchg	ecx, esi
941
	xchg	ecx, esi
933
	mov	ebx, [disasm_cur_str]
942
	mov	ebx, [disasm_cur_str]
934
	imul	ebx, 10
943
	imul	ebx, 10
935
	add	ebx, (data_x_pos+6*40)*10000h+disasm_y_pos
944
	add	ebx, (data_x_pos+6*40)*10000h+disasm_y_pos
936
	mov	al, 4
945
	mov	al, 4
937
	mcall
946
	mcall
938
	inc	[disasm_cur_str]
947
	inc	[disasm_cur_str]
939
	cmp	[disasm_cur_str], disasm_height
948
	cmp	[disasm_cur_str], disasm_height
940
	jb	.loop
949
	jb	.loop
941
.loopend:
950
.loopend:
942
	mov	ecx, disasm_height
951
	mov	ecx, disasm_height
943
	sub	ecx, [disasm_cur_str]
952
	sub	ecx, [disasm_cur_str]
944
	jz	@f
953
	jz	@f
945
	imul	ecx, 10
954
	imul	ecx, 10
-
 
955
	inc	ecx
946
	mov	eax, disasm_y_pos + disasm_y_size
956
	mov	eax, disasm_y_pos + disasm_y_size
947
	sub	eax, ecx
957
	sub	eax, ecx
948
	shl	eax, 16
958
	shl	eax, 16
949
	add	ecx, eax
959
	add	ecx, eax
950
	push	13
960
	push	13
951
	pop	eax
961
	pop	eax
952
	mov	ebx, data_x_pos*65536 + data_x_size
962
	mov	ebx, data_x_pos*65536 + data_x_size
953
	mov	edx, 0xFFFFFF
963
	mov	edx, 0xFFFFFF
954
	mcall
964
	mcall
955
@@:
965
@@:
956
	ret
966
	ret
957
 
967
 
958
update_disasm_eip:
968
update_disasm_eip:
959
; test if instruction at eip is showed
969
; test if instruction at eip is showed
960
	mov	ecx, disasm_height
970
	mov	ecx, disasm_height
961
	mov	eax, [disasm_start_pos]
971
	mov	eax, [disasm_start_pos]
962
	mov	[disasm_cur_pos], eax
972
	mov	[disasm_cur_pos], eax
963
.l:
973
.l:
964
	mov	eax, [disasm_cur_pos]
974
	mov	eax, [disasm_cur_pos]
965
	call	find_symbol
975
	call	find_symbol
966
	jc	@f
976
	jc	@f
967
	dec	ecx
977
	dec	ecx
968
	jz	.m
978
	jz	.m
969
@@:
979
@@:
970
	cmp	[_eip], eax
980
	cmp	[_eip], eax
971
	jz	redraw_disasm
981
	jz	redraw_disasm
972
	push	ecx
982
	push	ecx
973
	call	disasm_instr
983
	call	disasm_instr
974
	pop	ecx
984
	pop	ecx
975
	jc	.m
985
	jc	.m
976
	loop	.l
986
	loop	.l
977
.m:
987
.m:
978
update_disasm_eip_force:
988
update_disasm_eip_force:
979
	mov	eax, [_eip]
989
	mov	eax, [_eip]
980
	mov	[disasm_start_pos], eax
990
	mov	[disasm_start_pos], eax
981
update_disasm:
991
update_disasm:
982
	cmp	[debuggee_pid], 0
992
	cmp	[debuggee_pid], 0
983
	jz	.no
993
	jz	.no
984
	push	69
994
	push	69
985
	pop	eax
995
	pop	eax
986
	push	6
996
	push	6
987
	pop	ebx
997
	pop	ebx
988
	mov	ecx, [debuggee_pid]
998
	mov	ecx, [debuggee_pid]
989
	mov	edi, disasm_buffer
999
	mov	edi, disasm_buffer
990
	mov	edx, 256
1000
	mov	edx, 256
991
	mov	esi, [disasm_start_pos]
1001
	mov	esi, [disasm_start_pos]
992
	mcall
1002
	mcall
993
	cmp	eax, -1
1003
	cmp	eax, -1
994
	jnz	@f
1004
	jnz	@f
995
	mov	esi, read_mem_err
1005
	mov	esi, read_mem_err
996
	call	put_message
1006
	call	put_message
997
.no:
1007
.no:
998
	xor	eax, eax
1008
	xor	eax, eax
999
@@:
1009
@@:
1000
	mov	[disasm_buf_size], eax
1010
	mov	[disasm_buf_size], eax
1001
	call	restore_from_breaks
1011
	call	restore_from_breaks
1002
	jmp	redraw_disasm
1012
	jmp	redraw_disasm
1003
 
1013
 
1004
draw_window:
1014
draw_window:
1005
; start redraw
1015
; start redraw
1006
	push	12
1016
	push	12
1007
	pop	eax
1017
	pop	eax
1008
	push	1
1018
	push	1
1009
	pop	ebx
1019
	pop	ebx
1010
	mcall
1020
	mcall
1011
; define window
1021
; define window
1012
	xor	eax, eax
1022
	xor	eax, eax
1013
	mov	ebx, wnd_x_size
1023
	mov	ebx, wnd_x_size
1014
	mov	ecx, wnd_y_size
1024
	mov	ecx, wnd_y_size
1015
	mov	edx, 54FFFFFFh
1025
	mov	edx, 54FFFFFFh
1016
	mov	edi, caption_str
1026
	mov	edi, caption_str
1017
	mcall
1027
	mcall
1018
; clear unused areas
1028
; clear unused areas
1019
	mov	al, 48
1029
	mov	al, 48
1020
	push	4
1030
	push	4
1021
	pop	ebx
1031
	pop	ebx
1022
	mcall
1032
	mcall
1023
	cmp	eax, title_y_pos
1033
	cmp	eax, title_y_pos
1024
	jb	@f
1034
	jb	@f
1025
	push	registers_y_pos
1035
	push	registers_y_pos
1026
	pop	eax
1036
	pop	eax
1027
@@:
1037
@@:
1028
	push	registers_y_pos
1038
	push	registers_y_pos
1029
	pop	ecx
1039
	pop	ecx
1030
	push	eax
1040
	push	eax
1031
	sub	ecx, eax
1041
	sub	ecx, eax
1032
	shl	eax, 16
1042
	shl	eax, 16
1033
	add	ecx, eax
1043
	add	ecx, eax
1034
	mov	ebx, 5*10000h + (wnd_x_size-9)
1044
	mov	ebx, 5*10000h + (wnd_x_size-9)
1035
	push	13
1045
	push	13
1036
	pop	eax
1046
	pop	eax
1037
	mcall
1047
	mcall
1038
	mov	ecx, (registers_y_pos+registers_y_size)*10000h + (dump_y_pos-registers_y_pos-registers_y_size)
1048
	mov	ecx, (registers_y_pos+registers_y_size)*10000h + (dump_y_pos-registers_y_pos-registers_y_size)
1039
	mcall
1049
	mcall
1040
	mov	ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size)
1050
	mov	ecx, (dump_y_pos+dump_y_size)*10000h + (disasm_y_pos-dump_y_pos-dump_y_size)
1041
	mcall
1051
	mcall
1042
	mov	ecx, (disasm_y_pos+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos-disasm_y_size)
1052
	mov	ecx, (disasm_y_pos-1+disasm_y_size)*10000h + (messages_y_pos-disasm_y_pos+1-disasm_y_size)
1043
	mcall
1053
	mcall
1044
	mov	ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4)
1054
	mov	ecx, (messages_y_pos+messages_y_size)*10000h + (wnd_y_size-messages_y_pos-messages_y_size-4)
1045
	mcall
1055
	mcall
1046
	mov	ebx, 5*10000h + (data_x_pos-5)
1056
	mov	ebx, 5*10000h + (data_x_pos-5)
1047
	pop	ecx
1057
	pop	ecx
1048
	imul	ecx, 10001h
1058
	imul	ecx, 10001h
1049
	sub	cx, wnd_y_size-4
1059
	sub	cx, wnd_y_size-4
1050
	neg	cx
1060
	neg	cx
1051
	mcall
1061
	mcall
1052
	mov	ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4)
1062
	mov	ebx, (data_x_pos+data_x_size)*10000h + (wnd_x_size-data_x_pos-data_x_size-4)
1053
	mcall
1063
	mcall
1054
; messages frame
1064
; messages frame
1055
	mov	al, 38
1065
	mov	al, 38
1056
	mov	ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2)
1066
	mov	ebx, (messages_x_pos-2)*10000h + (messages_x_pos+messages_x_size+2)
1057
	push	ebx
1067
	push	ebx
1058
	mov	ecx, (messages_y_pos-2)*10001h
1068
	mov	ecx, (messages_y_pos-2)*10001h
1059
	xor	edx, edx
1069
	xor	edx, edx
1060
	mcall
1070
	mcall
1061
	mov	ecx, (messages_y_pos+messages_y_size+2)*10001h
1071
	mov	ecx, (messages_y_pos+messages_y_size+2)*10001h
1062
	mcall
1072
	mcall
1063
	mov	ebx, (messages_x_pos-2)*10001h
1073
	mov	ebx, (messages_x_pos-2)*10001h
1064
	push	ebx
1074
	push	ebx
1065
	mov	ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2)
1075
	mov	ecx, (messages_y_pos-2)*10000h + (messages_y_pos+messages_y_size+2)
1066
	mcall
1076
	mcall
1067
	mov	ebx, (messages_x_pos+messages_x_size+2)*10001h
1077
	mov	ebx, (messages_x_pos+messages_x_size+2)*10001h
1068
	push	ebx
1078
	push	ebx
1069
	mcall
1079
	mcall
1070
; command line frame
1080
; command line frame
1071
	mov	ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2)
1081
	mov	ecx, (cmdline_y_pos-2)*10000h + (cmdline_y_pos+cmdline_y_size+2)
1072
	pop	ebx
1082
	pop	ebx
1073
	mcall
1083
	mcall
1074
	pop	ebx
1084
	pop	ebx
1075
	mcall
1085
	mcall
1076
	pop	ebx
1086
	pop	ebx
1077
	mov	ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h
1087
	mov	ecx, (cmdline_y_pos+cmdline_y_size+2)*10001h
1078
	mcall
1088
	mcall
1079
	mov	ecx, (cmdline_y_pos-2)*10001h
1089
	mov	ecx, (cmdline_y_pos-2)*10001h
1080
	mcall
1090
	mcall
1081
; messages
1091
; messages
1082
	call	draw_messages
1092
	call	draw_messages
1083
; command line & cursor
1093
; command line & cursor
1084
	call	draw_cmdline
1094
	call	draw_cmdline
1085
	call	draw_cursor
1095
	call	draw_cursor
1086
; title & registers & dump & disasm
1096
; title & registers & dump & disasm
1087
	mov	al, 38
1097
	mov	al, 38
1088
	mov	ebx, (data_x_pos-2)*10001h
1098
	mov	ebx, (data_x_pos-2)*10001h
1089
	mov	ecx, (title_y_pos+5)*10000h + (messages_y_pos-2)
1099
	mov	ecx, (title_y_pos+5)*10000h + (messages_y_pos-2)
1090
	mcall
1100
	mcall
1091
	mov	ebx, (data_x_pos+data_x_size+2)*10001h
1101
	mov	ebx, (data_x_pos+data_x_size+2)*10001h
1092
	mcall
1102
	mcall
1093
	mov	ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2)
1103
	mov	ebx, (data_x_pos-2)*10000h + (data_x_pos+data_x_size+2)
1094
	mov	ecx, (dump_y_pos-3)*10001h
1104
	mov	ecx, (dump_y_pos-3)*10001h
1095
	mcall
1105
	mcall
1096
	mov	ecx, (disasm_y_pos-4)*10001h
1106
	mov	ecx, (disasm_y_pos-4)*10001h
1097
	mcall
1107
	mcall
1098
	call	redraw_title
1108
	call	redraw_title
1099
	call	draw_registers
1109
	call	draw_registers
1100
	call	draw_dump
1110
	call	draw_dump
1101
	call	redraw_disasm
1111
	call	redraw_disasm
1102
; end redraw
1112
; end redraw
1103
	push	12
1113
	push	12
1104
	pop	eax
1114
	pop	eax
1105
	push	2
1115
	push	2
1106
	pop	ebx
1116
	pop	ebx
1107
	mcall
1117
	mcall
1108
	ret
1118
	ret
1109
 
1119
 
1110
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1120
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1111
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1121
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DEBUGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1112
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1122
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1113
 
1123
 
1114
OnHelp:
1124
OnHelp:
1115
	mov	esi, help_msg
1125
	mov	esi, help_msg
1116
	mov	edi, [curarg]
1126
	mov	edi, [curarg]
1117
	cmp	byte [edi], 0
1127
	cmp	byte [edi], 0
1118
	jz	.x
1128
	jz	.x
1119
	mov	esi, help_groups
1129
	mov	esi, help_groups
1120
	call	find_cmd
1130
	call	find_cmd
1121
	jc	.nocmd
1131
	jc	.nocmd
1122
	mov	esi, [esi+12]
1132
	mov	esi, [esi+12]
1123
.x:
1133
.x:
1124
	jmp	put_message
1134
	jmp	put_message
1125
.nocmd:
1135
.nocmd:
1126
	mov	esi, aUnknownCommand
1136
	mov	esi, aUnknownCommand
1127
	jmp	.x
1137
	jmp	.x
1128
 
1138
 
1129
OnQuit:
1139
OnQuit:
1130
	push	-1
1140
	push	-1
1131
	pop	eax
1141
	pop	eax
1132
	mcall
1142
	mcall
1133
 
1143
 
1134
get_new_context:
1144
get_new_context:
1135
	mov	esi, context
1145
	mov	esi, context
1136
	mov	edi, oldcontext
1146
	mov	edi, oldcontext
1137
	mov	ecx, 10
1147
	mov	ecx, 10
1138
	rep	movsd
1148
	rep	movsd
1139
get_context:
1149
get_context:
1140
	push	1
1150
	push	1
1141
	pop	ebx
1151
	pop	ebx
1142
	push	69
1152
	push	69
1143
	pop	eax
1153
	pop	eax
1144
	mov	ecx, [debuggee_pid]
1154
	mov	ecx, [debuggee_pid]
1145
	mov	esi, context
1155
	mov	esi, context
1146
	push	28h
1156
	push	28h
1147
	pop	edx
1157
	pop	edx
1148
	mcall
1158
	mcall
1149
	ret
1159
	ret
1150
set_context:
1160
set_context:
1151
	push	2
1161
	push	2
1152
	pop	ebx
1162
	pop	ebx
1153
	push	69
1163
	push	69
1154
	pop	eax
1164
	pop	eax
1155
	mov	ecx, [debuggee_pid]
1165
	mov	ecx, [debuggee_pid]
1156
	mov	esi, context
1166
	mov	esi, context
1157
	push	28h
1167
	push	28h
1158
	pop	edx
1168
	pop	edx
1159
	mcall
1169
	mcall
1160
	ret
1170
	ret
1161
 
1171
 
1162
get_dump:
1172
get_dump:
1163
	mov	edi, dumpdata
1173
	mov	edi, dumpdata
1164
	mov	esi, [edi-4]
1174
	mov	esi, [edi-4]
1165
	mov	edx, dump_height*10h
1175
	mov	edx, dump_height*10h
1166
	mov	ecx, edx
1176
	mov	ecx, edx
1167
	xor	eax, eax
1177
	xor	eax, eax
1168
	push	edi
1178
	push	edi
1169
	rep	stosb
1179
	rep	stosb
1170
	pop	edi
1180
	pop	edi
1171
	mov	ecx, [debuggee_pid]
1181
	mov	ecx, [debuggee_pid]
1172
	mov	al, 69
1182
	mov	al, 69
1173
	push	6
1183
	push	6
1174
	pop	ebx
1184
	pop	ebx
1175
	mcall
1185
	mcall
1176
	cmp	eax, -1
1186
	cmp	eax, -1
1177
	jnz	@f
1187
	jnz	@f
1178
	mov	esi, read_mem_err
1188
	mov	esi, read_mem_err
1179
	call	put_message
1189
	call	put_message
1180
	xor	eax, eax
1190
	xor	eax, eax
1181
@@:
1191
@@:
1182
	mov	[edi-8], eax
1192
	mov	[edi-8], eax
1183
;	call	restore_from_breaks
1193
;	call	restore_from_breaks
1184
;	ret
1194
;	ret
1185
restore_from_breaks:
1195
restore_from_breaks:
1186
; in: edi=buffer,eax=size,esi=address
1196
; in: edi=buffer,eax=size,esi=address
1187
	mov	ebx, breakpoints
1197
	mov	ebx, breakpoints
1188
@@:
1198
@@:
1189
	test	byte [ebx+4], 1
1199
	test	byte [ebx+4], 1
1190
	jz	.cont		; ignore invalid
1200
	jz	.cont		; ignore invalid
1191
	test	byte [ebx+4], 2 or 8
1201
	test	byte [ebx+4], 2 or 8
1192
	jnz	.cont		; ignore disabled and memory breaks
1202
	jnz	.cont		; ignore disabled and memory breaks
1193
	mov	ecx, [ebx]
1203
	mov	ecx, [ebx]
1194
	sub	ecx, esi
1204
	sub	ecx, esi
1195
	cmp	ecx, eax
1205
	cmp	ecx, eax
1196
	jae	.cont
1206
	jae	.cont
1197
	mov	dl, [ebx+5]
1207
	mov	dl, [ebx+5]
1198
	mov	[edi+ecx], dl
1208
	mov	[edi+ecx], dl
1199
.cont:
1209
.cont:
1200
	add	ebx, 6
1210
	add	ebx, 6
1201
	cmp	ebx, breakpoints+breakpoints_n*6
1211
	cmp	ebx, breakpoints+breakpoints_n*6
1202
	jb	@b
1212
	jb	@b
1203
	ret
1213
	ret
1204
 
1214
 
1205
OnLoad:
1215
OnLoad:
1206
	mov	esi, [curarg]
1216
	mov	esi, [curarg]
1207
OnLoadInit:
1217
OnLoadInit:
1208
	mov	edi, loadname
1218
	mov	edi, loadname
1209
	or	[prgname_len], -1
1219
	or	[prgname_len], -1
1210
	mov	[prgname_ptr], edi
1220
	mov	[prgname_ptr], edi
1211
.copyname:
1221
.copyname:
1212
	lodsb
1222
	lodsb
1213
	stosb
1223
	stosb
1214
	inc	[prgname_len]
1224
	inc	[prgname_len]
1215
	cmp	al, '/'
1225
	cmp	al, '/'
1216
	jnz	@f
1226
	jnz	@f
1217
	or	[prgname_len], -1
1227
	or	[prgname_len], -1
1218
	mov	[prgname_ptr], edi
1228
	mov	[prgname_ptr], edi
1219
@@:
1229
@@:
1220
	cmp	al, ' '
1230
	cmp	al, ' '
1221
	ja	.copyname
1231
	ja	.copyname
1222
	mov	byte [edi-1], 0
1232
	mov	byte [edi-1], 0
1223
	and	[load_params], 0
1233
	and	[load_params], 0
1224
	dec	esi
1234
	dec	esi
1225
	call	skip_spaces
1235
	call	skip_spaces
1226
	cmp	al, 0
1236
	cmp	al, 0
1227
	jz	@f
1237
	jz	@f
1228
	mov	[load_params], esi
1238
	mov	[load_params], esi
1229
@@:
1239
@@:
1230
	and	[dumppos], 0
1240
	and	[dumppos], 0
1231
	mov	ecx, [symbols]
1241
	mov	ecx, [symbols]
1232
	jecxz	do_reload
1242
	jecxz	do_reload
1233
	mcall	68, 13
1243
	mcall	68, 13
1234
	and	[symbols], 0
1244
	and	[symbols], 0
1235
	and	[num_symbols], 0
1245
	and	[num_symbols], 0
1236
do_reload:
1246
do_reload:
1237
	push	18
1247
	push	18
1238
	pop	eax
1248
	pop	eax
1239
	push	7
1249
	push	7
1240
	pop	ebx
1250
	pop	ebx
1241
	mcall
1251
	mcall
1242
	mov	[dbgwnd], eax
1252
	mov	[dbgwnd], eax
1243
	xchg	ecx, eax
1253
	xchg	ecx, eax
1244
	push	70
1254
	push	70
1245
	pop	eax
1255
	pop	eax
1246
	mov	ebx, fn70_load_block
1256
	mov	ebx, fn70_load_block
1247
	mcall
1257
	mcall
1248
	test	eax, eax
1258
	test	eax, eax
1249
	jns	.load_ok
1259
	jns	.load_ok
1250
.load_err:
1260
.load_err:
1251
	push	eax
1261
	push	eax
1252
	mov	esi, load_err_msg
1262
	mov	esi, load_err_msg
1253
	call	put_message
1263
	call	put_message
1254
	pop	eax
1264
	pop	eax
1255
	not	eax
1265
	not	eax
1256
	cmp	eax, 0x20
1266
	cmp	eax, 0x20
1257
	jae	.unk_err
1267
	jae	.unk_err
1258
	mov	esi, [load_err_msgs+eax*4]
1268
	mov	esi, [load_err_msgs+eax*4]
1259
	test	esi, esi
1269
	test	esi, esi
1260
	jnz	put_message
1270
	jnz	put_message
1261
.unk_err:
1271
.unk_err:
1262
	mov	esi, unk_err_msg
1272
	mov	esi, unk_err_msg
1263
	inc	eax
1273
	inc	eax
1264
	push	eax
1274
	push	eax
1265
	call	put_message_nodraw
1275
	call	put_message_nodraw
1266
	jmp	draw_messages
1276
	jmp	draw_messages
1267
.load_ok:
1277
.load_ok:
1268
	mov	[debuggee_pid], eax
1278
	mov	[debuggee_pid], eax
1269
	mov	[bSuspended], 1
1279
	mov	[bSuspended], 1
1270
	push	ecx
1280
	push	ecx
1271
	call	get_context
1281
	call	get_context
1272
	mov	edi, oldcontext
1282
	mov	edi, oldcontext
1273
	mov	ecx, 10
1283
	mov	ecx, 10
1274
	rep	movsd
1284
	rep	movsd
1275
; activate debugger window
1285
; activate debugger window
1276
	pop	ecx
1286
	pop	ecx
1277
	mov	bl, 3
1287
	mov	bl, 3
1278
	push	18
1288
	push	18
1279
	pop	eax
1289
	pop	eax
1280
	mcall
1290
	mcall
1281
	call	redraw_title
1291
	call	redraw_title
1282
	call	redraw_registers
1292
	call	redraw_registers
1283
	call	get_dump
1293
	call	get_dump
1284
	call	redraw_dump
1294
	call	redraw_dump
1285
	call	update_disasm_eip_force
1295
	call	update_disasm_eip_force
1286
	mov	esi, load_succ_msg
1296
	mov	esi, load_succ_msg
1287
	push	[debuggee_pid]
1297
	push	[debuggee_pid]
1288
	call	put_message_nodraw
1298
	call	put_message_nodraw
1289
	call	draw_messages
1299
	call	draw_messages
1290
; try to load symbols
1300
; try to load symbols
1291
	mov	esi, loadname
1301
	mov	esi, loadname
1292
	mov	edi, symbolsfile
1302
	mov	edi, symbolsfile
1293
	push	edi
1303
	push	edi
1294
@@:
1304
@@:
1295
	lodsb
1305
	lodsb
1296
	stosb
1306
	stosb
1297
	test	al, al
1307
	test	al, al
1298
	jnz	@b
1308
	jnz	@b
1299
	lea	ecx, [edi-1]
1309
	lea	ecx, [edi-1]
1300
@@:
1310
@@:
1301
	dec	edi
1311
	dec	edi
1302
	cmp	edi, symbolsfile
1312
	cmp	edi, symbolsfile
1303
	jb	@f
1313
	jb	@f
1304
	cmp	byte [edi], '/'
1314
	cmp	byte [edi], '/'
1305
	jz	@f
1315
	jz	@f
1306
	cmp	byte [edi], '.'
1316
	cmp	byte [edi], '.'
1307
	jnz	@b
1317
	jnz	@b
1308
	mov	ecx, edi
1318
	mov	ecx, edi
1309
@@:
1319
@@:
1310
	mov	dword [ecx], '.dbg'
1320
	mov	dword [ecx], '.dbg'
1311
	mov	byte [ecx+4], 0
1321
	mov	byte [ecx+4], 0
1312
	pop	esi
1322
	pop	esi
1313
	mov	ebp, esi
1323
	mov	ebp, esi
1314
	call	OnLoadSymbols.silent
1324
	call	OnLoadSymbols.silent
1315
; now test for packed progs
1325
; now test for packed progs
1316
	cmp	[disasm_buf_size], 100h
1326
	cmp	[disasm_buf_size], 100h
1317
	jz	@f
1327
	jz	@f
1318
	ret
1328
	ret
1319
@@:
1329
@@:
1320
	mov	esi, mxp_nrv_sig
1330
	mov	esi, mxp_nrv_sig
1321
	mov	ebp, disasm_buffer
1331
	mov	ebp, disasm_buffer
1322
	mov	edi, ebp
1332
	mov	edi, ebp
1323
	push	3
1333
	push	3
1324
	pop	ecx
1334
	pop	ecx
1325
	repz	cmpsb
1335
	repz	cmpsb
1326
	jnz	.not_mxp_nrv
1336
	jnz	.not_mxp_nrv
1327
	cmpsb
1337
	cmpsb
1328
	mov	cl, mxp_nrv_sig_size-4
1338
	mov	cl, mxp_nrv_sig_size-4
1329
	repz	cmpsb
1339
	repz	cmpsb
1330
	mov	esi, mxp_nrv_name
1340
	mov	esi, mxp_nrv_name
1331
	jz	.packed
1341
	jz	.packed
1332
.not_mxp_nrv:
1342
.not_mxp_nrv:
1333
	mov	esi, mxp_sig
1343
	mov	esi, mxp_sig
1334
	mov	edi, ebp
1344
	mov	edi, ebp
1335
	mov	cl, mxp_sig_size
1345
	mov	cl, mxp_sig_size
1336
	repz	cmpsb
1346
	repz	cmpsb
1337
	mov	esi, mxp_name
1347
	mov	esi, mxp_name
1338
	jz	.packed
1348
	jz	.packed
1339
.not_mxp:
1349
.not_mxp:
1340
	mov	esi, mxp_lzo_sig1
1350
	mov	esi, mxp_lzo_sig1
1341
	mov	edi, ebp
1351
	mov	edi, ebp
1342
	mov	cl, mxp_lzo_sig1_size
1352
	mov	cl, mxp_lzo_sig1_size
1343
	repz	cmpsb
1353
	repz	cmpsb
1344
	mov	esi, mxp_lzo_name
1354
	mov	esi, mxp_lzo_name
1345
	jz	.packed
1355
	jz	.packed
1346
	mov	esi, mxp_lzo_sig2
1356
	mov	esi, mxp_lzo_sig2
1347
	mov	edi, ebp
1357
	mov	edi, ebp
1348
	mov	cl, 8
1358
	mov	cl, 8
1349
	repz	cmpsb
1359
	repz	cmpsb
1350
	jnz	.not_mxp_lzo
1360
	jnz	.not_mxp_lzo
1351
	cmpsb
1361
	cmpsb
1352
	mov	cl, mxp_lzo_sig2_size - 9
1362
	mov	cl, mxp_lzo_sig2_size - 9
1353
	repz	cmpsb
1363
	repz	cmpsb
1354
	mov	esi, mxp_lzo_name
1364
	mov	esi, mxp_lzo_name
1355
	jz	.packed
1365
	jz	.packed
1356
.not_mxp_lzo:
1366
.not_mxp_lzo:
1357
	mov	esi, mtappack_name
1367
	mov	esi, mtappack_name
1358
	cmp	dword [ebp], 0xBF5E246A
1368
	cmp	dword [ebp], 0xBF5E246A
1359
	jnz	.not_mtappack
1369
	jnz	.not_mtappack
1360
	cmp	dword [ebp+8], 0xEC4E8B57
1370
	cmp	dword [ebp+8], 0xEC4E8B57
1361
	jnz	.not_mtappack1
1371
	jnz	.not_mtappack1
1362
	cmp	dword [ebp+12], 0x8D5EA4F3
1372
	cmp	dword [ebp+12], 0x8D5EA4F3
1363
	jnz	.not_mtappack1
1373
	jnz	.not_mtappack1
1364
	cmp	byte [ebp+12h], 0xE9
1374
	cmp	byte [ebp+12h], 0xE9
1365
	jz	.packed
1375
	jz	.packed
1366
.not_mtappack1:
1376
.not_mtappack1:
1367
	cmp	word [ebp+8], 0xB957
1377
	cmp	word [ebp+8], 0xB957
1368
	jnz	.not_mtappack
1378
	jnz	.not_mtappack
1369
	cmp	dword [ebp+14], 0x575EA4F3
1379
	cmp	dword [ebp+14], 0x575EA4F3
1370
	jnz	.not_mtappack2
1380
	jnz	.not_mtappack2
1371
	cmp	byte [ebp+17h], 0xE9
1381
	cmp	byte [ebp+17h], 0xE9
1372
	jz	.packed
1382
	jz	.packed
1373
.not_mtappack2:
1383
.not_mtappack2:
1374
	cmp	dword [ebp+14], 0x5F8DA4F3
1384
	cmp	dword [ebp+14], 0x5F8DA4F3
1375
	jnz	.not_mtappack3
1385
	jnz	.not_mtappack3
1376
	cmp	word [ebp+18], 0xE9FC
1386
	cmp	word [ebp+18], 0xE9FC
1377
	jz	.packed
1387
	jz	.packed
1378
.not_mtappack3:
1388
.not_mtappack3:
1379
	cmp	word [ebp+14], 0xA4F3
1389
	cmp	word [ebp+14], 0xA4F3
1380
	jnz	.not_mtappack
1390
	jnz	.not_mtappack
1381
	cmp	byte [ebp+15h], 0xE9
1391
	cmp	byte [ebp+15h], 0xE9
1382
	jz	.packed
1392
	jz	.packed
1383
.not_mtappack:
1393
.not_mtappack:
1384
	ret
1394
	ret
1385
.packed:
1395
.packed:
1386
	push	esi
1396
	push	esi
1387
	mov	esi, aPacked1
1397
	mov	esi, aPacked1
1388
	call	put_message_nodraw
1398
	call	put_message_nodraw
1389
	pop	esi
1399
	pop	esi
1390
	call	put_message_nodraw
1400
	call	put_message_nodraw
1391
	mov	esi, aPacked2
1401
	mov	esi, aPacked2
1392
	call	put_message
1402
	call	put_message
1393
	call	hide_cursor
1403
	call	hide_cursor
1394
	push	40
1404
	push	40
1395
	pop	eax
1405
	pop	eax
1396
	push	7
1406
	push	7
1397
	pop	ebx
1407
	pop	ebx
1398
	mcall
1408
	mcall
1399
.wait:
1409
.wait:
1400
	push	10
1410
	push	10
1401
	pop	eax
1411
	pop	eax
1402
	mcall
1412
	mcall
1403
	dec	eax
1413
	dec	eax
1404
	jz	.redraw
1414
	jz	.redraw
1405
	dec	eax
1415
	dec	eax
1406
	jz	.key
1416
	jz	.key
1407
	or	eax, -1
1417
	or	eax, -1
1408
	mcall
1418
	mcall
1409
.redraw:
1419
.redraw:
1410
	call	draw_window
1420
	call	draw_window
1411
	call	hide_cursor
1421
	call	hide_cursor
1412
	jmp	.wait
1422
	jmp	.wait
1413
.key:
1423
.key:
1414
	mov	al, 2
1424
	mov	al, 2
1415
	mcall
1425
	mcall
1416
	cmp	ah, 'y'
1426
	cmp	ah, 'y'
1417
	jz	.yes
1427
	jz	.yes
1418
	cmp	ah, 'Y'
1428
	cmp	ah, 'Y'
1419
	jz	.yes
1429
	jz	.yes
1420
	cmp	ah, 0xD
1430
	cmp	ah, 0xD
1421
	jz	.yes
1431
	jz	.yes
1422
	cmp	ah, 'n'
1432
	cmp	ah, 'n'
1423
	jz	.no
1433
	jz	.no
1424
	cmp	ah, 'N'
1434
	cmp	ah, 'N'
1425
	jnz	.wait
1435
	jnz	.wait
1426
.no:
1436
.no:
1427
	push	40
1437
	push	40
1428
	pop	eax
1438
	pop	eax
1429
	mov	ebx, 0x107
1439
	mov	ebx, 0x107
1430
	mcall
1440
	mcall
1431
	call	draw_cursor
1441
	call	draw_cursor
1432
	mov	esi, aN_str
1442
	mov	esi, aN_str
1433
	jmp	put_message
1443
	jmp	put_message
1434
.yes:
1444
.yes:
1435
	push	40
1445
	push	40
1436
	pop	eax
1446
	pop	eax
1437
	mov	ebx, 0x107
1447
	mov	ebx, 0x107
1438
	mcall
1448
	mcall
1439
	call	draw_cursor
1449
	call	draw_cursor
1440
	mov	esi, aY_str
1450
	mov	esi, aY_str
1441
	call	put_message
1451
	call	put_message
1442
	call	OnUnpack
1452
	call	OnUnpack
1443
	ret
1453
	ret
1444
 
1454
 
1445
mxp_nrv_sig:
1455
mxp_nrv_sig:
1446
	xor	eax, eax
1456
	xor	eax, eax
1447
	mov	ecx, 0x95	; 0xA1 for programs with parameters
1457
	mov	ecx, 0x95	; 0xA1 for programs with parameters
1448
	mov	[eax], ecx
1458
	mov	[eax], ecx
1449
	add	ecx, [eax+24h]
1459
	add	ecx, [eax+24h]
1450
	push	40h
1460
	push	40h
1451
	pop	esi
1461
	pop	esi
1452
	mov	edi, [eax+20h]
1462
	mov	edi, [eax+20h]
1453
	push	edi
1463
	push	edi
1454
	rep	movsb
1464
	rep	movsb
1455
	jmp	dword [esp]
1465
	jmp	dword [esp]
1456
	pop	esi
1466
	pop	esi
1457
	add	esi, [eax]
1467
	add	esi, [eax]
1458
	xor	edi, edi
1468
	xor	edi, edi
1459
mxp_nrv_sig_size = $ - mxp_nrv_sig
1469
mxp_nrv_sig_size = $ - mxp_nrv_sig
1460
 
1470
 
1461
mxp_sig:
1471
mxp_sig:
1462
	mov	ecx, 1CBh
1472
	mov	ecx, 1CBh
1463
	push	46h
1473
	push	46h
1464
	pop	esi
1474
	pop	esi
1465
	mov	edi, [20h]
1475
	mov	edi, [20h]
1466
	rep	movsb
1476
	rep	movsb
1467
	mov	ecx, [24h]
1477
	mov	ecx, [24h]
1468
	rep	movsb
1478
	rep	movsb
1469
	jmp	dword [20h]
1479
	jmp	dword [20h]
1470
	mov	eax, [20h]
1480
	mov	eax, [20h]
1471
	add	eax, 1CBh
1481
	add	eax, 1CBh
1472
	push	eax
1482
	push	eax
1473
	push	dword [24h]
1483
	push	dword [24h]
1474
	push	0
1484
	push	0
1475
	push	8
1485
	push	8
1476
	call	$+0x25
1486
	call	$+0x25
1477
mxp_sig_size = $ - mxp_sig
1487
mxp_sig_size = $ - mxp_sig
1478
 
1488
 
1479
mxp_lzo_sig1:
1489
mxp_lzo_sig1:
1480
	xor	eax, eax
1490
	xor	eax, eax
1481
	mov	ebp, 0FFh
1491
	mov	ebp, 0FFh
1482
	mov	ecx, 175h
1492
	mov	ecx, 175h
1483
	mov	[eax], ecx
1493
	mov	[eax], ecx
1484
	add	ecx, [eax+24h]
1494
	add	ecx, [eax+24h]
1485
	push	45h
1495
	push	45h
1486
	pop	esi
1496
	pop	esi
1487
	mov	edi, [eax+20h]
1497
	mov	edi, [eax+20h]
1488
	push	edi
1498
	push	edi
1489
	rep	movsb
1499
	rep	movsb
1490
	jmp	dword [esp]
1500
	jmp	dword [esp]
1491
	pop	ebx
1501
	pop	ebx
1492
	add	ebx, [eax]
1502
	add	ebx, [eax]
1493
	xor	edi, edi
1503
	xor	edi, edi
1494
	cmp	byte [ebx], 11h
1504
	cmp	byte [ebx], 11h
1495
	jbe	$+0x1A
1505
	jbe	$+0x1A
1496
mxp_lzo_sig1_size = $ - mxp_lzo_sig1
1506
mxp_lzo_sig1_size = $ - mxp_lzo_sig1
1497
mxp_lzo_sig2:
1507
mxp_lzo_sig2:
1498
	xor	eax, eax
1508
	xor	eax, eax
1499
	mov	ebp, 0FFh
1509
	mov	ebp, 0FFh
1500
	mov	ecx, 188h	; or 177h
1510
	mov	ecx, 188h	; or 177h
1501
	mov	[eax], ecx
1511
	mov	[eax], ecx
1502
	add	ecx, [eax+24h]
1512
	add	ecx, [eax+24h]
1503
	push	44h
1513
	push	44h
1504
	pop	esi
1514
	pop	esi
1505
	mov	edi, [eax+20h]
1515
	mov	edi, [eax+20h]
1506
	rep	movsb
1516
	rep	movsb
1507
	jmp	dword [eax+20h]
1517
	jmp	dword [eax+20h]
1508
	mov	ebx, [eax+20h]
1518
	mov	ebx, [eax+20h]
1509
	add	ebx, [eax]
1519
	add	ebx, [eax]
1510
mxp_lzo_sig2_size = $ - mxp_lzo_sig2
1520
mxp_lzo_sig2_size = $ - mxp_lzo_sig2
1511
 
1521
 
1512
OnReload:
1522
OnReload:
1513
	cmp	[debuggee_pid], 0
1523
	cmp	[debuggee_pid], 0
1514
	jnz	terminate_reload
1524
	jnz	terminate_reload
1515
	mov	esi, need_debuggee
1525
	mov	esi, need_debuggee
1516
	cmp	byte [loadname], 0
1526
	cmp	byte [loadname], 0
1517
	jnz	do_reload
1527
	jnz	do_reload
1518
	jz	put_message
1528
	jz	put_message
1519
terminate_reload:
1529
terminate_reload:
1520
	mov	[bReload], 1
1530
	mov	[bReload], 1
1521
OnTerminate:
1531
OnTerminate:
1522
	mov	ecx, [debuggee_pid]
1532
	mov	ecx, [debuggee_pid]
1523
	push	8
1533
	push	8
1524
	pop	ebx
1534
	pop	ebx
1525
	push	69
1535
	push	69
1526
	pop	eax
1536
	pop	eax
1527
	mcall
1537
	mcall
1528
	ret
1538
	ret
1529
 
1539
 
1530
AfterSuspend:
1540
AfterSuspend:
1531
	mov	[bSuspended], 1
1541
	mov	[bSuspended], 1
1532
	call	get_new_context
1542
	call	get_new_context
1533
	call	get_dump
1543
	call	get_dump
1534
	call	redraw_title
1544
	call	redraw_title
1535
	call	redraw_registers
1545
	call	redraw_registers
1536
	call	redraw_dump
1546
	call	redraw_dump
1537
	call	update_disasm_eip
1547
	call	update_disasm_eip
1538
	ret
1548
	ret
1539
 
1549
 
1540
OnSuspend:
1550
OnSuspend:
1541
	mov	ecx, [debuggee_pid]
1551
	mov	ecx, [debuggee_pid]
1542
	push	4
1552
	push	4
1543
	pop	ebx
1553
	pop	ebx
1544
	push	69
1554
	push	69
1545
	pop	eax
1555
	pop	eax
1546
	mcall
1556
	mcall
1547
	call	AfterSuspend
1557
	call	AfterSuspend
1548
	mov	esi, aSuspended
1558
	mov	esi, aSuspended
1549
	jmp	put_message
1559
	jmp	put_message
1550
DoResume:
1560
DoResume:
1551
	mov	ecx, [debuggee_pid]
1561
	mov	ecx, [debuggee_pid]
1552
	push	5
1562
	push	5
1553
	pop	ebx
1563
	pop	ebx
1554
	push	69
1564
	push	69
1555
	pop	eax
1565
	pop	eax
1556
	mcall
1566
	mcall
1557
	mov	[bSuspended], 0
1567
	mov	[bSuspended], 0
1558
	ret
1568
	ret
1559
OnResume:
1569
OnResume:
1560
	mov	esi, [curarg]
1570
	mov	esi, [curarg]
1561
	cmp	byte [esi], 0
1571
	cmp	byte [esi], 0
1562
	jz	GoOn
1572
	jz	GoOn
1563
	call	calc_expression
1573
	call	calc_expression
1564
	jc	.ret
1574
	jc	.ret
1565
	mov	eax, ebp
1575
	mov	eax, ebp
1566
	push	eax
1576
	push	eax
1567
	call	find_enabled_breakpoint
1577
	call	find_enabled_breakpoint
1568
	pop	eax
1578
	pop	eax
1569
	jz	GoOn
1579
	jz	GoOn
1570
	mov	bl, 5	; valid enabled one-shot
1580
	mov	bl, 5	; valid enabled one-shot
1571
	call	add_breakpoint
1581
	call	add_breakpoint
1572
	jnc	GoOn
1582
	jnc	GoOn
1573
	mov	esi, aBreakpointLimitExceeded
1583
	mov	esi, aBreakpointLimitExceeded
1574
	call	put_message
1584
	call	put_message
1575
.ret:
1585
.ret:
1576
	ret
1586
	ret
1577
GoOn:
1587
GoOn:
1578
; test for enabled breakpoint at eip
1588
; test for enabled breakpoint at eip
1579
	mov	eax, [_eip]
1589
	mov	eax, [_eip]
1580
	call	find_enabled_breakpoint
1590
	call	find_enabled_breakpoint
1581
	jnz	.nobreak
1591
	jnz	.nobreak
1582
; temporarily disable breakpoint, make step, enable breakpoint, continue
1592
; temporarily disable breakpoint, make step, enable breakpoint, continue
1583
	inc	eax
1593
	inc	eax
1584
	mov	[temp_break], eax
1594
	mov	[temp_break], eax
1585
	mov	[bAfterGo], 1
1595
	mov	[bAfterGo], 1
1586
	dec	eax
1596
	dec	eax
1587
	call	disable_breakpoint
1597
	call	disable_breakpoint
1588
	call	get_context
1598
	call	get_context
1589
	or	byte [_eflags+1], 1		; set TF
1599
	or	byte [_eflags+1], 1		; set TF
1590
	call	set_context
1600
	call	set_context
1591
	and	byte [_eflags+1], not 1
1601
	and	byte [_eflags+1], not 1
1592
	call	DoResume
1602
	call	DoResume
1593
	ret
1603
	ret
1594
.nobreak:
1604
.nobreak:
1595
	call	DoResume
1605
	call	DoResume
1596
	call	redraw_title
1606
	call	redraw_title
1597
	call	redraw_registers
1607
	call	redraw_registers
1598
	call	redraw_dump
1608
	call	redraw_dump
1599
	ret
1609
	ret
1600
OnDetach:
1610
OnDetach:
1601
	mov	ecx, [debuggee_pid]
1611
	mov	ecx, [debuggee_pid]
1602
	push	3
1612
	push	3
1603
	pop	ebx
1613
	pop	ebx
1604
	push	69
1614
	push	69
1605
	pop	eax
1615
	pop	eax
1606
	mcall
1616
	mcall
1607
	and	[debuggee_pid], 0
1617
	and	[debuggee_pid], 0
1608
	call	redraw_title
1618
	call	redraw_title
1609
	call	redraw_registers
1619
	call	redraw_registers
1610
	call	redraw_dump
1620
	call	redraw_dump
1611
	call	free_symbols
1621
	call	free_symbols
1612
	mov	esi, aContinued
1622
	mov	esi, aContinued
1613
	jmp	put_message
1623
	jmp	put_message
1614
 
1624
 
1615
after_go_exception:
1625
after_go_exception:
1616
	push	eax
1626
	push	eax
1617
	mov	eax, [temp_break]
1627
	mov	eax, [temp_break]
1618
	dec	eax
1628
	dec	eax
1619
	push	esi
1629
	push	esi
1620
	call	enable_breakpoint
1630
	call	enable_breakpoint
1621
; in any case, clear TF and RF
1631
; in any case, clear TF and RF
1622
	call	get_new_context
1632
	call	get_new_context
1623
	and	[_eflags], not 10100h		; clear TF,RF
1633
	and	[_eflags], not 10100h		; clear TF,RF
1624
	call	set_context
1634
	call	set_context
1625
	xor	edx, edx
1635
	xor	edx, edx
1626
	mov	[temp_break], edx
1636
	mov	[temp_break], edx
1627
	xchg	dl, [bAfterGo]
1637
	xchg	dl, [bAfterGo]
1628
	pop	esi
1638
	pop	esi
1629
	pop	eax
1639
	pop	eax
1630
	cmp	dl, 2
1640
	cmp	dl, 2
1631
	jnz	@f
1641
	jnz	@f
1632
	lodsd
1642
	lodsd
1633
	push	esi
1643
	push	esi
1634
	call	get_dump
1644
	call	get_dump
1635
	jmp	exception.done
1645
	jmp	exception.done
1636
@@:	test	eax, eax
1646
@@:	test	eax, eax
1637
	jz	.notint1
1647
	jz	.notint1
1638
; if exception is result of single step, simply ignore it and continue
1648
; if exception is result of single step, simply ignore it and continue
1639
	test	dword [esi], 0xF
1649
	test	dword [esi], 0xF
1640
	jnz	dbgmsgstart.5
1650
	jnz	dbgmsgstart.5
1641
	lodsd
1651
	lodsd
1642
	push	esi
1652
	push	esi
1643
	mov	esi, oldcontext
1653
	mov	esi, oldcontext
1644
	mov	edi, context
1654
	mov	edi, context
1645
	mov	ecx, 28h/4
1655
	mov	ecx, 28h/4
1646
	rep	movsd
1656
	rep	movsd
1647
	call	DoResume
1657
	call	DoResume
1648
	jmp	dbgmsgend
1658
	jmp	dbgmsgend
1649
.notint1:
1659
.notint1:
1650
; in other case, work as without temp_break
1660
; in other case, work as without temp_break
1651
	lodsd
1661
	lodsd
1652
	push	esi
1662
	push	esi
1653
	push	eax
1663
	push	eax
1654
	jmp	exception.4
1664
	jmp	exception.4
1655
.notour:
1665
.notour:
1656
 
1666
 
1657
debugmsg:
1667
debugmsg:
1658
	neg	[dbgbufsize]
1668
	neg	[dbgbufsize]
1659
	mov	esi, dbgbuf
1669
	mov	esi, dbgbuf
1660
dbgmsgstart:
1670
dbgmsgstart:
1661
	lodsd
1671
	lodsd
1662
;	push	eax esi
1672
;	push	eax esi
1663
;	push	dword [esi]
1673
;	push	dword [esi]
1664
;	mov	esi, dbgmsg_str
1674
;	mov	esi, dbgmsg_str
1665
;	call	put_message_nodraw
1675
;	call	put_message_nodraw
1666
;	pop	esi eax
1676
;	pop	esi eax
1667
	add	esi, 4
1677
	add	esi, 4
1668
	dec	eax
1678
	dec	eax
1669
	jz	exception
1679
	jz	exception
1670
	dec	eax
1680
	dec	eax
1671
	jz	terminated
1681
	jz	terminated
1672
	mov	[bSuspended], 1
1682
	mov	[bSuspended], 1
1673
	cmp	[bAfterGo], 0
1683
	cmp	[bAfterGo], 0
1674
	jnz	after_go_exception
1684
	jnz	after_go_exception
1675
	push	esi
1685
	push	esi
1676
	call	get_new_context
1686
	call	get_new_context
1677
	and	[_eflags], not 10100h		; clear TF,RF
1687
	and	[_eflags], not 10100h		; clear TF,RF
1678
	call	set_context
1688
	call	set_context
1679
	pop	esi
1689
	pop	esi
1680
.5:
1690
.5:
1681
	push	esi
1691
	push	esi
1682
	call	get_dump
1692
	call	get_dump
1683
	pop	esi
1693
	pop	esi
1684
	lodsd
1694
	lodsd
1685
	xor	ecx, ecx
1695
	xor	ecx, ecx
1686
.6:
1696
.6:
1687
	bt	eax, ecx
1697
	bt	eax, ecx
1688
	jnc	.7
1698
	jnc	.7
1689
	mov	ebx, [drx_break+ecx*4]
1699
	mov	ebx, [drx_break+ecx*4]
1690
	test	ebx, ebx
1700
	test	ebx, ebx
1691
	jz	.7
1701
	jz	.7
1692
	pushad
1702
	pushad
1693
	dec	ebx
1703
	dec	ebx
1694
	push	ebx
1704
	push	ebx
1695
	mov	esi, aBreakStop
1705
	mov	esi, aBreakStop
1696
	call	put_message_nodraw
1706
	call	put_message_nodraw
1697
	popad
1707
	popad
1698
.7:
1708
.7:
1699
	inc	ecx
1709
	inc	ecx
1700
	cmp	cl, 4
1710
	cmp	cl, 4
1701
	jb	.6
1711
	jb	.6
1702
	push	esi
1712
	push	esi
1703
	jmp	exception.done_draw
1713
	jmp	exception.done_draw
1704
terminated:
1714
terminated:
1705
	push	esi
1715
	push	esi
1706
	mov	esi, terminated_msg
1716
	mov	esi, terminated_msg
1707
	call	put_message
1717
	call	put_message
1708
	and	[debuggee_pid], 0
1718
	and	[debuggee_pid], 0
1709
	and	[temp_break], 0
1719
	and	[temp_break], 0
1710
	mov	[bAfterGo], 0
1720
	mov	[bAfterGo], 0
1711
	xor	eax, eax
1721
	xor	eax, eax
1712
	mov	ecx, breakpoints_n*6/4+4
1722
	mov	ecx, breakpoints_n*6/4+4
1713
	mov	edi, breakpoints
1723
	mov	edi, breakpoints
1714
	rep	stosd
1724
	rep	stosd
1715
	cmp	[bReload], 1
1725
	cmp	[bReload], 1
1716
	sbb	[bReload], -1
1726
	sbb	[bReload], -1
1717
	jnz	exception.done
1727
	jnz	exception.done
1718
	call	free_symbols
1728
	call	free_symbols
1719
	jmp	exception.done
1729
	jmp	exception.done
1720
exception:
1730
exception:
1721
	mov	[bSuspended], 1
1731
	mov	[bSuspended], 1
1722
	cmp	[bAfterGo], 0
1732
	cmp	[bAfterGo], 0
1723
	jnz	after_go_exception
1733
	jnz	after_go_exception
1724
	lodsd
1734
	lodsd
1725
	push	esi
1735
	push	esi
1726
	push	eax
1736
	push	eax
1727
	call	get_new_context
1737
	call	get_new_context
1728
	and	[_eflags], not 10100h		; clear TF,RF
1738
	and	[_eflags], not 10100h		; clear TF,RF
1729
	call	set_context
1739
	call	set_context
1730
.4:
1740
.4:
1731
	call	get_dump
1741
	call	get_dump
1732
	pop	eax
1742
	pop	eax
1733
; int3 command generates exception 0D, #GP
1743
; int3 command generates exception 0D, #GP
1734
	push	eax
1744
	push	eax
1735
	cmp	al, 0Dh
1745
	cmp	al, 0Dh
1736
	jnz	.notdbg
1746
	jnz	.notdbg
1737
; check for 0xCC byte at eip
1747
; check for 0xCC byte at eip
1738
	push	0
1748
	push	0
1739
	push	69
1749
	push	69
1740
	pop	eax
1750
	pop	eax
1741
	push	6
1751
	push	6
1742
	pop	ebx
1752
	pop	ebx
1743
	mov	ecx, [debuggee_pid]
1753
	mov	ecx, [debuggee_pid]
1744
	mov	edi, esp
1754
	mov	edi, esp
1745
	mov	esi, [_eip]
1755
	mov	esi, [_eip]
1746
	push	1
1756
	push	1
1747
	pop	edx
1757
	pop	edx
1748
	mcall
1758
	mcall
1749
	pop	eax
1759
	pop	eax
1750
	cmp	al, 0xCC
1760
	cmp	al, 0xCC
1751
	jnz	.notdbg
1761
	jnz	.notdbg
1752
; this is either dbg breakpoint or int3 cmd in debuggee
1762
; this is either dbg breakpoint or int3 cmd in debuggee
1753
	mov	eax, [_eip]
1763
	mov	eax, [_eip]
1754
	call	find_enabled_breakpoint
1764
	call	find_enabled_breakpoint
1755
	jnz	.user_int3
1765
	jnz	.user_int3
1756
; dbg breakpoint; clear if one-shot
1766
; dbg breakpoint; clear if one-shot
1757
	pop	ecx
1767
	pop	ecx
1758
	push	eax
1768
	push	eax
1759
	mov	esi, aBreakStop
1769
	mov	esi, aBreakStop
1760
	test	byte [edi+4], 4
1770
	test	byte [edi+4], 4
1761
	jz	.put_msg_eax
1771
	jz	.put_msg_eax
1762
	pop	ecx
1772
	pop	ecx
1763
	call	clear_breakpoint
1773
	call	clear_breakpoint
1764
	jmp	.done
1774
	jmp	.done
1765
.user_int3:
1775
.user_int3:
1766
	mov	eax, [_eip]
1776
	mov	eax, [_eip]
1767
	inc	[_eip]
1777
	inc	[_eip]
1768
	pop	ecx
1778
	pop	ecx
1769
	push	eax
1779
	push	eax
1770
	call	set_context
1780
	call	set_context
1771
	mov	esi, aUserBreak
1781
	mov	esi, aUserBreak
1772
	jmp	.put_msg_eax
1782
	jmp	.put_msg_eax
1773
.notdbg:
1783
.notdbg:
1774
	mov	esi, aException
1784
	mov	esi, aException
1775
.put_msg_eax:
1785
.put_msg_eax:
1776
	call	put_message_nodraw
1786
	call	put_message_nodraw
1777
.done_draw:
1787
.done_draw:
1778
	call	draw_messages
1788
	call	draw_messages
1779
.done:
1789
.done:
1780
	push	18
1790
	push	18
1781
	pop	eax
1791
	pop	eax
1782
	push	3
1792
	push	3
1783
	pop	ebx
1793
	pop	ebx
1784
	mov	ecx, [dbgwnd]
1794
	mov	ecx, [dbgwnd]
1785
	mcall	; activate dbg window
1795
	mcall	; activate dbg window
1786
	call	redraw_title
1796
	call	redraw_title
1787
	call	redraw_registers
1797
	call	redraw_registers
1788
	call	redraw_dump
1798
	call	redraw_dump
1789
	call	update_disasm_eip
1799
	call	update_disasm_eip
1790
dbgmsgend:
1800
dbgmsgend:
1791
	pop	esi
1801
	pop	esi
1792
	mov	ecx, [dbgbuflen]
1802
	mov	ecx, [dbgbuflen]
1793
	add	ecx, dbgbuf
1803
	add	ecx, dbgbuf
1794
	cmp	esi, ecx
1804
	cmp	esi, ecx
1795
	jnz	dbgmsgstart
1805
	jnz	dbgmsgstart
1796
	and	[dbgbuflen], 0
1806
	and	[dbgbuflen], 0
1797
	neg	[dbgbufsize]
1807
	neg	[dbgbufsize]
1798
	cmp	[bReload], 2
1808
	cmp	[bReload], 2
1799
	jnz	@f
1809
	jnz	@f
1800
	mov	[bReload], 0
1810
	mov	[bReload], 0
1801
	call	do_reload
1811
	call	do_reload
1802
@@:
1812
@@:
1803
	jmp	waitevent
1813
	jmp	waitevent
1804
 
1814
 
1805
CtrlF7:
1815
CtrlF7:
1806
	cmp	[debuggee_pid], 0
1816
	cmp	[debuggee_pid], 0
1807
	jz	.no
1817
	jz	.no
1808
	call	OnStep
1818
	call	OnStep
1809
.no:
1819
.no:
1810
	jmp	waitevent
1820
	jmp	waitevent
1811
CtrlF8:
1821
CtrlF8:
1812
	cmp	[debuggee_pid], 0
1822
	cmp	[debuggee_pid], 0
1813
	jz	CtrlF7.no
1823
	jz	CtrlF7.no
1814
	call	OnProceed
1824
	call	OnProceed
1815
	jmp	CtrlF7.no
1825
	jmp	CtrlF7.no
1816
 
1826
 
1817
OnStep:
1827
OnStep:
1818
	cmp	[bSuspended], 0
1828
	cmp	[bSuspended], 0
1819
	jz	.running
1829
	jz	.running
1820
	call	get_context
1830
	call	get_context
1821
	or	byte [_eflags+1], 1		; set TF
1831
	or	byte [_eflags+1], 1		; set TF
1822
	call	set_context
1832
	call	set_context
1823
	and	byte [_eflags+1], not 1
1833
	and	byte [_eflags+1], not 1
1824
; if instruction at eip is "int xx", set one-shot breakpoint immediately after
1834
; if instruction at eip is "int xx", set one-shot breakpoint immediately after
1825
	mov	eax, [_eip]
1835
	mov	eax, [_eip]
1826
	call	find_enabled_breakpoint
1836
	call	find_enabled_breakpoint
1827
	jnz	@f
1837
	jnz	@f
1828
	cmp	byte [edi+5], 0xCD
1838
	cmp	byte [edi+5], 0xCD
1829
	jz	.int
1839
	jz	.int
1830
@@:
1840
@@:
1831
	push	0
1841
	push	0
1832
	push	69
1842
	push	69
1833
	pop	eax
1843
	pop	eax
1834
	push	6
1844
	push	6
1835
	pop	ebx
1845
	pop	ebx
1836
	mov	ecx, [debuggee_pid]
1846
	mov	ecx, [debuggee_pid]
1837
	push	3
1847
	push	3
1838
	pop	edx
1848
	pop	edx
1839
	mov	edi, esp
1849
	mov	edi, esp
1840
	mov	esi, [_eip]
1850
	mov	esi, [_eip]
1841
	mcall
1851
	mcall
1842
	cmp	eax, edx
1852
	cmp	eax, edx
1843
	pop	eax
1853
	pop	eax
1844
	jnz	.doit
1854
	jnz	.doit
1845
	cmp	al, 0xCD
1855
	cmp	al, 0xCD
1846
	jz	.int
1856
	jz	.int
1847
	cmp	ax, 0x050F
1857
	cmp	ax, 0x050F
1848
	jz	.syscall
1858
	jz	.syscall
1849
	cmp	ax, 0x340F
1859
	cmp	ax, 0x340F
1850
	jz	.sysenter
1860
	jz	.sysenter
1851
; resume process
1861
; resume process
1852
.doit:
1862
.doit:
1853
	call	GoOn
1863
	call	GoOn
1854
	cmp	[bAfterGo], 0
1864
	cmp	[bAfterGo], 0
1855
	jz	@f
1865
	jz	@f
1856
	mov	[bAfterGo], 2
1866
	mov	[bAfterGo], 2
1857
@@:
1867
@@:
1858
	ret
1868
	ret
1859
.sysenter:	; return address is [ebp-4]
1869
.sysenter:	; return address is [ebp-4]
1860
	push	0
1870
	push	0
1861
	push	69
1871
	push	69
1862
	pop	eax
1872
	pop	eax
1863
	inc	edx	; read 4 bytes
1873
	inc	edx	; read 4 bytes
1864
	mov	esi, [_ebp]
1874
	mov	esi, [_ebp]
1865
	sub	esi, 4
1875
	sub	esi, 4
1866
	mcall
1876
	mcall
1867
	cmp	eax, edx
1877
	cmp	eax, edx
1868
	pop	eax
1878
	pop	eax
1869
	jnz	.syscall
1879
	jnz	.syscall
1870
	push	eax
1880
	push	eax
1871
	and	byte [_eflags+1], not 1
1881
	and	byte [_eflags+1], not 1
1872
	call	set_context
1882
	call	set_context
1873
	pop	eax
1883
	pop	eax
1874
	jmp	@f
1884
	jmp	@f
1875
.syscall:
1885
.syscall:
1876
	and	byte [_eflags+1], not 1	; clear TF - avoid system halt (!)
1886
	and	byte [_eflags+1], not 1	; clear TF - avoid system halt (!)
1877
	call	set_context
1887
	call	set_context
1878
.int:
1888
.int:
1879
	mov	eax, [_eip]
1889
	mov	eax, [_eip]
1880
	inc	eax
1890
	inc	eax
1881
	inc	eax
1891
	inc	eax
1882
@@:
1892
@@:
1883
	push	eax
1893
	push	eax
1884
	call	find_enabled_breakpoint
1894
	call	find_enabled_breakpoint
1885
	pop	eax
1895
	pop	eax
1886
	jz	.doit
1896
	jz	.doit
1887
; there is no enabled breakpoint yet; set temporary breakpoint
1897
; there is no enabled breakpoint yet; set temporary breakpoint
1888
	mov	bl, 5
1898
	mov	bl, 5
1889
	call	add_breakpoint
1899
	call	add_breakpoint
1890
	jmp	.doit
1900
	jmp	.doit
1891
.running:
1901
.running:
1892
	mov	esi, aRunningErr
1902
	mov	esi, aRunningErr
1893
	jmp	put_message
1903
	jmp	put_message
1894
 
1904
 
1895
OnProceed:
1905
OnProceed:
1896
	cmp	[bSuspended], 0
1906
	cmp	[bSuspended], 0
1897
	jz	OnStep.running
1907
	jz	OnStep.running
1898
	mov	esi, [_eip]
1908
	mov	esi, [_eip]
1899
@@:
1909
@@:
1900
	call	get_byte_nobreak
1910
	call	get_byte_nobreak
1901
	jc	OnStep
1911
	jc	OnStep
1902
	inc	esi
1912
	inc	esi
1903
; skip prefixes
1913
; skip prefixes
1904
	call	is_prefix
1914
	call	is_prefix
1905
	jz	@b
1915
	jz	@b
1906
	cmp	al, 0xE8	; call
1916
	cmp	al, 0xE8	; call
1907
	jnz	@f
1917
	jnz	@f
1908
	add	esi, 4
1918
	add	esi, 4
1909
	jmp	.doit
1919
	jmp	.doit
1910
@@:	; A4,A5 = movs, A6,A7=cmps
1920
@@:	; A4,A5 = movs, A6,A7=cmps
1911
	cmp	al, 0xA4
1921
	cmp	al, 0xA4
1912
	jb	@f
1922
	jb	@f
1913
	cmp	al, 0xA8
1923
	cmp	al, 0xA8
1914
	jb	.doit
1924
	jb	.doit
1915
@@:	; AA,AB=stos, AC,AD=lods, AE,AF=scas
1925
@@:	; AA,AB=stos, AC,AD=lods, AE,AF=scas
1916
	cmp	al, 0xAA
1926
	cmp	al, 0xAA
1917
	jb	@f
1927
	jb	@f
1918
	cmp	al, 0xB0
1928
	cmp	al, 0xB0
1919
	jb	.doit
1929
	jb	.doit
1920
@@:	; E0=loopnz,E1=loopz,E2=loop
1930
@@:	; E0=loopnz,E1=loopz,E2=loop
1921
	cmp	al, 0xE0
1931
	cmp	al, 0xE0
1922
	jb	.noloop
1932
	jb	.noloop
1923
	cmp	al, 0xE2
1933
	cmp	al, 0xE2
1924
	ja	.noloop
1934
	ja	.noloop
1925
	inc	esi
1935
	inc	esi
1926
	jmp	.doit
1936
	jmp	.doit
1927
.noloop:	; FF /2 = call
1937
.noloop:	; FF /2 = call
1928
	cmp	al, 0xFF
1938
	cmp	al, 0xFF
1929
	jnz	OnStep
1939
	jnz	OnStep
1930
	call	get_byte_nobreak
1940
	call	get_byte_nobreak
1931
	jc	OnStep
1941
	jc	OnStep
1932
	inc	esi
1942
	inc	esi
1933
	mov	cl, al
1943
	mov	cl, al
1934
	and	al, 00111000b
1944
	and	al, 00111000b
1935
	cmp	al, 00010000b
1945
	cmp	al, 00010000b
1936
	jnz	OnStep
1946
	jnz	OnStep
1937
; skip instruction
1947
; skip instruction
1938
	mov	al, cl
1948
	mov	al, cl
1939
	and	eax, 7
1949
	and	eax, 7
1940
	shr	cl, 6
1950
	shr	cl, 6
1941
	jz	.mod0
1951
	jz	.mod0
1942
	jp	.doit
1952
	jp	.doit
1943
	cmp	al, 4
1953
	cmp	al, 4
1944
	jnz	@f
1954
	jnz	@f
1945
	inc	esi
1955
	inc	esi
1946
@@:
1956
@@:
1947
	inc	esi
1957
	inc	esi
1948
	dec	cl
1958
	dec	cl
1949
	jz	@f
1959
	jz	@f
1950
	add	esi, 3
1960
	add	esi, 3
1951
@@:
1961
@@:
1952
	jmp	.doit
1962
	jmp	.doit
1953
.mod0:
1963
.mod0:
1954
	cmp	al, 4
1964
	cmp	al, 4
1955
	jnz	@f
1965
	jnz	@f
1956
	call	get_byte_nobreak
1966
	call	get_byte_nobreak
1957
	jc	OnStep
1967
	jc	OnStep
1958
	inc	esi
1968
	inc	esi
1959
	and	al, 7
1969
	and	al, 7
1960
@@:
1970
@@:
1961
	cmp	al, 5
1971
	cmp	al, 5
1962
	jnz	.doit
1972
	jnz	.doit
1963
	add	esi, 4
1973
	add	esi, 4
1964
.doit:
1974
.doit:
1965
; insert one-shot breakpoint at esi and resume
1975
; insert one-shot breakpoint at esi and resume
1966
	call	get_byte_nobreak
1976
	call	get_byte_nobreak
1967
	jc	OnStep
1977
	jc	OnStep
1968
	mov	eax, esi
1978
	mov	eax, esi
1969
	call	find_enabled_breakpoint
1979
	call	find_enabled_breakpoint
1970
	jz	.ret
1980
	jz	.ret
1971
	mov	eax, esi
1981
	mov	eax, esi
1972
	mov	bl, 5
1982
	mov	bl, 5
1973
	call	add_breakpoint
1983
	call	add_breakpoint
1974
	jmp	OnStep.doit
1984
	jmp	OnStep.doit
1975
.ret:
1985
.ret:
1976
	ret
1986
	ret
1977
 
1987
 
1978
get_byte_nobreak:
1988
get_byte_nobreak:
1979
	mov	eax, esi
1989
	mov	eax, esi
1980
	call	find_enabled_breakpoint
1990
	call	find_enabled_breakpoint
1981
	jnz	.nobreak
1991
	jnz	.nobreak
1982
	mov	al, [edi+5]
1992
	mov	al, [edi+5]
1983
	clc
1993
	clc
1984
	ret
1994
	ret
1985
.nobreak:
1995
.nobreak:
1986
	push	69
1996
	push	69
1987
	pop	eax
1997
	pop	eax
1988
	push	6
1998
	push	6
1989
	pop	ebx
1999
	pop	ebx
1990
	mov	ecx, [debuggee_pid]
2000
	mov	ecx, [debuggee_pid]
1991
	xor	edx, edx
2001
	xor	edx, edx
1992
	push	edx
2002
	push	edx
1993
	inc	edx
2003
	inc	edx
1994
	mov	edi, esp
2004
	mov	edi, esp
1995
	mcall
2005
	mcall
1996
	dec	eax
2006
	dec	eax
1997
	clc
2007
	clc
1998
	jz	@f
2008
	jz	@f
1999
	stc
2009
	stc
2000
@@:	pop	eax
2010
@@:	pop	eax
2001
	ret
2011
	ret
2002
 
2012
 
2003
is_prefix:
2013
is_prefix:
2004
	cmp	al, 0x64	; fs:
2014
	cmp	al, 0x64	; fs:
2005
	jz	.ret
2015
	jz	.ret
2006
	cmp	al, 0x65	; gs:
2016
	cmp	al, 0x65	; gs:
2007
	jz	.ret
2017
	jz	.ret
2008
	cmp	al, 0x66	; use16/32
2018
	cmp	al, 0x66	; use16/32
2009
	jz	.ret
2019
	jz	.ret
2010
	cmp	al, 0x67	; addr16/32
2020
	cmp	al, 0x67	; addr16/32
2011
	jz	.ret
2021
	jz	.ret
2012
	cmp	al, 0xF0	; lock
2022
	cmp	al, 0xF0	; lock
2013
	jz	.ret
2023
	jz	.ret
2014
	cmp	al, 0xF2	; repnz
2024
	cmp	al, 0xF2	; repnz
2015
	jz	.ret
2025
	jz	.ret
2016
	cmp	al, 0xF3	; rep(z)
2026
	cmp	al, 0xF3	; rep(z)
2017
	jz	.ret
2027
	jz	.ret
2018
	cmp	al, 0x2E	; cs:
2028
	cmp	al, 0x2E	; cs:
2019
	jz	.ret
2029
	jz	.ret
2020
	cmp	al, 0x36	; ss:
2030
	cmp	al, 0x36	; ss:
2021
	jz	.ret
2031
	jz	.ret
2022
	cmp	al, 0x3E	; ds:
2032
	cmp	al, 0x3E	; ds:
2023
	jz	.ret
2033
	jz	.ret
2024
	cmp	al, 0x26	; es:
2034
	cmp	al, 0x26	; es:
2025
.ret:	ret
2035
.ret:	ret
2026
 
2036
 
2027
token_end	equ	1
2037
token_end	equ	1
2028
token_reg	equ	2
2038
token_reg	equ	2
2029
token_hex	equ	3
2039
token_hex	equ	3
2030
token_add	equ	4
2040
token_add	equ	4
2031
token_sub	equ	5
2041
token_sub	equ	5
2032
token_mul	equ	6
2042
token_mul	equ	6
2033
token_div	equ	7
2043
token_div	equ	7
2034
token_lp	equ	8
2044
token_lp	equ	8
2035
token_rp	equ	9
2045
token_rp	equ	9
2036
token_err	equ	-1
2046
token_err	equ	-1
2037
 
2047
 
2038
is_hex_digit:
2048
is_hex_digit:
2039
	cmp	al, '0'
2049
	cmp	al, '0'
2040
	jb	.no
2050
	jb	.no
2041
	cmp	al, '9'
2051
	cmp	al, '9'
2042
	jbe	.09
2052
	jbe	.09
2043
	cmp	al, 'A'
2053
	cmp	al, 'A'
2044
	jb	.no
2054
	jb	.no
2045
	cmp	al, 'F'
2055
	cmp	al, 'F'
2046
	jbe	.AF
2056
	jbe	.AF
2047
	cmp	al, 'a'
2057
	cmp	al, 'a'
2048
	jb	.no
2058
	jb	.no
2049
	cmp	al, 'f'
2059
	cmp	al, 'f'
2050
	jbe	.af
2060
	jbe	.af
2051
.no:
2061
.no:
2052
	stc
2062
	stc
2053
	ret
2063
	ret
2054
.09:
2064
.09:
2055
	sub	al, '0'
2065
	sub	al, '0'
2056
;	clc
2066
;	clc
2057
	ret
2067
	ret
2058
.AF:
2068
.AF:
2059
	sub	al, 'A'-10
2069
	sub	al, 'A'-10
2060
;	clc
2070
;	clc
2061
	ret
2071
	ret
2062
.af:
2072
.af:
2063
	sub	al, 'a'-10
2073
	sub	al, 'a'-10
2064
;	clc
2074
;	clc
2065
	ret
2075
	ret
2066
 
2076
 
2067
find_reg:
2077
find_reg:
2068
	mov	edi, reg_table
2078
	mov	edi, reg_table
2069
.findreg:
2079
.findreg:
2070
	movzx	ecx, byte [edi]
2080
	movzx	ecx, byte [edi]
2071
	stc
2081
	stc
2072
	jecxz	.regnotfound
2082
	jecxz	.regnotfound
2073
	inc	edi
2083
	inc	edi
2074
	push	esi edi ecx
2084
	push	esi edi ecx
2075
@@:
2085
@@:
2076
	lodsb
2086
	lodsb
2077
	or	al, 20h
2087
	or	al, 20h
2078
	scasb
2088
	scasb
2079
	loopz	@b
2089
	loopz	@b
2080
	pop	ecx edi esi
2090
	pop	ecx edi esi
2081
	lea	edi, [edi+ecx+1]
2091
	lea	edi, [edi+ecx+1]
2082
	jnz	.findreg
2092
	jnz	.findreg
2083
	movzx	edi, byte [edi-1]
2093
	movzx	edi, byte [edi-1]
2084
	add	esi, ecx
2094
	add	esi, ecx
2085
.regnotfound:
2095
.regnotfound:
2086
	ret
2096
	ret
2087
 
2097
 
2088
expr_get_token:
2098
expr_get_token:
2089
	lodsb
2099
	lodsb
2090
	cmp	al, 0
2100
	cmp	al, 0
2091
	jz	.end_token
2101
	jz	.end_token
2092
	cmp	al, ' '
2102
	cmp	al, ' '
2093
	jbe	expr_get_token
2103
	jbe	expr_get_token
2094
	cmp	al, '+'
2104
	cmp	al, '+'
2095
	jz	.add
2105
	jz	.add
2096
	cmp	al, '-'
2106
	cmp	al, '-'
2097
	jz	.sub
2107
	jz	.sub
2098
	cmp	al, '*'
2108
	cmp	al, '*'
2099
	jz	.mul
2109
	jz	.mul
2100
	cmp	al, '/'
2110
	cmp	al, '/'
2101
	jz	.div
2111
	jz	.div
2102
	cmp	al, '('
2112
	cmp	al, '('
2103
	jz	.lp
2113
	jz	.lp
2104
	cmp	al, ')'
2114
	cmp	al, ')'
2105
	jnz	.notsign
2115
	jnz	.notsign
2106
.rp:
2116
.rp:
2107
	mov	al, token_rp
2117
	mov	al, token_rp
2108
	ret
2118
	ret
2109
.div:
2119
.div:
2110
	mov	al, token_div
2120
	mov	al, token_div
2111
	ret
2121
	ret
2112
.end_token:
2122
.end_token:
2113
	mov	al, token_end
2123
	mov	al, token_end
2114
	ret
2124
	ret
2115
.add:
2125
.add:
2116
	mov	al, token_add
2126
	mov	al, token_add
2117
	ret
2127
	ret
2118
.sub:
2128
.sub:
2119
	mov	al, token_sub
2129
	mov	al, token_sub
2120
	ret
2130
	ret
2121
.mul:
2131
.mul:
2122
	mov	al, token_mul
2132
	mov	al, token_mul
2123
	ret
2133
	ret
2124
.lp:
2134
.lp:
2125
	mov	al, token_lp
2135
	mov	al, token_lp
2126
	ret
2136
	ret
2127
.notsign:
2137
.notsign:
2128
	dec	esi
2138
	dec	esi
2129
	call	find_reg
2139
	call	find_reg
2130
	jc	.regnotfound
2140
	jc	.regnotfound
2131
	mov	al, token_reg
2141
	mov	al, token_reg
2132
	ret
2142
	ret
2133
.regnotfound:
2143
.regnotfound:
2134
; test for symbol
2144
; test for symbol
2135
	push	esi
2145
	push	esi
2136
@@:
2146
@@:
2137
	lodsb
2147
	lodsb
2138
	cmp	al, ' '
2148
	cmp	al, ' '
2139
	ja	@b
2149
	ja	@b
2140
	push	eax
2150
	push	eax
2141
	mov	byte [esi], 0
2151
	mov	byte [esi], 0
2142
	xchg	esi, [esp+4]
2152
	xchg	esi, [esp+4]
2143
	call	find_symbol_name
2153
	call	find_symbol_name
2144
	mov	edi, eax
2154
	mov	edi, eax
2145
	pop	eax
2155
	pop	eax
2146
	xchg	esi, [esp]
2156
	xchg	esi, [esp]
2147
	mov	byte [esi], al
2157
	mov	byte [esi], al
2148
	jc	@f
2158
	jc	@f
2149
	add	esp, 4
2159
	add	esp, 4
2150
	mov	al, token_hex
2160
	mov	al, token_hex
2151
	ret
2161
	ret
2152
@@:
2162
@@:
2153
	pop	esi
2163
	pop	esi
2154
; test for hex number
2164
; test for hex number
2155
	xor	ecx, ecx
2165
	xor	ecx, ecx
2156
	xor	edi, edi
2166
	xor	edi, edi
2157
	xor	eax, eax
2167
	xor	eax, eax
2158
@@:
2168
@@:
2159
	lodsb
2169
	lodsb
2160
	call	is_hex_digit
2170
	call	is_hex_digit
2161
	jc	@f
2171
	jc	@f
2162
	shl	edi, 4
2172
	shl	edi, 4
2163
	or	edi, eax
2173
	or	edi, eax
2164
	inc	ecx
2174
	inc	ecx
2165
	jmp	@b
2175
	jmp	@b
2166
@@:
2176
@@:
2167
	dec	esi
2177
	dec	esi
2168
	jecxz	.err
2178
	jecxz	.err
2169
	cmp	ecx, 8
2179
	cmp	ecx, 8
2170
	ja	.err
2180
	ja	.err
2171
	mov	al, token_hex
2181
	mov	al, token_hex
2172
	ret
2182
	ret
2173
.err:
2183
.err:
2174
	mov	al, token_err
2184
	mov	al, token_err
2175
	mov	esi, aParseError
2185
	mov	esi, aParseError
2176
	ret
2186
	ret
2177
 
2187
 
2178
expr_read2:
2188
expr_read2:
2179
	cmp	al, token_hex
2189
	cmp	al, token_hex
2180
	jz	.hex
2190
	jz	.hex
2181
	cmp	al, token_reg
2191
	cmp	al, token_reg
2182
	jz	.reg
2192
	jz	.reg
2183
	cmp	al, token_lp
2193
	cmp	al, token_lp
2184
	jz	.lp
2194
	jz	.lp
2185
	mov	al, token_err
2195
	mov	al, token_err
2186
	mov	esi, aParseError
2196
	mov	esi, aParseError
2187
	ret
2197
	ret
2188
.hex:
2198
.hex:
2189
	mov	ebp, edi
2199
	mov	ebp, edi
2190
.ret:
2200
.ret:
2191
	jmp	expr_get_token
2201
	jmp	expr_get_token
2192
.reg:
2202
.reg:
2193
	cmp	edi, 24
2203
	cmp	edi, 24
2194
	jz	.eip
2204
	jz	.eip
2195
	sub	edi, 4
2205
	sub	edi, 4
2196
	jb	.8lo
2206
	jb	.8lo
2197
	sub	edi, 4
2207
	sub	edi, 4
2198
	jb	.8hi
2208
	jb	.8hi
2199
	sub	edi, 8
2209
	sub	edi, 8
2200
	jb	.16
2210
	jb	.16
2201
	mov	ebp, [_eax+edi*4]
2211
	mov	ebp, [_eax+edi*4]
2202
	jmp	.ret
2212
	jmp	.ret
2203
.16:
2213
.16:
2204
	movzx	ebp, word [_eax+(edi+8)*4]
2214
	movzx	ebp, word [_eax+(edi+8)*4]
2205
	jmp	.ret
2215
	jmp	.ret
2206
.8lo:
2216
.8lo:
2207
	movzx	ebp, byte [_eax+(edi+4)*4]
2217
	movzx	ebp, byte [_eax+(edi+4)*4]
2208
	jmp	.ret
2218
	jmp	.ret
2209
.8hi:
2219
.8hi:
2210
	movzx	ebp, byte [_eax+(edi+4)*4+1]
2220
	movzx	ebp, byte [_eax+(edi+4)*4+1]
2211
	jmp	.ret
2221
	jmp	.ret
2212
.eip:
2222
.eip:
2213
	mov	ebp, [_eip]
2223
	mov	ebp, [_eip]
2214
	jmp	.ret
2224
	jmp	.ret
2215
.lp:
2225
.lp:
2216
	call	expr_get_token
2226
	call	expr_get_token
2217
	call	expr_read0
2227
	call	expr_read0
2218
	cmp	al, token_err
2228
	cmp	al, token_err
2219
	jz	@f
2229
	jz	@f
2220
	cmp	al, token_rp
2230
	cmp	al, token_rp
2221
	jz	expr_get_token
2231
	jz	expr_get_token
2222
	mov	al, token_err
2232
	mov	al, token_err
2223
	mov	esi, aParseError
2233
	mov	esi, aParseError
2224
@@:	ret
2234
@@:	ret
2225
 
2235
 
2226
expr_read1:
2236
expr_read1:
2227
	call	expr_read2
2237
	call	expr_read2
2228
.1:
2238
.1:
2229
	cmp	al, token_mul
2239
	cmp	al, token_mul
2230
	jz	.mul
2240
	jz	.mul
2231
	cmp	al, token_div
2241
	cmp	al, token_div
2232
	jz	.div
2242
	jz	.div
2233
	ret
2243
	ret
2234
.mul:
2244
.mul:
2235
	push	ebp
2245
	push	ebp
2236
	call	expr_get_token
2246
	call	expr_get_token
2237
	call	expr_read2
2247
	call	expr_read2
2238
	pop	edx
2248
	pop	edx
2239
; ebp := edx*ebp
2249
; ebp := edx*ebp
2240
	imul	ebp, edx
2250
	imul	ebp, edx
2241
	jmp	.1
2251
	jmp	.1
2242
.div:
2252
.div:
2243
	push	ebp
2253
	push	ebp
2244
	call	expr_get_token
2254
	call	expr_get_token
2245
	call	expr_read2
2255
	call	expr_read2
2246
	pop	edx
2256
	pop	edx
2247
; ebp := edx/ebp
2257
; ebp := edx/ebp
2248
	test	ebp, ebp
2258
	test	ebp, ebp
2249
	jz	.div0
2259
	jz	.div0
2250
	push	eax
2260
	push	eax
2251
	xor	eax, eax
2261
	xor	eax, eax
2252
	xchg	eax, edx
2262
	xchg	eax, edx
2253
	div	ebp
2263
	div	ebp
2254
	xchg	eax, ebp
2264
	xchg	eax, ebp
2255
	pop	eax
2265
	pop	eax
2256
	jmp	.1
2266
	jmp	.1
2257
.div0:
2267
.div0:
2258
	mov	al, token_err
2268
	mov	al, token_err
2259
	mov	esi, aDivByZero
2269
	mov	esi, aDivByZero
2260
	ret
2270
	ret
2261
 
2271
 
2262
expr_read0:
2272
expr_read0:
2263
	xor	ebp, ebp
2273
	xor	ebp, ebp
2264
	cmp	al, token_add
2274
	cmp	al, token_add
2265
	jz	.add
2275
	jz	.add
2266
	cmp	al, token_sub
2276
	cmp	al, token_sub
2267
	jz	.sub
2277
	jz	.sub
2268
	call	expr_read1
2278
	call	expr_read1
2269
.1:
2279
.1:
2270
	cmp	al, token_add
2280
	cmp	al, token_add
2271
	jz	.add
2281
	jz	.add
2272
	cmp	al, token_sub
2282
	cmp	al, token_sub
2273
	jz	.sub
2283
	jz	.sub
2274
	ret
2284
	ret
2275
.add:
2285
.add:
2276
	push	ebp
2286
	push	ebp
2277
	call	expr_get_token
2287
	call	expr_get_token
2278
	call	expr_read1
2288
	call	expr_read1
2279
	pop	edx
2289
	pop	edx
2280
; ebp := edx+ebp
2290
; ebp := edx+ebp
2281
	add	ebp, edx
2291
	add	ebp, edx
2282
	jmp	.1
2292
	jmp	.1
2283
.sub:
2293
.sub:
2284
	push	ebp
2294
	push	ebp
2285
	call	expr_get_token
2295
	call	expr_get_token
2286
	call	expr_read1
2296
	call	expr_read1
2287
	pop	edx
2297
	pop	edx
2288
; ebp := edx-ebp
2298
; ebp := edx-ebp
2289
	xchg	edx, ebp
2299
	xchg	edx, ebp
2290
	sub	ebp, edx
2300
	sub	ebp, edx
2291
	jmp	.1
2301
	jmp	.1
2292
 
2302
 
2293
calc_expression:
2303
calc_expression:
2294
; in: esi->expression
2304
; in: esi->expression
2295
; out: CF=1 if error
2305
; out: CF=1 if error
2296
;      CF=0 and ebp=value if ok
2306
;      CF=0 and ebp=value if ok
2297
	call	expr_get_token
2307
	call	expr_get_token
2298
	call	expr_read0
2308
	call	expr_read0
2299
	cmp	al, token_end
2309
	cmp	al, token_end
2300
	jz	.end
2310
	jz	.end
2301
	cmp	al, token_err
2311
	cmp	al, token_err
2302
	jz	@f
2312
	jz	@f
2303
	mov	esi, aParseError
2313
	mov	esi, aParseError
2304
@@:
2314
@@:
2305
	call	put_message
2315
	call	put_message
2306
	stc
2316
	stc
2307
	ret
2317
	ret
2308
.end:
2318
.end:
2309
	clc
2319
	clc
2310
	ret
2320
	ret
2311
 
2321
 
2312
OnCalc:
2322
OnCalc:
2313
	mov	esi, [curarg]
2323
	mov	esi, [curarg]
2314
	call	calc_expression
2324
	call	calc_expression
2315
	jc	.ret
2325
	jc	.ret
2316
	push	ebp
2326
	push	ebp
2317
	mov	esi, calc_string
2327
	mov	esi, calc_string
2318
	call	put_message_nodraw
2328
	call	put_message_nodraw
2319
	jmp	draw_messages
2329
	jmp	draw_messages
2320
.ret:
2330
.ret:
2321
	ret
2331
	ret
2322
 
2332
 
2323
OnDump:
2333
OnDump:
2324
	mov	esi, [curarg]
2334
	mov	esi, [curarg]
2325
	cmp	byte [esi], 0
2335
	cmp	byte [esi], 0
2326
	jnz	.param
2336
	jnz	.param
2327
	add	[dumppos], dump_height*10h
2337
	add	[dumppos], dump_height*10h
2328
	jmp	.doit
2338
	jmp	.doit
2329
.param:
2339
.param:
2330
	call	calc_expression
2340
	call	calc_expression
2331
	jc	.ret
2341
	jc	.ret
2332
	mov	[dumppos], ebp
2342
	mov	[dumppos], ebp
2333
.doit:
2343
.doit:
2334
	call	get_dump
2344
	call	get_dump
2335
	call	redraw_dump
2345
	call	redraw_dump
2336
.ret:
2346
.ret:
2337
	ret
2347
	ret
2338
 
2348
 
2339
OnUnassemble:
2349
OnUnassemble:
2340
	mov	esi, [curarg]
2350
	mov	esi, [curarg]
2341
	cmp	byte [esi], 0
2351
	cmp	byte [esi], 0
2342
	jnz	.param
2352
	jnz	.param
2343
	mov	eax, [disasm_start_pos]
2353
	mov	eax, [disasm_start_pos]
2344
	mov	ecx, disasm_height
2354
	mov	ecx, disasm_height
2345
	mov	[disasm_cur_pos], eax
2355
	mov	[disasm_cur_pos], eax
2346
.l:
2356
.l:
2347
	mov	eax, [disasm_cur_pos]
2357
	mov	eax, [disasm_cur_pos]
2348
	call	find_symbol
2358
	call	find_symbol
2349
	jc	@f
2359
	jc	@f
2350
	dec	ecx
2360
	dec	ecx
2351
	jz	.m
2361
	jz	.m
2352
@@:
2362
@@:
2353
	push	ecx
2363
	push	ecx
2354
	call	disasm_instr
2364
	call	disasm_instr
2355
	pop	ecx
2365
	pop	ecx
2356
	jc	.err
2366
	jc	.err
2357
	loop	.l
2367
	loop	.l
2358
.m:
2368
.m:
2359
	mov	eax, [disasm_cur_pos]
2369
	mov	eax, [disasm_cur_pos]
2360
	jmp	.doit
2370
	jmp	.doit
2361
.param:
2371
.param:
2362
	call	calc_expression
2372
	call	calc_expression
2363
	jc	.ret
2373
	jc	.ret
2364
	mov	eax, ebp
2374
	mov	eax, ebp
2365
.doit:
2375
.doit:
2366
	push	eax
2376
	push	eax
2367
	push	[disasm_start_pos]
2377
	push	[disasm_start_pos]
2368
	mov	[disasm_start_pos], eax
2378
	mov	[disasm_start_pos], eax
2369
	call	update_disasm
2379
	call	update_disasm
2370
	pop	[disasm_start_pos]
2380
	pop	[disasm_start_pos]
2371
	pop	eax
2381
	pop	eax
2372
	cmp	[disasm_cur_str], 0
2382
	cmp	[disasm_cur_str], 0
2373
	jz	@f
2383
	jz	@f
2374
	mov	[disasm_start_pos], eax
2384
	mov	[disasm_start_pos], eax
2375
.ret:
2385
.ret:
2376
	ret
2386
	ret
2377
@@:
2387
@@:
2378
	call	update_disasm
2388
	call	update_disasm
2379
.err:
2389
.err:
2380
	mov	esi, aInvAddr
2390
	mov	esi, aInvAddr
2381
	jmp	put_message
2391
	jmp	put_message
2382
 
2392
 
2383
OnReg:
2393
OnReg:
2384
	mov	esi, [curarg]
2394
	mov	esi, [curarg]
2385
	call	skip_spaces
2395
	call	skip_spaces
2386
	call	find_reg
2396
	call	find_reg
2387
	jnc	@f
2397
	jnc	@f
2388
.err:
2398
.err:
2389
	mov	esi, RSyntax
2399
	mov	esi, RSyntax
2390
	jmp	put_message
2400
	jmp	put_message
2391
@@:
2401
@@:
2392
	call	skip_spaces
2402
	call	skip_spaces
2393
	test	al, al
2403
	test	al, al
2394
	jz	.err
2404
	jz	.err
2395
	cmp	al, '='
2405
	cmp	al, '='
2396
	jnz	@f
2406
	jnz	@f
2397
	inc	esi
2407
	inc	esi
2398
	call	skip_spaces
2408
	call	skip_spaces
2399
	test	al, al
2409
	test	al, al
2400
	jz	.err
2410
	jz	.err
2401
@@:
2411
@@:
2402
	push	edi
2412
	push	edi
2403
	call	calc_expression
2413
	call	calc_expression
2404
	pop	edi
2414
	pop	edi
2405
	jc	.ret
2415
	jc	.ret
2406
; now edi=register id, ebp=value
2416
; now edi=register id, ebp=value
2407
	cmp	[bSuspended], 0
2417
	cmp	[bSuspended], 0
2408
	mov	esi, aRunningErr
2418
	mov	esi, aRunningErr
2409
	jz	put_message
2419
	jz	put_message
2410
	xchg	eax, ebp
2420
	xchg	eax, ebp
2411
	cmp	edi, 24
2421
	cmp	edi, 24
2412
	jz	.eip
2422
	jz	.eip
2413
	sub	edi, 4
2423
	sub	edi, 4
2414
	jb	.8lo
2424
	jb	.8lo
2415
	sub	edi, 4
2425
	sub	edi, 4
2416
	jb	.8hi
2426
	jb	.8hi
2417
	sub	edi, 8
2427
	sub	edi, 8
2418
	jb	.16
2428
	jb	.16
2419
	mov	[_eax+edi*4], eax
2429
	mov	[_eax+edi*4], eax
2420
	jmp	.ret
2430
	jmp	.ret
2421
.16:
2431
.16:
2422
	mov	word [_eax+(edi+8)*4], ax
2432
	mov	word [_eax+(edi+8)*4], ax
2423
	jmp	.ret
2433
	jmp	.ret
2424
.8lo:
2434
.8lo:
2425
	mov	byte [_eax+(edi+4)*4], al
2435
	mov	byte [_eax+(edi+4)*4], al
2426
	jmp	.ret
2436
	jmp	.ret
2427
.8hi:
2437
.8hi:
2428
	mov	byte [_eax+(edi+4)*4+1], al
2438
	mov	byte [_eax+(edi+4)*4+1], al
2429
	jmp	.ret
2439
	jmp	.ret
2430
.eip:
2440
.eip:
2431
	mov	[_eip], eax
2441
	mov	[_eip], eax
2432
	call	update_disasm_eip
2442
	call	update_disasm_eip
2433
.ret:
2443
.ret:
2434
	call	set_context
2444
	call	set_context
2435
	jmp	redraw_registers
2445
	jmp	redraw_registers
2436
 
2446
 
2437
; Breakpoints manipulation
2447
; Breakpoints manipulation
2438
OnBp:
2448
OnBp:
2439
	mov	esi, [curarg]
2449
	mov	esi, [curarg]
2440
	call	calc_expression
2450
	call	calc_expression
2441
	jc	.ret
2451
	jc	.ret
2442
	xchg	eax, ebp
2452
	xchg	eax, ebp
2443
	push	eax
2453
	push	eax
2444
	call	find_breakpoint
2454
	call	find_breakpoint
2445
	inc	eax
2455
	inc	eax
2446
	pop	eax
2456
	pop	eax
2447
	jz	.notfound
2457
	jz	.notfound
2448
	mov	esi, aDuplicateBreakpoint
2458
	mov	esi, aDuplicateBreakpoint
2449
	jmp	.sayerr
2459
	jmp	.sayerr
2450
.notfound:
2460
.notfound:
2451
	mov	bl, 1
2461
	mov	bl, 1
2452
	call	add_breakpoint
2462
	call	add_breakpoint
2453
	jnc	.ret
2463
	jnc	.ret
2454
	mov	esi, aBreakpointLimitExceeded
2464
	mov	esi, aBreakpointLimitExceeded
2455
.sayerr:
2465
.sayerr:
2456
	call	put_message
2466
	call	put_message
2457
.ret:
2467
.ret:
2458
	jmp	redraw_disasm
2468
	jmp	redraw_disasm
2459
 
2469
 
2460
OnBpmb:
2470
OnBpmb:
2461
	mov	dh, 0011b
2471
	mov	dh, 0011b
2462
	jmp	DoBpm
2472
	jmp	DoBpm
2463
OnBpmw:
2473
OnBpmw:
2464
	mov	dh, 0111b
2474
	mov	dh, 0111b
2465
	jmp	DoBpm
2475
	jmp	DoBpm
2466
OnBpmd:
2476
OnBpmd:
2467
	mov	dh, 1111b
2477
	mov	dh, 1111b
2468
DoBpm:
2478
DoBpm:
2469
	mov	esi, [curarg]
2479
	mov	esi, [curarg]
2470
	cmp	byte [esi], 'w'
2480
	cmp	byte [esi], 'w'
2471
	jnz	@f
2481
	jnz	@f
2472
	and	dh, not 2
2482
	and	dh, not 2
2473
	inc	esi
2483
	inc	esi
2474
@@:
2484
@@:
2475
	push	edx
2485
	push	edx
2476
	call	calc_expression
2486
	call	calc_expression
2477
	pop	edx
2487
	pop	edx
2478
	jnc	@f
2488
	jnc	@f
2479
	ret
2489
	ret
2480
@@:
2490
@@:
2481
; ebp=expression, dh=flags
2491
; ebp=expression, dh=flags
2482
	movzx	eax, dh
2492
	movzx	eax, dh
2483
	shr	eax, 2
2493
	shr	eax, 2
2484
	test	ebp, eax
2494
	test	ebp, eax
2485
	jz	@f
2495
	jz	@f
2486
	mov	esi, aUnaligned
2496
	mov	esi, aUnaligned
2487
	jmp	put_message
2497
	jmp	put_message
2488
@@:
2498
@@:
2489
	mov	eax, ebp
2499
	mov	eax, ebp
2490
	mov	bl, 0Bh
2500
	mov	bl, 0Bh
2491
	call	add_breakpoint
2501
	call	add_breakpoint
2492
	jnc	@f
2502
	jnc	@f
2493
	mov	esi, aBreakpointLimitExceeded
2503
	mov	esi, aBreakpointLimitExceeded
2494
	jmp	put_message
2504
	jmp	put_message
2495
@@:
2505
@@:
2496
; now find index
2506
; now find index
2497
	push	eax
2507
	push	eax
2498
	xor	ecx, ecx
2508
	xor	ecx, ecx
2499
.l1:
2509
.l1:
2500
	cmp	[drx_break+ecx*4], 0
2510
	cmp	[drx_break+ecx*4], 0
2501
	jnz	.l2
2511
	jnz	.l2
2502
	push	69
2512
	push	69
2503
	pop	eax
2513
	pop	eax
2504
	push	ecx
2514
	push	ecx
2505
	mov	dl, cl
2515
	mov	dl, cl
2506
	mov	ecx, [debuggee_pid]
2516
	mov	ecx, [debuggee_pid]
2507
	mov	esi, ebp
2517
	mov	esi, ebp
2508
	push	9
2518
	push	9
2509
	pop	ebx
2519
	pop	ebx
2510
	mcall
2520
	mcall
2511
	test	eax, eax
2521
	test	eax, eax
2512
	jz	.ok
2522
	jz	.ok
2513
	pop	ecx
2523
	pop	ecx
2514
.l2:
2524
.l2:
2515
	inc	ecx
2525
	inc	ecx
2516
	cmp	ecx, 4
2526
	cmp	ecx, 4
2517
	jb	.l1
2527
	jb	.l1
2518
	pop	eax
2528
	pop	eax
2519
	call	clear_breakpoint
2529
	call	clear_breakpoint
2520
	mov	esi, aBreakpointLimitExceeded
2530
	mov	esi, aBreakpointLimitExceeded
2521
	jmp	put_message
2531
	jmp	put_message
2522
.ok:
2532
.ok:
2523
	pop	ecx
2533
	pop	ecx
2524
	pop	eax
2534
	pop	eax
2525
	and	byte [edi], not 2	; breakpoint is enabled
2535
	and	byte [edi], not 2	; breakpoint is enabled
2526
	shl	dl, 6
2536
	shl	dl, 6
2527
	or	dl, dh
2537
	or	dl, dh
2528
	mov	byte [edi+1], dl
2538
	mov	byte [edi+1], dl
2529
	inc	eax
2539
	inc	eax
2530
	mov	[drx_break+ecx*4], eax
2540
	mov	[drx_break+ecx*4], eax
2531
	ret
2541
	ret
2532
 
2542
 
2533
OnBc:
2543
OnBc:
2534
	mov	esi, [curarg]
2544
	mov	esi, [curarg]
2535
@@:	call	get_hex_number
2545
@@:	call	get_hex_number
2536
	jc	OnBp.ret
2546
	jc	OnBp.ret
2537
	call	clear_breakpoint
2547
	call	clear_breakpoint
2538
	jmp	@b
2548
	jmp	@b
2539
 
2549
 
2540
OnBd:
2550
OnBd:
2541
	mov	esi, [curarg]
2551
	mov	esi, [curarg]
2542
@@:	call	get_hex_number
2552
@@:	call	get_hex_number
2543
	jc	OnBp.ret
2553
	jc	OnBp.ret
2544
	call	disable_breakpoint
2554
	call	disable_breakpoint
2545
	jmp	@b
2555
	jmp	@b
2546
 
2556
 
2547
OnBe:
2557
OnBe:
2548
	mov	esi, [curarg]
2558
	mov	esi, [curarg]
2549
@@:	call	get_hex_number
2559
@@:	call	get_hex_number
2550
	jc	OnBp.ret
2560
	jc	OnBp.ret
2551
	push	eax
2561
	push	eax
2552
	call	find_enabled_breakpoint
2562
	call	find_enabled_breakpoint
2553
	pop	eax
2563
	pop	eax
2554
	jz	.err
2564
	jz	.err
2555
	call	enable_breakpoint
2565
	call	enable_breakpoint
2556
	jmp	@b
2566
	jmp	@b
2557
.err:
2567
.err:
2558
	mov	esi, OnBeErrMsg
2568
	mov	esi, OnBeErrMsg
2559
	jmp	put_message
2569
	jmp	put_message
2560
 
2570
 
2561
get_hex_number:
2571
get_hex_number:
2562
	call	skip_spaces
2572
	call	skip_spaces
2563
	xor	ecx, ecx
2573
	xor	ecx, ecx
2564
	xor	edx, edx
2574
	xor	edx, edx
2565
@@:
2575
@@:
2566
	lodsb
2576
	lodsb
2567
	call	is_hex_digit
2577
	call	is_hex_digit
2568
	jc	.ret
2578
	jc	.ret
2569
	shl	edx, 4
2579
	shl	edx, 4
2570
	or	dl, al
2580
	or	dl, al
2571
	inc	ecx
2581
	inc	ecx
2572
	jmp	@b
2582
	jmp	@b
2573
.ret:
2583
.ret:
2574
	dec	esi
2584
	dec	esi
2575
	cmp	ecx, 1
2585
	cmp	ecx, 1
2576
	xchg	eax, edx
2586
	xchg	eax, edx
2577
	ret
2587
	ret
2578
 
2588
 
2579
OnBl:
2589
OnBl:
2580
	mov	esi, [curarg]
2590
	mov	esi, [curarg]
2581
	cmp	byte [esi], 0
2591
	cmp	byte [esi], 0
2582
	jz	.listall
2592
	jz	.listall
2583
	call	get_hex_number
2593
	call	get_hex_number
2584
	jc	.ret
2594
	jc	.ret
2585
	cmp	eax, breakpoints_n
2595
	cmp	eax, breakpoints_n
2586
	jae	.err
2596
	jae	.err
2587
	push	eax
2597
	push	eax
2588
	add	eax, eax
2598
	add	eax, eax
2589
	lea	edi, [breakpoints + eax + eax*2]
2599
	lea	edi, [breakpoints + eax + eax*2]
2590
	pop	eax
2600
	pop	eax
2591
	test	byte [edi+4], 1
2601
	test	byte [edi+4], 1
2592
	jz	.err
2602
	jz	.err
2593
	call	show_break_info
2603
	call	show_break_info
2594
.ret:
2604
.ret:
2595
	ret
2605
	ret
2596
.err:
2606
.err:
2597
	mov	esi, aInvalidBreak
2607
	mov	esi, aInvalidBreak
2598
	jmp	put_message
2608
	jmp	put_message
2599
.listall:
2609
.listall:
2600
	mov	edi, breakpoints
2610
	mov	edi, breakpoints
2601
	xor	eax, eax
2611
	xor	eax, eax
2602
@@:
2612
@@:
2603
	test	byte [edi+4], 1
2613
	test	byte [edi+4], 1
2604
	jz	.cont
2614
	jz	.cont
2605
	push	edi eax
2615
	push	edi eax
2606
	call	show_break_info
2616
	call	show_break_info
2607
	pop	eax edi
2617
	pop	eax edi
2608
.cont:
2618
.cont:
2609
	add	edi, 6
2619
	add	edi, 6
2610
	inc	eax
2620
	inc	eax
2611
	cmp	eax, breakpoints_n
2621
	cmp	eax, breakpoints_n
2612
	jb	@b
2622
	jb	@b
2613
	ret
2623
	ret
2614
 
2624
 
2615
show_break_info:
2625
show_break_info:
2616
	push	edi
2626
	push	edi
2617
	test	byte [edi+4], 8
2627
	test	byte [edi+4], 8
2618
	jnz	.dr
2628
	jnz	.dr
2619
	push	dword [edi]
2629
	push	dword [edi]
2620
	push	eax
2630
	push	eax
2621
	mov	esi, aBreakNum
2631
	mov	esi, aBreakNum
2622
	call	put_message_nodraw
2632
	call	put_message_nodraw
2623
	jmp	.cmn
2633
	jmp	.cmn
2624
.dr:
2634
.dr:
2625
	push	eax
2635
	push	eax
2626
	mov	esi, aMemBreak1
2636
	mov	esi, aMemBreak1
2627
	call	put_message_nodraw
2637
	call	put_message_nodraw
2628
	pop	edi
2638
	pop	edi
2629
	push	edi
2639
	push	edi
2630
	mov	esi, aMemBreak2
2640
	mov	esi, aMemBreak2
2631
	test	byte [edi+5], 2
2641
	test	byte [edi+5], 2
2632
	jz	@f
2642
	jz	@f
2633
	mov	esi, aMemBreak3
2643
	mov	esi, aMemBreak3
2634
@@:
2644
@@:
2635
	call	put_message_nodraw
2645
	call	put_message_nodraw
2636
	pop	edi
2646
	pop	edi
2637
	push	edi
2647
	push	edi
2638
	mov	esi, aMemBreak6
2648
	mov	esi, aMemBreak6
2639
	test	byte [edi+5], 8
2649
	test	byte [edi+5], 8
2640
	jnz	@f
2650
	jnz	@f
2641
	mov	esi, aMemBreak5
2651
	mov	esi, aMemBreak5
2642
	test	byte [edi+5], 4
2652
	test	byte [edi+5], 4
2643
	jnz	@f
2653
	jnz	@f
2644
	mov	esi, aMemBreak4
2654
	mov	esi, aMemBreak4
2645
@@:
2655
@@:
2646
	call	put_message_nodraw
2656
	call	put_message_nodraw
2647
	pop	edi
2657
	pop	edi
2648
	push	edi
2658
	push	edi
2649
	push	dword [edi]
2659
	push	dword [edi]
2650
	mov	esi, aMemBreak7
2660
	mov	esi, aMemBreak7
2651
	call	put_message_nodraw
2661
	call	put_message_nodraw
2652
.cmn:
2662
.cmn:
2653
	pop	edi
2663
	pop	edi
2654
	test	byte [edi+4], 2
2664
	test	byte [edi+4], 2
2655
	jz	@f
2665
	jz	@f
2656
	push	edi
2666
	push	edi
2657
	mov	esi, aDisabled
2667
	mov	esi, aDisabled
2658
	call	put_message_nodraw
2668
	call	put_message_nodraw
2659
	pop	edi
2669
	pop	edi
2660
@@:
2670
@@:
2661
	test	byte [edi+4], 4
2671
	test	byte [edi+4], 4
2662
	jz	@f
2672
	jz	@f
2663
	mov	esi, aOneShot
2673
	mov	esi, aOneShot
2664
	call	put_message_nodraw
2674
	call	put_message_nodraw
2665
@@:
2675
@@:
2666
	mov	esi, newline
2676
	mov	esi, newline
2667
	jmp	put_message
2677
	jmp	put_message
2668
 
2678
 
2669
add_breakpoint:
2679
add_breakpoint:
2670
; in: eax=address, bl=flags
2680
; in: eax=address, bl=flags
2671
; out: CF=1 => error, CF=0 => eax=breakpoint number
2681
; out: CF=1 => error, CF=0 => eax=breakpoint number
2672
	xor	ecx, ecx
2682
	xor	ecx, ecx
2673
	mov	edi, breakpoints
2683
	mov	edi, breakpoints
2674
@@:
2684
@@:
2675
	test	byte [edi+4], 1
2685
	test	byte [edi+4], 1
2676
	jz	.found
2686
	jz	.found
2677
	add	edi, 6
2687
	add	edi, 6
2678
	inc	ecx
2688
	inc	ecx
2679
	cmp	ecx, breakpoints_n
2689
	cmp	ecx, breakpoints_n
2680
	jb	@b
2690
	jb	@b
2681
	stc
2691
	stc
2682
	ret
2692
	ret
2683
.found:
2693
.found:
2684
	stosd
2694
	stosd
2685
	xchg	eax, ecx
2695
	xchg	eax, ecx
2686
	mov	[edi], bl
2696
	mov	[edi], bl
2687
	test	bl, 2
2697
	test	bl, 2
2688
	jnz	@f
2698
	jnz	@f
2689
	or	byte [edi], 2
2699
	or	byte [edi], 2
2690
	push	eax
2700
	push	eax
2691
	call	enable_breakpoint
2701
	call	enable_breakpoint
2692
	pop	eax
2702
	pop	eax
2693
@@:
2703
@@:
2694
	clc
2704
	clc
2695
	ret
2705
	ret
2696
 
2706
 
2697
clear_breakpoint:
2707
clear_breakpoint:
2698
	cmp	eax, breakpoints_n
2708
	cmp	eax, breakpoints_n
2699
	jae	.ret
2709
	jae	.ret
2700
	mov	ecx, 4
2710
	mov	ecx, 4
2701
	inc	eax
2711
	inc	eax
2702
.1:
2712
.1:
2703
	cmp	[drx_break-4+ecx*4], eax
2713
	cmp	[drx_break-4+ecx*4], eax
2704
	jnz	@f
2714
	jnz	@f
2705
	and	[drx_break-4+ecx*4], 0
2715
	and	[drx_break-4+ecx*4], 0
2706
@@:	loop	.1
2716
@@:	loop	.1
2707
	dec	eax
2717
	dec	eax
2708
	push	eax
2718
	push	eax
2709
	add	eax, eax
2719
	add	eax, eax
2710
	lea	edi, [breakpoints + eax + eax*2 + 4]
2720
	lea	edi, [breakpoints + eax + eax*2 + 4]
2711
	test	byte [edi], 1
2721
	test	byte [edi], 1
2712
	pop	eax
2722
	pop	eax
2713
	jz	.ret
2723
	jz	.ret
2714
	push	edi
2724
	push	edi
2715
	call	disable_breakpoint
2725
	call	disable_breakpoint
2716
	pop	edi
2726
	pop	edi
2717
	mov	byte [edi], 0
2727
	mov	byte [edi], 0
2718
.ret:
2728
.ret:
2719
	ret
2729
	ret
2720
 
2730
 
2721
disable_breakpoint:
2731
disable_breakpoint:
2722
	cmp	eax, breakpoints_n
2732
	cmp	eax, breakpoints_n
2723
	jae	.ret
2733
	jae	.ret
2724
	add	eax, eax
2734
	add	eax, eax
2725
	lea	edi, [breakpoints + eax + eax*2 + 5]
2735
	lea	edi, [breakpoints + eax + eax*2 + 5]
2726
	test	byte [edi-1], 1
2736
	test	byte [edi-1], 1
2727
	jz	.ret
2737
	jz	.ret
2728
	test	byte [edi-1], 2
2738
	test	byte [edi-1], 2
2729
	jnz	.ret
2739
	jnz	.ret
2730
	or	byte [edi-1], 2
2740
	or	byte [edi-1], 2
2731
	test	byte [edi-1], 8
2741
	test	byte [edi-1], 8
2732
	jnz	.dr
2742
	jnz	.dr
2733
	push	esi
2743
	push	esi
2734
	push	7
2744
	push	7
2735
	pop	ebx
2745
	pop	ebx
2736
	push	69
2746
	push	69
2737
	pop	eax
2747
	pop	eax
2738
	mov	ecx, [debuggee_pid]
2748
	mov	ecx, [debuggee_pid]
2739
	xor	edx, edx
2749
	xor	edx, edx
2740
	inc	edx
2750
	inc	edx
2741
	mov	esi, [edi-5]
2751
	mov	esi, [edi-5]
2742
	mcall
2752
	mcall
2743
	pop	esi
2753
	pop	esi
2744
.ret:
2754
.ret:
2745
	ret
2755
	ret
2746
.dr:
2756
.dr:
2747
	mov	dl, [edi]
2757
	mov	dl, [edi]
2748
	shr	dl, 6
2758
	shr	dl, 6
2749
	mov	dh, 80h
2759
	mov	dh, 80h
2750
	push	69
2760
	push	69
2751
	pop	eax
2761
	pop	eax
2752
	push	9
2762
	push	9
2753
	pop	ebx
2763
	pop	ebx
2754
	mov	ecx, [debuggee_pid]
2764
	mov	ecx, [debuggee_pid]
2755
	mcall
2765
	mcall
2756
	ret
2766
	ret
2757
 
2767
 
2758
enable_breakpoint:
2768
enable_breakpoint:
2759
	push	esi
2769
	push	esi
2760
	cmp	eax, breakpoints_n
2770
	cmp	eax, breakpoints_n
2761
	jae	.ret
2771
	jae	.ret
2762
	add	eax, eax
2772
	add	eax, eax
2763
	lea	edi, [breakpoints + eax + eax*2 + 5]
2773
	lea	edi, [breakpoints + eax + eax*2 + 5]
2764
	test	byte [edi-1], 1
2774
	test	byte [edi-1], 1
2765
	jz	.ret
2775
	jz	.ret
2766
	test	byte [edi-1], 2
2776
	test	byte [edi-1], 2
2767
	jz	.ret
2777
	jz	.ret
2768
	and	byte [edi-1], not 2
2778
	and	byte [edi-1], not 2
2769
	test	byte [edi-1], 8
2779
	test	byte [edi-1], 8
2770
	jnz	.dr
2780
	jnz	.dr
2771
	push	6
2781
	push	6
2772
	pop	ebx
2782
	pop	ebx
2773
	push	69
2783
	push	69
2774
	pop	eax
2784
	pop	eax
2775
	mov	esi, [edi-5]
2785
	mov	esi, [edi-5]
2776
	mov	ecx, [debuggee_pid]
2786
	mov	ecx, [debuggee_pid]
2777
	xor	edx, edx
2787
	xor	edx, edx
2778
	inc	edx
2788
	inc	edx
2779
	mcall
2789
	mcall
2780
	dec	eax
2790
	dec	eax
2781
	jnz	.err
2791
	jnz	.err
2782
	mov	al, 69
2792
	mov	al, 69
2783
	push	0xCC
2793
	push	0xCC
2784
	mov	edi, esp
2794
	mov	edi, esp
2785
	inc	ebx
2795
	inc	ebx
2786
	mcall
2796
	mcall
2787
	pop	eax
2797
	pop	eax
2788
.ret:
2798
.ret:
2789
	pop	esi
2799
	pop	esi
2790
	ret
2800
	ret
2791
.err:
2801
.err:
2792
	or	byte [edi-1], 2
2802
	or	byte [edi-1], 2
2793
	mov	esi, aBreakErr
2803
	mov	esi, aBreakErr
2794
	call	put_message
2804
	call	put_message
2795
	pop	esi
2805
	pop	esi
2796
	ret
2806
	ret
2797
.dr:
2807
.dr:
2798
	push	9
2808
	push	9
2799
	pop	ebx
2809
	pop	ebx
2800
	push	69
2810
	push	69
2801
	pop	eax
2811
	pop	eax
2802
	mov	esi, [edi-5]
2812
	mov	esi, [edi-5]
2803
	mov	ecx, [debuggee_pid]
2813
	mov	ecx, [debuggee_pid]
2804
	mov	dl, [edi]
2814
	mov	dl, [edi]
2805
	shr	dl, 6
2815
	shr	dl, 6
2806
	mov	dh, [edi]
2816
	mov	dh, [edi]
2807
	and	dh, 0xF
2817
	and	dh, 0xF
2808
	mcall
2818
	mcall
2809
	test	eax, eax
2819
	test	eax, eax
2810
	jnz	.err
2820
	jnz	.err
2811
	pop	esi
2821
	pop	esi
2812
	ret
2822
	ret
2813
 
2823
 
2814
find_breakpoint:
2824
find_breakpoint:
2815
	xor	ecx, ecx
2825
	xor	ecx, ecx
2816
	xchg	eax, ecx
2826
	xchg	eax, ecx
2817
	mov	edi, breakpoints
2827
	mov	edi, breakpoints
2818
@@:
2828
@@:
2819
	test	byte [edi+4], 1
2829
	test	byte [edi+4], 1
2820
	jz	.cont
2830
	jz	.cont
2821
	test	byte [edi+4], 8
2831
	test	byte [edi+4], 8
2822
	jnz	.cont
2832
	jnz	.cont
2823
	cmp	[edi], ecx
2833
	cmp	[edi], ecx
2824
	jz	.found
2834
	jz	.found
2825
.cont:
2835
.cont:
2826
	add	edi, 6
2836
	add	edi, 6
2827
	inc	eax
2837
	inc	eax
2828
	cmp	eax, breakpoints_n
2838
	cmp	eax, breakpoints_n
2829
	jb	@b
2839
	jb	@b
2830
	or	eax, -1
2840
	or	eax, -1
2831
.found:
2841
.found:
2832
	ret
2842
	ret
2833
 
2843
 
2834
find_enabled_breakpoint:
2844
find_enabled_breakpoint:
2835
	xor	ecx, ecx
2845
	xor	ecx, ecx
2836
	xchg	eax, ecx
2846
	xchg	eax, ecx
2837
	mov	edi, breakpoints
2847
	mov	edi, breakpoints
2838
@@:
2848
@@:
2839
	test	byte [edi+4], 1
2849
	test	byte [edi+4], 1
2840
	jz	.cont
2850
	jz	.cont
2841
	test	byte [edi+4], 2 or 8
2851
	test	byte [edi+4], 2 or 8
2842
	jnz	.cont
2852
	jnz	.cont
2843
	cmp	[edi], ecx
2853
	cmp	[edi], ecx
2844
	jz	.found
2854
	jz	.found
2845
.cont:
2855
.cont:
2846
	add	edi, 6
2856
	add	edi, 6
2847
	inc	eax
2857
	inc	eax
2848
	cmp	eax, breakpoints_n
2858
	cmp	eax, breakpoints_n
2849
	jb	@b
2859
	jb	@b
2850
	or	eax, -1
2860
	or	eax, -1
2851
.found:
2861
.found:
2852
	ret
2862
	ret
2853
 
2863
 
2854
OnUnpack:
2864
OnUnpack:
2855
; program must be loaded - checked when command was parsed
2865
; program must be loaded - checked when command was parsed
2856
; program must be stopped
2866
; program must be stopped
2857
	mov	esi, aRunningErr
2867
	mov	esi, aRunningErr
2858
	cmp	[bSuspended], 0
2868
	cmp	[bSuspended], 0
2859
	jz	put_message
2869
	jz	put_message
2860
; all breakpoints must be disabled
2870
; all breakpoints must be disabled
2861
	mov	edi, breakpoints
2871
	mov	edi, breakpoints
2862
@@:
2872
@@:
2863
	test	byte [edi+4], 1
2873
	test	byte [edi+4], 1
2864
	jz	.cont
2874
	jz	.cont
2865
	test	byte [edi+4], 2
2875
	test	byte [edi+4], 2
2866
	jnz	.cont
2876
	jnz	.cont
2867
	mov	esi, aEnabledBreakErr
2877
	mov	esi, aEnabledBreakErr
2868
	jmp	put_message
2878
	jmp	put_message
2869
.cont:
2879
.cont:
2870
	add	edi, 6
2880
	add	edi, 6
2871
	cmp	edi, breakpoints+breakpoints_n*6
2881
	cmp	edi, breakpoints+breakpoints_n*6
2872
	jb	@b
2882
	jb	@b
2873
; ok, now do it
2883
; ok, now do it
2874
; set breakpoint on 0xC dword access
2884
; set breakpoint on 0xC dword access
2875
	push	9
2885
	push	9
2876
	pop	ebx
2886
	pop	ebx
2877
	mov	ecx, [debuggee_pid]
2887
	mov	ecx, [debuggee_pid]
2878
	mov	dx, 1111b*256
2888
	mov	dx, 1111b*256
2879
	push	0xC
2889
	push	0xC
2880
	pop	esi
2890
	pop	esi
2881
@@:
2891
@@:
2882
	push	69
2892
	push	69
2883
	pop	eax
2893
	pop	eax
2884
	mcall
2894
	mcall
2885
	test	eax, eax
2895
	test	eax, eax
2886
	jz	.breakok
2896
	jz	.breakok
2887
	inc	edx
2897
	inc	edx
2888
	cmp	dl, 4
2898
	cmp	dl, 4
2889
	jb	@b
2899
	jb	@b
2890
.breakok:
2900
.breakok:
2891
	call	GoOn
2901
	call	GoOn
2892
; now wait for event
2902
; now wait for event
2893
.wait:
2903
.wait:
2894
	push	10
2904
	push	10
2895
	pop	eax
2905
	pop	eax
2896
	mcall
2906
	mcall
2897
	dec	eax
2907
	dec	eax
2898
	jz	.redraw
2908
	jz	.redraw
2899
	dec	eax
2909
	dec	eax
2900
	jz	.key
2910
	jz	.key
2901
	dec	eax
2911
	dec	eax
2902
	jnz	.debug
2912
	jnz	.debug
2903
; button; we have only one button, close
2913
; button; we have only one button, close
2904
	or	eax, -1
2914
	or	eax, -1
2905
	mcall
2915
	mcall
2906
.redraw:
2916
.redraw:
2907
	call	draw_window
2917
	call	draw_window
2908
	jmp	.wait
2918
	jmp	.wait
2909
.key:
2919
.key:
2910
	mov	al, 2
2920
	mov	al, 2
2911
	mcall
2921
	mcall
2912
	cmp	ah, 3	; Ctrl+C
2922
	cmp	ah, 3	; Ctrl+C
2913
	jnz	.wait
2923
	jnz	.wait
2914
.userbreak:
2924
.userbreak:
2915
	mov	esi, aInterrupted
2925
	mov	esi, aInterrupted
2916
.x1:
2926
.x1:
2917
	push	edx esi
2927
	push	edx esi
2918
	call	put_message
2928
	call	put_message
2919
	pop	esi edx
2929
	pop	esi edx
2920
	or	dh, 80h
2930
	or	dh, 80h
2921
	push	69
2931
	push	69
2922
	pop	eax
2932
	pop	eax
2923
	push	9
2933
	push	9
2924
	pop	ebx
2934
	pop	ebx
2925
	mov	ecx, [debuggee_pid]
2935
	mov	ecx, [debuggee_pid]
2926
	mcall
2936
	mcall
2927
	cmp	esi, aUnpacked
2937
	cmp	esi, aUnpacked
2928
	jnz	OnSuspend
2938
	jnz	OnSuspend
2929
	jmp	AfterSuspend
2939
	jmp	AfterSuspend
2930
.debug:
2940
.debug:
2931
	cmp	[dbgbuflen], 4*3
2941
	cmp	[dbgbuflen], 4*3
2932
	jnz	.notour
2942
	jnz	.notour
2933
	cmp	dword [dbgbuf], 3
2943
	cmp	dword [dbgbuf], 3
2934
	jnz	.notour
2944
	jnz	.notour
2935
	test	byte [dbgbuf+8], 1
2945
	test	byte [dbgbuf+8], 1
2936
	jnz	.our
2946
	jnz	.our
2937
.notour:
2947
.notour:
2938
	mov	esi, aInterrupted
2948
	mov	esi, aInterrupted
2939
	push	edx
2949
	push	edx
2940
	call	put_message
2950
	call	put_message
2941
	pop	edx
2951
	pop	edx
2942
	or	dh, 80h
2952
	or	dh, 80h
2943
	push	69
2953
	push	69
2944
	pop	eax
2954
	pop	eax
2945
	push	9
2955
	push	9
2946
	pop	ebx
2956
	pop	ebx
2947
	mov	ecx, [debuggee_pid]
2957
	mov	ecx, [debuggee_pid]
2948
	mcall
2958
	mcall
2949
	jmp	debugmsg
2959
	jmp	debugmsg
2950
.our:
2960
.our:
2951
	and	[dbgbuflen], 0
2961
	and	[dbgbuflen], 0
2952
	push	edx
2962
	push	edx
2953
	call	get_context
2963
	call	get_context
2954
	push	eax
2964
	push	eax
2955
	mov	al, 69
2965
	mov	al, 69
2956
	mov	bl, 6
2966
	mov	bl, 6
2957
	mov	ecx, [debuggee_pid]
2967
	mov	ecx, [debuggee_pid]
2958
	mov	edi, esp
2968
	mov	edi, esp
2959
	push	4
2969
	push	4
2960
	pop	edx
2970
	pop	edx
2961
	push	0xC
2971
	push	0xC
2962
	pop	esi
2972
	pop	esi
2963
	mcall
2973
	mcall
2964
	pop	eax
2974
	pop	eax
2965
	pop	edx
2975
	pop	edx
2966
	cmp	eax, [_eip]
2976
	cmp	eax, [_eip]
2967
	jz	.done
2977
	jz	.done
2968
	call	DoResume
2978
	call	DoResume
2969
	jmp	.wait
2979
	jmp	.wait
2970
.done:
2980
.done:
2971
	mov	esi, aUnpacked
2981
	mov	esi, aUnpacked
2972
	jmp	.x1
2982
	jmp	.x1
2973
 
2983
 
2974
include 'sort.inc'
2984
include 'sort.inc'
2975
compare:
2985
compare:
2976
	cmpsd
2986
	cmpsd
2977
	jnz	@f
2987
	jnz	@f
2978
	cmp	esi, edi
2988
	cmp	esi, edi
2979
@@:	ret
2989
@@:	ret
2980
compare2:
2990
compare2:
2981
	cmpsd
2991
	cmpsd
2982
@@:
2992
@@:
2983
	cmpsb
2993
	cmpsb
2984
	jnz	@f
2994
	jnz	@f
2985
	cmp	byte [esi-1], 0
2995
	cmp	byte [esi-1], 0
2986
	jnz	@b
2996
	jnz	@b
2987
	cmp	esi, edi
2997
	cmp	esi, edi
2988
@@:
2998
@@:
2989
	ret
2999
	ret
2990
 
3000
 
2991
free_symbols:
3001
free_symbols:
2992
	mov	ecx, [symbols]
3002
	mov	ecx, [symbols]
2993
	jecxz	@f
3003
	jecxz	@f
2994
	mcall	68, 13
3004
	mcall	68, 13
2995
	and	[symbols], 0
3005
	and	[symbols], 0
2996
	and	[num_symbols], 0
3006
	and	[num_symbols], 0
2997
@@:
3007
@@:
2998
	ret
3008
	ret
2999
 
3009
 
3000
OnLoadSymbols.fileerr:
3010
OnLoadSymbols.fileerr:
3001
	test	ebp, ebp
3011
	test	ebp, ebp
3002
	jz	@f
3012
	jz	@f
3003
	mcall	68, 13, edi
3013
	mcall	68, 13, edi
3004
	ret
3014
	ret
3005
@@:
3015
@@:
3006
	push	eax
3016
	push	eax
3007
	mcall	68, 13, edi
3017
	mcall	68, 13, edi
3008
	mov	esi, aCannotLoadFile
3018
	mov	esi, aCannotLoadFile
3009
	call	put_message_nodraw
3019
	call	put_message_nodraw
3010
	pop	eax
3020
	pop	eax
3011
	cmp	eax, 0x20
3021
	cmp	eax, 0x20
3012
	jae	.unk
3022
	jae	.unk
3013
	mov	esi, [load_err_msgs + eax*4]
3023
	mov	esi, [load_err_msgs + eax*4]
3014
	test	esi, esi
3024
	test	esi, esi
3015
	jnz	put_message
3025
	jnz	put_message
3016
.unk:
3026
.unk:
3017
	mov	esi, unk_err_msg2
3027
	mov	esi, unk_err_msg2
3018
	jmp	put_message
3028
	jmp	put_message
3019
 
3029
 
3020
OnLoadSymbols:
3030
OnLoadSymbols:
3021
	xor	ebp, ebp
3031
	xor	ebp, ebp
3022
; load input file
3032
; load input file
3023
	mov	esi, [curarg]
3033
	mov	esi, [curarg]
3024
	call	free_symbols
3034
	call	free_symbols
3025
.silent:
3035
.silent:
3026
	xor	edi, edi
3036
	xor	edi, edi
3027
	cmp	[num_symbols], edi
3037
	cmp	[num_symbols], edi
3028
	jz	@f
3038
	jz	@f
3029
	ret
3039
	ret
3030
@@:
3040
@@:
3031
	mov	ebx, fn70_attr_block
3041
	mov	ebx, fn70_attr_block
3032
	mov	[ebx+21], esi
3042
	mov	[ebx+21], esi
3033
	mcall	70
3043
	mcall	70
3034
	test	eax, eax
3044
	test	eax, eax
3035
	jnz	.fileerr
3045
	jnz	.fileerr
3036
	cmp	dword [fileattr+36], edi
3046
	cmp	dword [fileattr+36], edi
3037
	jnz	.memerr
3047
	jnz	.memerr
3038
	mov	ecx, dword [fileattr+32]
3048
	mov	ecx, dword [fileattr+32]
3039
	mcall	68, 12
3049
	mcall	68, 12
3040
	test	eax, eax
3050
	test	eax, eax
3041
	jz	.memerr
3051
	jz	.memerr
3042
	mov	edi, eax
3052
	mov	edi, eax
3043
	mov	ebx, fn70_read_block
3053
	mov	ebx, fn70_read_block
3044
	mov	[ebx+12], ecx
3054
	mov	[ebx+12], ecx
3045
	mov	[ebx+16], edi
3055
	mov	[ebx+16], edi
3046
	mov	[ebx+21], esi
3056
	mov	[ebx+21], esi
3047
	mcall	70
3057
	mcall	70
3048
	test	eax, eax
3058
	test	eax, eax
3049
	jnz	.fileerr
3059
	jnz	.fileerr
3050
; calculate memory requirements
3060
; calculate memory requirements
3051
	lea	edx, [ecx+edi-1]	; edx = EOF-1
3061
	lea	edx, [ecx+edi-1]	; edx = EOF-1
3052
	mov	esi, edi
3062
	mov	esi, edi
3053
	xor	ecx, ecx
3063
	xor	ecx, ecx
3054
.calcloop:
3064
.calcloop:
3055
	cmp	esi, edx
3065
	cmp	esi, edx
3056
	jae	.calcdone
3066
	jae	.calcdone
3057
	cmp	word [esi], '0x'
3067
	cmp	word [esi], '0x'
3058
	jnz	.skipline
3068
	jnz	.skipline
3059
	inc	esi
3069
	inc	esi
3060
	inc	esi
3070
	inc	esi
3061
@@:
3071
@@:
3062
	cmp	esi, edx
3072
	cmp	esi, edx
3063
	jae	.calcdone
3073
	jae	.calcdone
3064
	lodsb
3074
	lodsb
3065
	or	al, 20h
3075
	or	al, 20h
3066
	sub	al, '0'
3076
	sub	al, '0'
3067
	cmp	al, 9
3077
	cmp	al, 9
3068
	jbe	@b
3078
	jbe	@b
3069
	sub	al, 'a'-'0'-10
3079
	sub	al, 'a'-'0'-10
3070
	cmp	al, 15
3080
	cmp	al, 15
3071
	jbe	@b
3081
	jbe	@b
3072
	dec	esi
3082
	dec	esi
3073
@@:
3083
@@:
3074
	cmp	esi, edx
3084
	cmp	esi, edx
3075
	ja	.calcdone
3085
	ja	.calcdone
3076
	lodsb
3086
	lodsb
3077
	cmp	al, 20h
3087
	cmp	al, 20h
3078
	jz	@b
3088
	jz	@b
3079
	jb	.calcloop
3089
	jb	.calcloop
3080
	cmp	al, 9
3090
	cmp	al, 9
3081
	jz	@b
3091
	jz	@b
3082
	add	ecx, 12+1
3092
	add	ecx, 12+1
3083
	inc	[num_symbols]
3093
	inc	[num_symbols]
3084
@@:
3094
@@:
3085
	inc	ecx
3095
	inc	ecx
3086
	cmp	esi, edx
3096
	cmp	esi, edx
3087
	ja	.calcdone
3097
	ja	.calcdone
3088
	lodsb
3098
	lodsb
3089
	cmp	al, 0xD
3099
	cmp	al, 0xD
3090
	jz	.calcloop
3100
	jz	.calcloop
3091
	cmp	al, 0xA
3101
	cmp	al, 0xA
3092
	jz	.calcloop
3102
	jz	.calcloop
3093
	jmp	@b
3103
	jmp	@b
3094
.skipline:
3104
.skipline:
3095
	cmp	esi, edx
3105
	cmp	esi, edx
3096
	jae	.calcdone
3106
	jae	.calcdone
3097
	lodsb
3107
	lodsb
3098
	cmp	al, 0xD
3108
	cmp	al, 0xD
3099
	jz	.calcloop
3109
	jz	.calcloop
3100
	cmp	al, 0xA
3110
	cmp	al, 0xA
3101
	jz	.calcloop
3111
	jz	.calcloop
3102
	jmp	.skipline
3112
	jmp	.skipline
3103
.calcdone:
3113
.calcdone:
3104
	mcall	68, 12
3114
	mcall	68, 12
3105
	test	eax, eax
3115
	test	eax, eax
3106
	jnz	.memok
3116
	jnz	.memok
3107
	inc	ebx
3117
	inc	ebx
3108
	mov	ecx, edi
3118
	mov	ecx, edi
3109
	mov	al, 68
3119
	mov	al, 68
3110
	mcall
3120
	mcall
3111
.memerr:
3121
.memerr:
3112
	mov	esi, aNoMemory
3122
	mov	esi, aNoMemory
3113
	jmp	put_message
3123
	jmp	put_message
3114
.memok:
3124
.memok:
3115
	mov	[symbols], eax
3125
	mov	[symbols], eax
3116
	mov	ebx, eax
3126
	mov	ebx, eax
3117
	push	edi
3127
	push	edi
3118
	mov	esi, edi
3128
	mov	esi, edi
3119
	mov	edi, [num_symbols]
3129
	mov	edi, [num_symbols]
3120
	lea	ebp, [eax+edi*4]
3130
	lea	ebp, [eax+edi*4]
3121
	lea	edi, [eax+edi*8]
3131
	lea	edi, [eax+edi*8]
3122
; parse input data, esi->input, edx->EOF, ebx->ptrs, edi->names
3132
; parse input data, esi->input, edx->EOF, ebx->ptrs, edi->names
3123
.readloop:
3133
.readloop:
3124
	cmp	esi, edx
3134
	cmp	esi, edx
3125
	jae	.readdone
3135
	jae	.readdone
3126
	cmp	word [esi], '0x'
3136
	cmp	word [esi], '0x'
3127
	jnz	.readline
3137
	jnz	.readline
3128
	inc	esi
3138
	inc	esi
3129
	inc	esi
3139
	inc	esi
3130
	xor	eax, eax
3140
	xor	eax, eax
3131
	xor	ecx, ecx
3141
	xor	ecx, ecx
3132
@@:
3142
@@:
3133
	shl	ecx, 4
3143
	shl	ecx, 4
3134
	add	ecx, eax
3144
	add	ecx, eax
3135
	cmp	esi, edx
3145
	cmp	esi, edx
3136
	jae	.readdone
3146
	jae	.readdone
3137
	lodsb
3147
	lodsb
3138
	or	al, 20h
3148
	or	al, 20h
3139
	sub	al, '0'
3149
	sub	al, '0'
3140
	cmp	al, 9
3150
	cmp	al, 9
3141
	jbe	@b
3151
	jbe	@b
3142
	sub	al, 'a'-'0'-10
3152
	sub	al, 'a'-'0'-10
3143
	cmp	al, 15
3153
	cmp	al, 15
3144
	jbe	@b
3154
	jbe	@b
3145
	dec	esi
3155
	dec	esi
3146
@@:
3156
@@:
3147
	cmp	esi, edx
3157
	cmp	esi, edx
3148
	ja	.readdone
3158
	ja	.readdone
3149
	lodsb
3159
	lodsb
3150
	cmp	al, 20h
3160
	cmp	al, 20h
3151
	jz	@b
3161
	jz	@b
3152
	jb	.readloop
3162
	jb	.readloop
3153
	cmp	al, 9
3163
	cmp	al, 9
3154
	jz	@b
3164
	jz	@b
3155
	mov	dword [ebx], edi
3165
	mov	dword [ebx], edi
3156
	add	ebx, 4
3166
	add	ebx, 4
3157
	mov	dword [ebp], edi
3167
	mov	dword [ebp], edi
3158
	add	ebp, 4
3168
	add	ebp, 4
3159
	mov	dword [edi], ecx
3169
	mov	dword [edi], ecx
3160
	add	edi, 4
3170
	add	edi, 4
3161
	stosb
3171
	stosb
3162
@@:
3172
@@:
3163
	xor	eax, eax
3173
	xor	eax, eax
3164
	stosb
3174
	stosb
3165
	cmp	esi, edx
3175
	cmp	esi, edx
3166
	ja	.readdone
3176
	ja	.readdone
3167
	lodsb
3177
	lodsb
3168
	cmp	al, 0xD
3178
	cmp	al, 0xD
3169
	jz	.readloop
3179
	jz	.readloop
3170
	cmp	al, 0xA
3180
	cmp	al, 0xA
3171
	jz	.readloop
3181
	jz	.readloop
3172
	mov	byte [edi-1], al
3182
	mov	byte [edi-1], al
3173
	jmp	@b
3183
	jmp	@b
3174
.readline:
3184
.readline:
3175
	cmp	esi, edx
3185
	cmp	esi, edx
3176
	jae	.readdone
3186
	jae	.readdone
3177
	lodsb
3187
	lodsb
3178
	cmp	al, 0xD
3188
	cmp	al, 0xD
3179
	jz	.readloop
3189
	jz	.readloop
3180
	cmp	al, 0xA
3190
	cmp	al, 0xA
3181
	jz	.readloop
3191
	jz	.readloop
3182
	jmp	.readline
3192
	jmp	.readline
3183
.readdone:
3193
.readdone:
3184
	pop	ecx
3194
	pop	ecx
3185
	mcall	68, 13
3195
	mcall	68, 13
3186
	mov	ecx, [num_symbols]
3196
	mov	ecx, [num_symbols]
3187
	mov	edx, [symbols]
3197
	mov	edx, [symbols]
3188
	mov	ebx, compare
3198
	mov	ebx, compare
3189
	call	sort
3199
	call	sort
3190
	mov	ecx, [num_symbols]
3200
	mov	ecx, [num_symbols]
3191
	lea	edx, [edx+ecx*4]
3201
	lea	edx, [edx+ecx*4]
3192
	mov	ebx, compare2
3202
	mov	ebx, compare2
3193
	call	sort
3203
	call	sort
3194
	mov	esi, aSymbolsLoaded
3204
	mov	esi, aSymbolsLoaded
3195
	call	put_message
3205
	call	put_message
3196
	jmp	redraw_disasm
3206
	jmp	redraw_disasm
3197
 
3207
 
3198
find_symbol:
3208
find_symbol:
3199
; in: eax=address
3209
; in: eax=address
3200
; out: esi, CF
3210
; out: esi, CF
3201
	cmp	[num_symbols], 0
3211
	cmp	[num_symbols], 0
3202
	jnz	@f
3212
	jnz	@f
3203
.ret0:
3213
.ret0:
3204
	xor	esi, esi
3214
	xor	esi, esi
3205
	stc
3215
	stc
3206
	ret
3216
	ret
3207
@@:
3217
@@:
3208
	push	ebx ecx edx
3218
	push	ebx ecx edx
3209
	xor	edx, edx
3219
	xor	edx, edx
3210
	mov	esi, [symbols]
3220
	mov	esi, [symbols]
3211
	mov	ecx, [num_symbols]
3221
	mov	ecx, [num_symbols]
3212
	mov	ebx, [esi]
3222
	mov	ebx, [esi]
3213
	cmp	[ebx], eax
3223
	cmp	[ebx], eax
3214
	jz	.donez
3224
	jz	.donez
3215
	jb	@f
3225
	jb	@f
3216
	pop	edx ecx ebx
3226
	pop	edx ecx ebx
3217
	jmp	.ret0
3227
	jmp	.ret0
3218
@@:
3228
@@:
3219
; invariant: symbols_addr[edx] < eax < symbols_addr[ecx]
3229
; invariant: symbols_addr[edx] < eax < symbols_addr[ecx]
3220
.0:
3230
.0:
3221
	push	edx
3231
	push	edx
3222
.1:
3232
.1:
3223
	add	edx, ecx
3233
	add	edx, ecx
3224
	sar	edx, 1
3234
	sar	edx, 1
3225
	cmp	edx, [esp]
3235
	cmp	edx, [esp]
3226
	jz	.done2
3236
	jz	.done2
3227
	mov	ebx, [esi+edx*4]
3237
	mov	ebx, [esi+edx*4]
3228
	cmp	[ebx], eax
3238
	cmp	[ebx], eax
3229
	jz	.done
3239
	jz	.done
3230
	ja	.2
3240
	ja	.2
3231
	mov	[esp], edx
3241
	mov	[esp], edx
3232
	jmp	.1
3242
	jmp	.1
3233
.2:
3243
.2:
3234
	mov	ecx, edx
3244
	mov	ecx, edx
3235
	pop	edx
3245
	pop	edx
3236
	jmp	.0
3246
	jmp	.0
3237
.donecont:
3247
.donecont:
3238
	dec	edx
3248
	dec	edx
3239
.done:
3249
.done:
3240
	test	edx, edx
3250
	test	edx, edx
3241
	jz	@f
3251
	jz	@f
3242
	mov	ebx, [esi+edx*4-4]
3252
	mov	ebx, [esi+edx*4-4]
3243
	cmp	[ebx], eax
3253
	cmp	[ebx], eax
3244
	jz	.donecont
3254
	jz	.donecont
3245
@@:
3255
@@:
3246
	pop	ecx
3256
	pop	ecx
3247
.donez:
3257
.donez:
3248
	mov	esi, [esi+edx*4]
3258
	mov	esi, [esi+edx*4]
3249
	add	esi, 4
3259
	add	esi, 4
3250
	pop	edx ecx ebx
3260
	pop	edx ecx ebx
3251
	clc
3261
	clc
3252
	ret
3262
	ret
3253
.done2:
3263
.done2:
3254
	lea	esi, [esi+edx*4]
3264
	lea	esi, [esi+edx*4]
3255
	pop	ecx edx ecx ebx
3265
	pop	ecx edx ecx ebx
3256
	stc
3266
	stc
3257
	ret
3267
	ret
3258
 
3268
 
3259
find_symbol_name:
3269
find_symbol_name:
3260
; in: esi->name
3270
; in: esi->name
3261
; out: if found: CF clear, eax=value
3271
; out: if found: CF clear, eax=value
3262
;      otherwise CF set
3272
;      otherwise CF set
3263
	cmp	[num_symbols], 0
3273
	cmp	[num_symbols], 0
3264
	jnz	@f
3274
	jnz	@f
3265
.stc_ret:
3275
.stc_ret:
3266
	stc
3276
	stc
3267
	ret
3277
	ret
3268
@@:
3278
@@:
3269
	push	ebx ecx edx edi
3279
	push	ebx ecx edx edi
3270
	push	-1
3280
	push	-1
3271
	pop	edx
3281
	pop	edx
3272
	mov	ebx, [symbols]
3282
	mov	ebx, [symbols]
3273
	mov	ecx, [num_symbols]
3283
	mov	ecx, [num_symbols]
3274
	lea	ebx, [ebx+ecx*4]
3284
	lea	ebx, [ebx+ecx*4]
3275
; invariant: symbols_name[edx] < name < symbols_name[ecx]
3285
; invariant: symbols_name[edx] < name < symbols_name[ecx]
3276
.0:
3286
.0:
3277
	push	edx
3287
	push	edx
3278
.1:
3288
.1:
3279
	add	edx, ecx
3289
	add	edx, ecx
3280
	sar	edx, 1
3290
	sar	edx, 1
3281
	cmp	edx, [esp]
3291
	cmp	edx, [esp]
3282
	jz	.done2
3292
	jz	.done2
3283
	call	.cmp
3293
	call	.cmp
3284
	jz	.done
3294
	jz	.done
3285
	jb	.2
3295
	jb	.2
3286
	mov	[esp], edx
3296
	mov	[esp], edx
3287
	jmp	.1
3297
	jmp	.1
3288
.2:
3298
.2:
3289
	mov	ecx, edx
3299
	mov	ecx, edx
3290
	pop	edx
3300
	pop	edx
3291
	jmp	.0
3301
	jmp	.0
3292
.done:
3302
.done:
3293
	pop	ecx
3303
	pop	ecx
3294
.donez:
3304
.donez:
3295
	mov	eax, [ebx+edx*4]
3305
	mov	eax, [ebx+edx*4]
3296
	mov	eax, [eax]
3306
	mov	eax, [eax]
3297
	pop	edi edx ecx ebx
3307
	pop	edi edx ecx ebx
3298
	clc
3308
	clc
3299
	ret
3309
	ret
3300
.done2:
3310
.done2:
3301
	pop	edx edi edx ecx ebx
3311
	pop	edx edi edx ecx ebx
3302
	stc
3312
	stc
3303
	ret
3313
	ret
3304
 
3314
 
3305
.cmp:
3315
.cmp:
3306
	mov	edi, [ebx+edx*4]
3316
	mov	edi, [ebx+edx*4]
3307
	push	esi
3317
	push	esi
3308
	add	edi, 4
3318
	add	edi, 4
3309
@@:
3319
@@:
3310
	cmpsb
3320
	cmpsb
3311
	jnz	@f
3321
	jnz	@f
3312
	cmp	byte [esi-1], 0
3322
	cmp	byte [esi-1], 0
3313
	jnz	@b
3323
	jnz	@b
3314
@@:
3324
@@:
3315
	pop	esi
3325
	pop	esi
3316
	ret
3326
	ret
3317
 
3327
 
3318
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3328
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3319
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISASSEMBLER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3329
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DISASSEMBLER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3320
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3330
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3321
 
3331
 
3322
disasm_get_byte:
3332
disasm_get_byte:
3323
; out: al=byte
3333
; out: al=byte
3324
	push	ecx
3334
	push	ecx
3325
	mov	ecx, [disasm_cur_pos]
3335
	mov	ecx, [disasm_cur_pos]
3326
	sub	ecx, [disasm_start_pos]
3336
	sub	ecx, [disasm_start_pos]
3327
	cmp	ecx, [disasm_buf_size]
3337
	cmp	ecx, [disasm_buf_size]
3328
	jae	disasm_err
3338
	jae	disasm_err
3329
	mov	al, [disasm_buffer+ecx]
3339
	mov	al, [disasm_buffer+ecx]
3330
	pop	ecx
3340
	pop	ecx
3331
	inc	[disasm_cur_pos]
3341
	inc	[disasm_cur_pos]
3332
	ret
3342
	ret
3333
disasm_get_word:
3343
disasm_get_word:
3334
	push	ecx
3344
	push	ecx
3335
	mov	ecx, [disasm_cur_pos]
3345
	mov	ecx, [disasm_cur_pos]
3336
	sub	ecx, [disasm_start_pos]
3346
	sub	ecx, [disasm_start_pos]
3337
	inc	ecx
3347
	inc	ecx
3338
	cmp	ecx, [disasm_buf_size]
3348
	cmp	ecx, [disasm_buf_size]
3339
	jae	disasm_err
3349
	jae	disasm_err
3340
	mov	ax, word [disasm_buffer-1+ecx]
3350
	mov	ax, word [disasm_buffer-1+ecx]
3341
	pop	ecx
3351
	pop	ecx
3342
	add	[disasm_cur_pos], 2
3352
	add	[disasm_cur_pos], 2
3343
	ret
3353
	ret
3344
disasm_get_dword:
3354
disasm_get_dword:
3345
	push	ecx
3355
	push	ecx
3346
	mov	ecx, [disasm_cur_pos]
3356
	mov	ecx, [disasm_cur_pos]
3347
	sub	ecx, [disasm_start_pos]
3357
	sub	ecx, [disasm_start_pos]
3348
	add	ecx, 3
3358
	add	ecx, 3
3349
	cmp	ecx, [disasm_buf_size]
3359
	cmp	ecx, [disasm_buf_size]
3350
	jae	disasm_err
3360
	jae	disasm_err
3351
	mov	eax, dword [disasm_buffer-3+ecx]
3361
	mov	eax, dword [disasm_buffer-3+ecx]
3352
	pop	ecx
3362
	pop	ecx
3353
	add	[disasm_cur_pos], 4
3363
	add	[disasm_cur_pos], 4
3354
	ret
3364
	ret
3355
 
3365
 
3356
disasm_err:
3366
disasm_err:
3357
	mov	esp, ebp
3367
	mov	esp, ebp
3358
stc_ret:
3368
stc_ret:
3359
	stc
3369
	stc
3360
	ret
3370
	ret
3361
disasm_ret:
3371
disasm_ret:
3362
	mov	esp, ebp
3372
	mov	esp, ebp
3363
	and	byte [edi], 0
3373
	and	byte [edi], 0
3364
	ret
3374
	ret
3365
 
3375
 
3366
disasm_instr:
3376
disasm_instr:
3367
	mov	ebp, esp
3377
	mov	ebp, esp
3368
	cmp	[debuggee_pid], 0
3378
	cmp	[debuggee_pid], 0
3369
	jz	stc_ret
3379
	jz	stc_ret
3370
	mov	edi, disasm_string
3380
	mov	edi, disasm_string
3371
	xor	ecx, ecx
3381
	xor	ecx, ecx
3372
; ecx=flags
3382
; ecx=flags
3373
disasm_loop1:
3383
disasm_loop1:
3374
	xor	eax, eax
3384
	xor	eax, eax
3375
	call	disasm_get_byte
3385
	call	disasm_get_byte
3376
	jmp	dword [disasm_table_1 + eax*4]
3386
	jmp	dword [disasm_table_1 + eax*4]
3377
 
3387
 
3378
cop0:
3388
cop0:
3379
clock:
3389
clock:
3380
csegcs:
3390
csegcs:
3381
csegds:
3391
csegds:
3382
cseges:
3392
cseges:
3383
csegss:
3393
csegss:
3384
csegfs:
3394
csegfs:
3385
cseggs:
3395
cseggs:
3386
	mov	esi, cmd1
3396
	mov	esi, cmd1
3387
iglobal
3397
iglobal
3388
cmd1:
3398
cmd1:
3389
	db	0x2E,3,'cs:'
3399
	db	0x2E,3,'cs:'
3390
	db	0x36,3,'ss:'
3400
	db	0x36,3,'ss:'
3391
	db	0x3E,3,'ds:'
3401
	db	0x3E,3,'ds:'
3392
	db	0x26,3,'es:'
3402
	db	0x26,3,'es:'
3393
	db	0x64,3,'fs:'
3403
	db	0x64,3,'fs:'
3394
	db	0x65,3,'gs:'
3404
	db	0x65,3,'gs:'
3395
	db	0x06,10,'push    es'
3405
	db	0x06,10,'push    es'
3396
	db	0x07,10,'pop     es'
3406
	db	0x07,10,'pop     es'
3397
	db	0x0E,10,'push    cs'
3407
	db	0x0E,10,'push    cs'
3398
	db	0x16,10,'push    ss'
3408
	db	0x16,10,'push    ss'
3399
	db	0x17,10,'pop     ss'
3409
	db	0x17,10,'pop     ss'
3400
	db	0x1E,10,'push    ds'
3410
	db	0x1E,10,'push    ds'
3401
	db	0x1F,10,'pop     ds'
3411
	db	0x1F,10,'pop     ds'
3402
	db	0x27,3,'daa'
3412
	db	0x27,3,'daa'
3403
	db	0x2F,3,'das'
3413
	db	0x2F,3,'das'
3404
	db	0x37,3,'aaa'
3414
	db	0x37,3,'aaa'
3405
	db	0x3F,3,'aas'
3415
	db	0x3F,3,'aas'
3406
	db	0x60,6,0,'pusha'
3416
	db	0x60,6,0,'pusha'
3407
	db	0x61,5,0,'popa'
3417
	db	0x61,5,0,'popa'
3408
	db	0x90,3,'nop'
3418
	db	0x90,3,'nop'
3409
	db	0x9B,5,'fwait'
3419
	db	0x9B,5,'fwait'
3410
	db	0x9C,6,0,'pushf'
3420
	db	0x9C,6,0,'pushf'
3411
	db	0x9D,5,0,'popf'
3421
	db	0x9D,5,0,'popf'
3412
	db	0x9E,4,'sahf'
3422
	db	0x9E,4,'sahf'
3413
	db	0x9F,4,'lahf'
3423
	db	0x9F,4,'lahf'
3414
	db	0xA4,5,'movsb'
3424
	db	0xA4,5,'movsb'
3415
	db	0xA5,5,0,'movs'
3425
	db	0xA5,5,0,'movs'
3416
	db	0xA6,5,'cmpsb'
3426
	db	0xA6,5,'cmpsb'
3417
	db	0xA7,5,0,'cmps'
3427
	db	0xA7,5,0,'cmps'
3418
	db	0xAA,5,'stosb'
3428
	db	0xAA,5,'stosb'
3419
	db	0xAB,5,0,'stos'
3429
	db	0xAB,5,0,'stos'
3420
	db	0xAC,5,'lodsb'
3430
	db	0xAC,5,'lodsb'
3421
	db	0xAD,5,0,'lods'
3431
	db	0xAD,5,0,'lods'
3422
	db	0xAE,5,'scasb'
3432
	db	0xAE,5,'scasb'
3423
	db	0xAF,5,0,'scas'
3433
	db	0xAF,5,0,'scas'
3424
	db	0xC3,3,'ret'
3434
	db	0xC3,3,'ret'
3425
	db	0xC9,5,'leave'
3435
	db	0xC9,5,'leave'
3426
	db	0xCC,4,'int3'
3436
	db	0xCC,4,'int3'
3427
	db	0xF0,4,'lock'
3437
	db	0xF0,4,'lock'
3428
	db	0xF5,3,'cmc'
3438
	db	0xF5,3,'cmc'
3429
	db	0xF8,3,'clc'
3439
	db	0xF8,3,'clc'
3430
	db	0xF9,3,'stc'
3440
	db	0xF9,3,'stc'
3431
	db	0xFA,3,'cli'
3441
	db	0xFA,3,'cli'
3432
	db	0xFB,3,'sti'
3442
	db	0xFB,3,'sti'
3433
	db	0xFC,3,'cld'
3443
	db	0xFC,3,'cld'
3434
	db	0xFD,3,'std'
3444
	db	0xFD,3,'std'
3435
cmd2:
3445
cmd2:
3436
	db	0x05,7,'syscall'
3446
	db	0x05,7,'syscall'
3437
	db	0x06,4,'clts'
3447
	db	0x06,4,'clts'
3438
	db	0x31,5,'rdtsc'
3448
	db	0x31,5,'rdtsc'
3439
	db	0x34,8,'sysenter'
3449
	db	0x34,8,'sysenter'
3440
	db	0xA2,5,'cpuid'
3450
	db	0xA2,5,'cpuid'
3441
	db	0x77,4,'emms'
3451
	db	0x77,4,'emms'
3442
endg
3452
endg
3443
	jmp	@f
3453
	jmp	@f
3444
ccpuid:
3454
ccpuid:
3445
crdtsc:
3455
crdtsc:
3446
cemms:
3456
cemms:
3447
cop0_F:
3457
cop0_F:
3448
	mov	esi, cmd2
3458
	mov	esi, cmd2
3449
@@:
3459
@@:
3450
	cmp	al, [esi]
3460
	cmp	al, [esi]
3451
	jz	.found
3461
	jz	.found
3452
	inc	esi
3462
	inc	esi
3453
	movzx	edx, byte [esi]
3463
	movzx	edx, byte [esi]
3454
	inc	esi
3464
	inc	esi
3455
	add	esi, edx
3465
	add	esi, edx
3456
	jmp	@b
3466
	jmp	@b
3457
.found:
3467
.found:
3458
	inc	esi
3468
	inc	esi
3459
	lodsb
3469
	lodsb
3460
	cmp	byte [esi], 0
3470
	cmp	byte [esi], 0
3461
	jz	@f
3471
	jz	@f
3462
	movzx	ecx, al
3472
	movzx	ecx, al
3463
disasm_1:
3473
disasm_1:
3464
	rep	movsb
3474
	rep	movsb
3465
	and	byte [edi], 0
3475
	and	byte [edi], 0
3466
	ret
3476
	ret
3467
@@:
3477
@@:
3468
	mov	dl, ch
3478
	mov	dl, ch
3469
	movzx	ecx, al
3479
	movzx	ecx, al
3470
	dec	ecx
3480
	dec	ecx
3471
	inc	esi
3481
	inc	esi
3472
	rep	movsb
3482
	rep	movsb
3473
	test	dl, 1
3483
	test	dl, 1
3474
	mov	al, 'w'
3484
	mov	al, 'w'
3475
	jnz	@f
3485
	jnz	@f
3476
	mov	al, 'd'
3486
	mov	al, 'd'
3477
@@:	stosb
3487
@@:	stosb
3478
	and	byte [edi], 0
3488
	and	byte [edi], 0
3479
	ret
3489
	ret
3480
 
3490
 
3481
c67:
3491
c67:
3482
	or	ch, 2
3492
	or	ch, 2
3483
	jmp	disasm_loop1
3493
	jmp	disasm_loop1
3484
c66:
3494
c66:
3485
	or	ch, 1
3495
	or	ch, 1
3486
	jmp	disasm_loop1
3496
	jmp	disasm_loop1
3487
 
3497
 
3488
cxlat:
3498
cxlat:
3489
cunk:
3499
cunk:
3490
cerr:
3500
cerr:
3491
	mov	eax, '???'
3501
	mov	eax, '???'
3492
	stosd
3502
	stosd
3493
	clc
3503
	clc
3494
	ret
3504
	ret
3495
 
3505
 
3496
cF:
3506
cF:
3497
	call	disasm_get_byte
3507
	call	disasm_get_byte
3498
	jmp	dword [disasm_table_2 + eax*4]
3508
	jmp	dword [disasm_table_2 + eax*4]
3499
 
3509
 
3500
crep:
3510
crep:
3501
	push	[disasm_cur_pos]
3511
	push	[disasm_cur_pos]
3502
	call	disasm_get_byte
3512
	call	disasm_get_byte
3503
	cmp	al, 0x0F
3513
	cmp	al, 0x0F
3504
	jz	.sse
3514
	jz	.sse
3505
	mov	dl, al
3515
	mov	dl, al
3506
	mov	eax, 'rep '
3516
	mov	eax, 'rep '
3507
	stosd
3517
	stosd
3508
	mov	al, dl
3518
	mov	al, dl
3509
@@:
3519
@@:
3510
	and	eax, not 1
3520
	and	eax, not 1
3511
	cmp	al, 0x66
3521
	cmp	al, 0x66
3512
	jnz	@f
3522
	jnz	@f
3513
	call	disasm_get_byte
3523
	call	disasm_get_byte
3514
	mov	dl, al
3524
	mov	dl, al
3515
	jmp	@b
3525
	jmp	@b
3516
@@:
3526
@@:
3517
	cmp	al, 0xA6
3527
	cmp	al, 0xA6
3518
	jz	.repz
3528
	jz	.repz
3519
	cmp	al, 0xAE
3529
	cmp	al, 0xAE
3520
	jz	.repz
3530
	jz	.repz
3521
	cmp	al, 0xA4
3531
	cmp	al, 0xA4
3522
	jz	.prefix
3532
	jz	.prefix
3523
	cmp	al, 0xAA
3533
	cmp	al, 0xAA
3524
	jz	.prefix
3534
	jz	.prefix
3525
	cmp	al, 0xAC
3535
	cmp	al, 0xAC
3526
	jz	.prefix
3536
	jz	.prefix
3527
	cmp	al, 0x6C
3537
	cmp	al, 0x6C
3528
	jz	.prefix
3538
	jz	.prefix
3529
	cmp	al, 0x6E
3539
	cmp	al, 0x6E
3530
	jz	.prefix
3540
	jz	.prefix
3531
.noprefix:
3541
.noprefix:
3532
	pop	[disasm_cur_pos]
3542
	pop	[disasm_cur_pos]
3533
	and	byte [edi-1], 0
3543
	and	byte [edi-1], 0
3534
	ret
3544
	ret
3535
.repz:
3545
.repz:
3536
	mov	byte [edi-1], 'z'
3546
	mov	byte [edi-1], 'z'
3537
	mov	al, ' '
3547
	mov	al, ' '
3538
	stosb
3548
	stosb
3539
.prefix:
3549
.prefix:
3540
	pop	[disasm_cur_pos]
3550
	pop	[disasm_cur_pos]
3541
	jmp	disasm_loop1
3551
	jmp	disasm_loop1
3542
.sse:
3552
.sse:
3543
	pop	eax
3553
	pop	eax
3544
	call	disasm_get_byte
3554
	call	disasm_get_byte
3545
iglobal
3555
iglobal
3546
rep_sse_cmds:
3556
rep_sse_cmds:
3547
	db	0x58,3,'add'
3557
	db	0x58,3,'add'
3548
	db	0xC2,3,'cmp'
3558
	db	0xC2,3,'cmp'
3549
	db	0,0
3559
	db	0,0
3550
endg
3560
endg
3551
	mov	esi, rep_sse_cmds+1
3561
	mov	esi, rep_sse_cmds+1
3552
@@:
3562
@@:
3553
	movzx	edx, byte [esi]
3563
	movzx	edx, byte [esi]
3554
	cmp	al, [esi-1]
3564
	cmp	al, [esi-1]
3555
	jz	@f
3565
	jz	@f
3556
	lea	esi, [esi+edx+2]
3566
	lea	esi, [esi+edx+2]
3557
	cmp	byte [esi], 0
3567
	cmp	byte [esi], 0
3558
	jnz	@b
3568
	jnz	@b
3559
	sub	[disasm_cur_pos], 2
3569
	sub	[disasm_cur_pos], 2
3560
	mov	eax, 'rep'
3570
	mov	eax, 'rep'
3561
	stosd
3571
	stosd
3562
	ret
3572
	ret
3563
@@:
3573
@@:
3564
	push	ecx
3574
	push	ecx
3565
	mov	ecx, edx
3575
	mov	ecx, edx
3566
	inc	esi
3576
	inc	esi
3567
	rep	movsb
3577
	rep	movsb
3568
	pop	ecx
3578
	pop	ecx
3569
	mov	al, 's'
3579
	mov	al, 's'
3570
	stosb
3580
	stosb
3571
	jmp	rep_sse_final
3581
	jmp	rep_sse_final
3572
 
3582
 
3573
crepnz:
3583
crepnz:
3574
	call	disasm_get_byte
3584
	call	disasm_get_byte
3575
	cmp	al, 0x0F
3585
	cmp	al, 0x0F
3576
	jz	.sse
3586
	jz	.sse
3577
	mov	dl, al
3587
	mov	dl, al
3578
	mov	eax, 'repn'
3588
	mov	eax, 'repn'
3579
	stosd
3589
	stosd
3580
	mov	al, 'z'
3590
	mov	al, 'z'
3581
	stosb
3591
	stosb
3582
	mov	al, ' '
3592
	mov	al, ' '
3583
	stosb
3593
	stosb
3584
	movzx	eax, dl
3594
	movzx	eax, dl
3585
	cmp	al, 0x6C
3595
	cmp	al, 0x6C
3586
	jb	crep.noprefix
3596
	jb	crep.noprefix
3587
	cmp	al, 0x6F
3597
	cmp	al, 0x6F
3588
	jbe	.prefix
3598
	jbe	.prefix
3589
	cmp	al, 0xA4
3599
	cmp	al, 0xA4
3590
	jb	crep.noprefix
3600
	jb	crep.noprefix
3591
	cmp	al, 0xA7
3601
	cmp	al, 0xA7
3592
	jbe	.prefix
3602
	jbe	.prefix
3593
	cmp	al, 0xAA
3603
	cmp	al, 0xAA
3594
	jb	crep.noprefix
3604
	jb	crep.noprefix
3595
	cmp	al, 0xAF
3605
	cmp	al, 0xAF
3596
	ja	crep.noprefix
3606
	ja	crep.noprefix
3597
.prefix:
3607
.prefix:
3598
	jmp	cop0
3608
	jmp	cop0
3599
.sse:
3609
.sse:
3600
	call	disasm_get_byte
3610
	call	disasm_get_byte
3601
	mov	esi, rep_sse_cmds+1
3611
	mov	esi, rep_sse_cmds+1
3602
@@:
3612
@@:
3603
	movzx	edx, byte [esi]
3613
	movzx	edx, byte [esi]
3604
	cmp	al, [esi-1]
3614
	cmp	al, [esi-1]
3605
	jz	.found0
3615
	jz	.found0
3606
	lea	esi, [esi+edx+2]
3616
	lea	esi, [esi+edx+2]
3607
	cmp	byte [esi], 0
3617
	cmp	byte [esi], 0
3608
	jnz	@b
3618
	jnz	@b
3609
	mov	esi, sse_cmds2+1
3619
	mov	esi, sse_cmds2+1
3610
@@:
3620
@@:
3611
	movzx	edx, byte [esi]
3621
	movzx	edx, byte [esi]
3612
	cmp	al, [esi-1]
3622
	cmp	al, [esi-1]
3613
	jz	.found1
3623
	jz	.found1
3614
	lea	esi, [esi+edx+2]
3624
	lea	esi, [esi+edx+2]
3615
	cmp	byte [esi], 0
3625
	cmp	byte [esi], 0
3616
	jnz	@b
3626
	jnz	@b
3617
	sub	[disasm_cur_pos], 2
3627
	sub	[disasm_cur_pos], 2
3618
	mov	eax, 'repn'
3628
	mov	eax, 'repn'
3619
	stosd
3629
	stosd
3620
	mov	al, 'z'
3630
	mov	al, 'z'
3621
	stosb
3631
	stosb
3622
	and	byte [edi], 0
3632
	and	byte [edi], 0
3623
	ret
3633
	ret
3624
.found0:
3634
.found0:
3625
	push	ecx
3635
	push	ecx
3626
	mov	ecx, edx
3636
	mov	ecx, edx
3627
	inc	esi
3637
	inc	esi
3628
	rep	movsb
3638
	rep	movsb
3629
	pop	ecx
3639
	pop	ecx
3630
	mov	al, 's'
3640
	mov	al, 's'
3631
	stosb
3641
	stosb
3632
	mov	al, 'd'
3642
	mov	al, 'd'
3633
	jmp	rep_sse_final
3643
	jmp	rep_sse_final
3634
.found1:
3644
.found1:
3635
	push	ecx
3645
	push	ecx
3636
	mov	ecx, edx
3646
	mov	ecx, edx
3637
	inc	esi
3647
	inc	esi
3638
	rep	movsb
3648
	rep	movsb
3639
	pop	ecx
3649
	pop	ecx
3640
	mov	al, 'p'
3650
	mov	al, 'p'
3641
	stosb
3651
	stosb
3642
	mov	al, 's'
3652
	mov	al, 's'
3643
rep_sse_final:
3653
rep_sse_final:
3644
	stosb
3654
	stosb
3645
	push	ecx
3655
	push	ecx
3646
	push	5
3656
	push	5
3647
	pop	ecx
3657
	pop	ecx
3648
	sub	ecx, edx
3658
	sub	ecx, edx
3649
	adc	ecx, 1
3659
	adc	ecx, 1
3650
	mov	al, ' '
3660
	mov	al, ' '
3651
	rep	stosb
3661
	rep	stosb
3652
	pop	ecx
3662
	pop	ecx
3653
	or	ch, 1
3663
	or	ch, 1
3654
	jmp	disasm_mmx1
3664
	jmp	disasm_mmx1
3655
 
3665
 
3656
macro disasm_set_modew
3666
macro disasm_set_modew
3657
{
3667
{
3658
	test	al, 1
3668
	test	al, 1
3659
	jz	@f
3669
	jz	@f
3660
	or	ch, 80h
3670
	or	ch, 80h
3661
@@:
3671
@@:
3662
}
3672
}
3663
 
3673
 
3664
cmov2:
3674
cmov2:
3665
	disasm_set_modew
3675
	disasm_set_modew
3666
; mov r/m,i
3676
; mov r/m,i
3667
	call	disasm_get_byte
3677
	call	disasm_get_byte
3668
	dec	[disasm_cur_pos]
3678
	dec	[disasm_cur_pos]
3669
	test	al, 00111000b
3679
	test	al, 00111000b
3670
	jnz	cunk
3680
	jnz	cunk
3671
	mov	eax, 'mov '
3681
	mov	eax, 'mov '
3672
	stosd
3682
	stosd
3673
	mov	eax, '    '
3683
	mov	eax, '    '
3674
	stosd
3684
	stosd
3675
	call	disasm_readrmop
3685
	call	disasm_readrmop
3676
	mov	ax, ', '
3686
	mov	ax, ', '
3677
	stosw
3687
	stosw
3678
	xor	eax, eax
3688
	xor	eax, eax
3679
	test	ch, 80h
3689
	test	ch, 80h
3680
	jnz	.1
3690
	jnz	.1
3681
	call	disasm_get_byte
3691
	call	disasm_get_byte
3682
	jmp	.3
3692
	jmp	.3
3683
.1:
3693
.1:
3684
	test	ch, 1
3694
	test	ch, 1
3685
	jnz	.2
3695
	jnz	.2
3686
	call	disasm_get_dword
3696
	call	disasm_get_dword
3687
	jmp	.3
3697
	jmp	.3
3688
.2:
3698
.2:
3689
	call	disasm_get_word
3699
	call	disasm_get_word
3690
.3:
3700
.3:
3691
	call	disasm_write_num
3701
	call	disasm_write_num
3692
	and	byte [edi], 0
3702
	and	byte [edi], 0
3693
	ret
3703
	ret
3694
 
3704
 
3695
cret2:
3705
cret2:
3696
	mov	eax, 'ret '
3706
	mov	eax, 'ret '
3697
	stosd
3707
	stosd
3698
	mov	eax, '    '
3708
	mov	eax, '    '
3699
	stosd
3709
	stosd
3700
	xor	eax, eax
3710
	xor	eax, eax
3701
	jmp	cmov2.2
3711
	jmp	cmov2.2
3702
 
3712
 
3703
disasm_write_num:
3713
disasm_write_num:
3704
	push	esi
3714
	push	esi
3705
	cmp	eax, 0x80
3715
	cmp	eax, 0x80
3706
	jl	.nosymb
3716
	jl	.nosymb
3707
	lea	esi, [eax-1]
3717
	lea	esi, [eax-1]
3708
	test	eax, esi
3718
	test	eax, esi
3709
	jz	.nosymb
3719
	jz	.nosymb
3710
	call	find_symbol
3720
	call	find_symbol
3711
	jc	.nosymb
3721
	jc	.nosymb
3712
@@:
3722
@@:
3713
	lodsb
3723
	lodsb
3714
	test	al, al
3724
	test	al, al
3715
	jz	@f
3725
	jz	@f
3716
	stosb
3726
	stosb
3717
	jmp	@b
3727
	jmp	@b
3718
@@:
3728
@@:
3719
	pop	esi
3729
	pop	esi
3720
	ret
3730
	ret
3721
.nosymb:
3731
.nosymb:
3722
	pop	esi
3732
	pop	esi
3723
	push	ecx eax
3733
	push	ecx eax
3724
	inc	edi
3734
	inc	edi
3725
@@:
3735
@@:
3726
	mov	ecx, eax
3736
	mov	ecx, eax
3727
	shr	eax, 4
3737
	shr	eax, 4
3728
	jz	@f
3738
	jz	@f
3729
	inc	edi
3739
	inc	edi
3730
	jmp	@b
3740
	jmp	@b
3731
@@:
3741
@@:
3732
	pop	eax
3742
	pop	eax
3733
	cmp	ecx, 10
3743
	cmp	ecx, 10
3734
	jb	@f
3744
	jb	@f
3735
	inc	edi
3745
	inc	edi
3736
@@:
3746
@@:
3737
	push	edi eax
3747
	push	edi eax
3738
@@:
3748
@@:
3739
	mov	ecx, eax
3749
	mov	ecx, eax
3740
	and	al, 0xF
3750
	and	al, 0xF
3741
	cmp	al, 10
3751
	cmp	al, 10
3742
	sbb	al, 69h
3752
	sbb	al, 69h
3743
	das
3753
	das
3744
	dec	edi
3754
	dec	edi
3745
	mov	[edi], al
3755
	mov	[edi], al
3746
	mov	eax, ecx
3756
	mov	eax, ecx
3747
	shr	eax, 4
3757
	shr	eax, 4
3748
	jnz	@b
3758
	jnz	@b
3749
	cmp	ecx, 10
3759
	cmp	ecx, 10
3750
	jb	@f
3760
	jb	@f
3751
	mov	byte [edi-1], '0'
3761
	mov	byte [edi-1], '0'
3752
@@:
3762
@@:
3753
	pop	eax edi ecx
3763
	pop	eax edi ecx
3754
	cmp	eax, 10
3764
	cmp	eax, 10
3755
	jb	@f
3765
	jb	@f
3756
	mov	byte [edi], 'h'
3766
	mov	byte [edi], 'h'
3757
	inc	edi
3767
	inc	edi
3758
@@:
3768
@@:
3759
	ret
3769
	ret
3760
 
3770
 
3761
iglobal
3771
iglobal
3762
label disasm_regs32 dword
3772
label disasm_regs32 dword
3763
label disasm_regs dword
3773
label disasm_regs dword
3764
	db	'eax',0
3774
	db	'eax',0
3765
	db	'ecx',0
3775
	db	'ecx',0
3766
	db	'edx',0
3776
	db	'edx',0
3767
	db	'ebx',0
3777
	db	'ebx',0
3768
	db	'esp',0
3778
	db	'esp',0
3769
	db	'ebp',0
3779
	db	'ebp',0
3770
	db	'esi',0
3780
	db	'esi',0
3771
	db	'edi',0
3781
	db	'edi',0
3772
disasm_regs16	dw	'ax','cx','dx','bx','sp','bp','si','di'
3782
disasm_regs16	dw	'ax','cx','dx','bx','sp','bp','si','di'
3773
disasm_regs8	dw	'al','cl','dl','bl','ah','ch','dh','bh'
3783
disasm_regs8	dw	'al','cl','dl','bl','ah','ch','dh','bh'
3774
disasm_scale	db	'1248'
3784
disasm_scale	db	'1248'
3775
endg
3785
endg
3776
disasm_readrmop:
3786
disasm_readrmop:
3777
	call	disasm_get_byte
3787
	call	disasm_get_byte
3778
	test	ch, 40h
3788
	test	ch, 40h
3779
	jnz	.skip_size
3789
	jnz	.skip_size
3780
	push	eax
3790
	push	eax
3781
	and	al, 0xC0
3791
	and	al, 0xC0
3782
	cmp	al, 0xC0
3792
	cmp	al, 0xC0
3783
	pop	eax
3793
	pop	eax
3784
	jz	.skip_size
3794
	jz	.skip_size
3785
	test	ch, 80h
3795
	test	ch, 80h
3786
	jz	.byte
3796
	jz	.byte
3787
	test	ch, 1
3797
	test	ch, 1
3788
	jnz	.word
3798
	jnz	.word
3789
	mov	dword [edi], 'dwor'
3799
	mov	dword [edi], 'dwor'
3790
	mov	byte [edi+4], 'd'
3800
	mov	byte [edi+4], 'd'
3791
	inc	edi
3801
	inc	edi
3792
	jmp	@f
3802
	jmp	@f
3793
.byte:
3803
.byte:
3794
	test	ch, 20h
3804
	test	ch, 20h
3795
	jz	.qb
3805
	jz	.qb
3796
	mov	byte [edi], 't'
3806
	mov	byte [edi], 't'
3797
	inc	edi
3807
	inc	edi
3798
.qb:
3808
.qb:
3799
	mov	dword [edi], 'byte'
3809
	mov	dword [edi], 'byte'
3800
	jmp	@f
3810
	jmp	@f
3801
.word:
3811
.word:
3802
	test	ch, 20h
3812
	test	ch, 20h
3803
	jz	.qw
3813
	jz	.qw
3804
	mov	byte [edi], 'q'
3814
	mov	byte [edi], 'q'
3805
	inc	edi
3815
	inc	edi
3806
.qw:
3816
.qw:
3807
	mov	dword [edi], 'word'
3817
	mov	dword [edi], 'word'
3808
@@:
3818
@@:
3809
	mov	byte [edi+4], ' '
3819
	mov	byte [edi+4], ' '
3810
	add	edi, 5
3820
	add	edi, 5
3811
.skip_size:
3821
.skip_size:
3812
	test	ch, 2
3822
	test	ch, 2
3813
	jnz	disasm_readrmop16
3823
	jnz	disasm_readrmop16
3814
	push	ecx
3824
	push	ecx
3815
	movzx	ecx, al
3825
	movzx	ecx, al
3816
	and	eax, 7
3826
	and	eax, 7
3817
	shr	ecx, 6
3827
	shr	ecx, 6
3818
	jz	.vmod0
3828
	jz	.vmod0
3819
	jp	.vmod3
3829
	jp	.vmod3
3820
	mov	byte [edi], '['
3830
	mov	byte [edi], '['
3821
	inc	edi
3831
	inc	edi
3822
	cmp	al, 4
3832
	cmp	al, 4
3823
	jz	.sib1
3833
	jz	.sib1
3824
	mov	eax, [disasm_regs+eax*4]
3834
	mov	eax, [disasm_regs+eax*4]
3825
	stosd
3835
	stosd
3826
	dec	edi
3836
	dec	edi
3827
	jmp	@f
3837
	jmp	@f
3828
.sib1:
3838
.sib1:
3829
	call	.parse_sib
3839
	call	.parse_sib
3830
@@:
3840
@@:
3831
	mov	al, '+'
3841
	mov	al, '+'
3832
	stosb
3842
	stosb
3833
	dec	ecx
3843
	dec	ecx
3834
	jz	.vmod1
3844
	jz	.vmod1
3835
	call	disasm_get_dword
3845
	call	disasm_get_dword
3836
	jmp	@f
3846
	jmp	@f
3837
.vmod1:
3847
.vmod1:
3838
	call	disasm_get_byte
3848
	call	disasm_get_byte
3839
	movsx	eax, al
3849
	movsx	eax, al
3840
@@:
3850
@@:
3841
	test	eax, eax
3851
	test	eax, eax
3842
	jns	.2
3852
	jns	.2
3843
	neg	eax
3853
	neg	eax
3844
	mov	byte [edi-1], '-'
3854
	mov	byte [edi-1], '-'
3845
.2:
3855
.2:
3846
	call	disasm_write_num
3856
	call	disasm_write_num
3847
.2a:
3857
.2a:
3848
	mov	al, ']'
3858
	mov	al, ']'
3849
	stosb
3859
	stosb
3850
	pop	ecx
3860
	pop	ecx
3851
	ret
3861
	ret
3852
.vmod3:
3862
.vmod3:
3853
	pop	ecx
3863
	pop	ecx
3854
	test	ch, 10h
3864
	test	ch, 10h
3855
	jnz	.vmod3_mmi
3865
	jnz	.vmod3_mmi
3856
	test	ch, 80h
3866
	test	ch, 80h
3857
	jz	.vmod3_byte
3867
	jz	.vmod3_byte
3858
	test	ch, 1
3868
	test	ch, 1
3859
	jnz	.vmod3_word
3869
	jnz	.vmod3_word
3860
	test	ch, 20h
3870
	test	ch, 20h
3861
	jnz	.vmod3_sti
3871
	jnz	.vmod3_sti
3862
	mov	eax, [disasm_regs32+eax*4]
3872
	mov	eax, [disasm_regs32+eax*4]
3863
	stosd
3873
	stosd
3864
	dec	edi
3874
	dec	edi
3865
	ret
3875
	ret
3866
.vmod3_byte:
3876
.vmod3_byte:
3867
	mov	ax, [disasm_regs8+eax*2]
3877
	mov	ax, [disasm_regs8+eax*2]
3868
@@:
3878
@@:
3869
	stosw
3879
	stosw
3870
	ret
3880
	ret
3871
.vmod3_word:
3881
.vmod3_word:
3872
	mov	ax, [disasm_regs16+eax*2]
3882
	mov	ax, [disasm_regs16+eax*2]
3873
	jmp	@b
3883
	jmp	@b
3874
.vmod3_sti:
3884
.vmod3_sti:
3875
	mov	word [edi], 'st'
3885
	mov	word [edi], 'st'
3876
	add	al, '0'
3886
	add	al, '0'
3877
	mov	byte [edi+2], al
3887
	mov	byte [edi+2], al
3878
	add	edi, 3
3888
	add	edi, 3
3879
	ret
3889
	ret
3880
.vmod3_mmi:
3890
.vmod3_mmi:
3881
disasm_write_mmreg = $
3891
disasm_write_mmreg = $
3882
	test	ch, 1
3892
	test	ch, 1
3883
	jz	@f
3893
	jz	@f
3884
	mov	byte [edi], 'x'
3894
	mov	byte [edi], 'x'
3885
	inc	edi
3895
	inc	edi
3886
@@:
3896
@@:
3887
	mov	word [edi], 'mm'
3897
	mov	word [edi], 'mm'
3888
	add	al, '0'
3898
	add	al, '0'
3889
	mov	byte [edi+2], al
3899
	mov	byte [edi+2], al
3890
	add	edi, 3
3900
	add	edi, 3
3891
	ret
3901
	ret
3892
.vmod0:
3902
.vmod0:
3893
	mov	byte [edi], '['
3903
	mov	byte [edi], '['
3894
	inc	edi
3904
	inc	edi
3895
	cmp	al, 4
3905
	cmp	al, 4
3896
	jz	.sib2
3906
	jz	.sib2
3897
	cmp	al, 5
3907
	cmp	al, 5
3898
	jz	.ofs32
3908
	jz	.ofs32
3899
	mov	eax, [disasm_regs+eax*4]
3909
	mov	eax, [disasm_regs+eax*4]
3900
	stosd
3910
	stosd
3901
	mov	byte [edi-1], ']'
3911
	mov	byte [edi-1], ']'
3902
	pop	ecx
3912
	pop	ecx
3903
	ret
3913
	ret
3904
.ofs32:
3914
.ofs32:
3905
	call	disasm_get_dword
3915
	call	disasm_get_dword
3906
	jmp	.2
3916
	jmp	.2
3907
.sib2:
3917
.sib2:
3908
	call	.parse_sib
3918
	call	.parse_sib
3909
	mov	al, ']'
3919
	mov	al, ']'
3910
	stosb
3920
	stosb
3911
	pop	ecx
3921
	pop	ecx
3912
	ret
3922
	ret
3913
.parse_sib:
3923
.parse_sib:
3914
	call	disasm_get_byte
3924
	call	disasm_get_byte
3915
	push	edx
3925
	push	edx
3916
	mov	dl, al
3926
	mov	dl, al
3917
	mov	dh, 0
3927
	mov	dh, 0
3918
	and	eax, 7
3928
	and	eax, 7
3919
	cmp	al, 5
3929
	cmp	al, 5
3920
	jnz	@f
3930
	jnz	@f
3921
	jecxz	.sib0
3931
	jecxz	.sib0
3922
@@:
3932
@@:
3923
	mov	eax, [disasm_regs+eax*4]
3933
	mov	eax, [disasm_regs+eax*4]
3924
	stosd
3934
	stosd
3925
	dec	edi
3935
	dec	edi
3926
	mov	dh, 1
3936
	mov	dh, 1
3927
.sib0:
3937
.sib0:
3928
	mov	al, dl
3938
	mov	al, dl
3929
	shr	eax, 3
3939
	shr	eax, 3
3930
	and	eax, 7
3940
	and	eax, 7
3931
	cmp	al, 4
3941
	cmp	al, 4
3932
	jz	.sibret
3942
	jz	.sibret
3933
	test	dh, dh
3943
	test	dh, dh
3934
	jz	@f
3944
	jz	@f
3935
	mov	byte [edi], '+'
3945
	mov	byte [edi], '+'
3936
	inc	edi
3946
	inc	edi
3937
@@:
3947
@@:
3938
	mov	eax, [disasm_regs+eax*4]
3948
	mov	eax, [disasm_regs+eax*4]
3939
	stosd
3949
	stosd
3940
	dec	edi
3950
	dec	edi
3941
	shr	dl, 6
3951
	shr	dl, 6
3942
	jz	@f
3952
	jz	@f
3943
	mov	al, '*'
3953
	mov	al, '*'
3944
	stosb
3954
	stosb
3945
	movzx	eax, dl
3955
	movzx	eax, dl
3946
	mov	al, [disasm_scale+eax]
3956
	mov	al, [disasm_scale+eax]
3947
	stosb
3957
	stosb
3948
@@:
3958
@@:
3949
.sibret:
3959
.sibret:
3950
	test	dh, dh
3960
	test	dh, dh
3951
	jnz	.sibret2
3961
	jnz	.sibret2
3952
	call	disasm_get_dword
3962
	call	disasm_get_dword
3953
	cmp	byte [edi-1], '['
3963
	cmp	byte [edi-1], '['
3954
	jz	@f
3964
	jz	@f
3955
	mov	byte [edi], '+'
3965
	mov	byte [edi], '+'
3956
	test	eax, eax
3966
	test	eax, eax
3957
	jns	.sibns
3967
	jns	.sibns
3958
	neg	eax
3968
	neg	eax
3959
	mov	byte [edi], '-'
3969
	mov	byte [edi], '-'
3960
.sibns:
3970
.sibns:
3961
	inc	edi
3971
	inc	edi
3962
@@:
3972
@@:
3963
	call	disasm_write_num
3973
	call	disasm_write_num
3964
.sibret2:
3974
.sibret2:
3965
	pop	edx
3975
	pop	edx
3966
	ret
3976
	ret
3967
 
3977
 
3968
iglobal
3978
iglobal
3969
disasm_rm16_1	dd	'bxsi','bxdi','bpsi','bpdi'
3979
disasm_rm16_1	dd	'bxsi','bxdi','bpsi','bpdi'
3970
disasm_rm16_2	dw	'si','di','bp','bx'
3980
disasm_rm16_2	dw	'si','di','bp','bx'
3971
endg
3981
endg
3972
disasm_readrmop16:
3982
disasm_readrmop16:
3973
	push	ecx
3983
	push	ecx
3974
	movzx	ecx, al
3984
	movzx	ecx, al
3975
	and	eax, 7
3985
	and	eax, 7
3976
	shr	ecx, 6
3986
	shr	ecx, 6
3977
	jz	.vmod0
3987
	jz	.vmod0
3978
	jp	disasm_readrmop.vmod3	; mod=3 is the same in 16- and 32-bit code
3988
	jp	disasm_readrmop.vmod3	; mod=3 is the same in 16- and 32-bit code
3979
; 1 or 2
3989
; 1 or 2
3980
	mov	byte [edi], '['
3990
	mov	byte [edi], '['
3981
	inc	edi
3991
	inc	edi
3982
	cmp	al, 4
3992
	cmp	al, 4
3983
	jae	@f
3993
	jae	@f
3984
	mov	eax, [disasm_rm16_1+eax*4]
3994
	mov	eax, [disasm_rm16_1+eax*4]
3985
	stosw
3995
	stosw
3986
	mov	al, '+'
3996
	mov	al, '+'
3987
	stosb
3997
	stosb
3988
	shr	eax, 16
3998
	shr	eax, 16
3989
	jmp	.1
3999
	jmp	.1
3990
@@:
4000
@@:
3991
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
4001
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
3992
.1:
4002
.1:
3993
	stosw
4003
	stosw
3994
	mov	al, '+'
4004
	mov	al, '+'
3995
	stosb
4005
	stosb
3996
	xor	eax, eax
4006
	xor	eax, eax
3997
	dec	ecx
4007
	dec	ecx
3998
	jnz	.2
4008
	jnz	.2
3999
	call	disasm_get_byte
4009
	call	disasm_get_byte
4000
	cbw
4010
	cbw
4001
	jmp	@f
4011
	jmp	@f
4002
.2:
4012
.2:
4003
	call	disasm_get_word
4013
	call	disasm_get_word
4004
@@:
4014
@@:
4005
	test	ax, ax
4015
	test	ax, ax
4006
	jns	@f
4016
	jns	@f
4007
	mov	byte [edi-1], '-'
4017
	mov	byte [edi-1], '-'
4008
	neg	ax
4018
	neg	ax
4009
@@:
4019
@@:
4010
	call	disasm_write_num
4020
	call	disasm_write_num
4011
.done1:
4021
.done1:
4012
	mov	al, ']'
4022
	mov	al, ']'
4013
	stosb
4023
	stosb
4014
	pop	ecx
4024
	pop	ecx
4015
	ret
4025
	ret
4016
.vmod0:
4026
.vmod0:
4017
	mov	byte [edi], '['
4027
	mov	byte [edi], '['
4018
	inc	edi
4028
	inc	edi
4019
	cmp	al, 6
4029
	cmp	al, 6
4020
	jz	.ofs16
4030
	jz	.ofs16
4021
	cmp	al, 4
4031
	cmp	al, 4
4022
	jae	@f
4032
	jae	@f
4023
	mov	eax, [disasm_rm16_1+eax*4]
4033
	mov	eax, [disasm_rm16_1+eax*4]
4024
	stosw
4034
	stosw
4025
	mov	al, '+'
4035
	mov	al, '+'
4026
	stosb
4036
	stosb
4027
	shr	eax, 16
4037
	shr	eax, 16
4028
	jmp	.3
4038
	jmp	.3
4029
@@:
4039
@@:
4030
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
4040
	mov	eax, dword [disasm_rm16_2+eax*2-4*2]
4031
.3:
4041
.3:
4032
	stosw
4042
	stosw
4033
	jmp	.done1
4043
	jmp	.done1
4034
.ofs16:
4044
.ofs16:
4035
	xor	eax, eax
4045
	xor	eax, eax
4036
	call	disasm_get_word
4046
	call	disasm_get_word
4037
	call	disasm_write_num
4047
	call	disasm_write_num
4038
	jmp	.done1
4048
	jmp	.done1
4039
 
4049
 
4040
cpush21:
4050
cpush21:
4041
	mov	eax, 'push'
4051
	mov	eax, 'push'
4042
	stosd
4052
	stosd
4043
	mov	eax, '    '
4053
	mov	eax, '    '
4044
	stosd
4054
	stosd
4045
disasm_i32:
4055
disasm_i32:
4046
	call	disasm_get_dword
4056
	call	disasm_get_dword
4047
	call	disasm_write_num
4057
	call	disasm_write_num
4048
	and	byte [edi], 0
4058
	and	byte [edi], 0
4049
	ret
4059
	ret
4050
 
4060
 
4051
cpush22:
4061
cpush22:
4052
	mov	eax, 'push'
4062
	mov	eax, 'push'
4053
	stosd
4063
	stosd
4054
	mov	eax, '    '
4064
	mov	eax, '    '
4055
	stosd
4065
	stosd
4056
	call	disasm_get_byte
4066
	call	disasm_get_byte
4057
	movsx	eax, al
4067
	movsx	eax, al
4058
@@:
4068
@@:
4059
	call	disasm_write_num
4069
	call	disasm_write_num
4060
	and	byte [edi], 0
4070
	and	byte [edi], 0
4061
	ret
4071
	ret
4062
 
4072
 
4063
center:
4073
center:
4064
	mov	eax, 'ente'
4074
	mov	eax, 'ente'
4065
	stosd
4075
	stosd
4066
	mov	eax, 'r   '
4076
	mov	eax, 'r   '
4067
	stosd
4077
	stosd
4068
	xor	eax, eax
4078
	xor	eax, eax
4069
	call	disasm_get_word
4079
	call	disasm_get_word
4070
	call	disasm_write_num
4080
	call	disasm_write_num
4071
	mov	al, ','
4081
	mov	al, ','
4072
	stosb
4082
	stosb
4073
	mov	al, ' '
4083
	mov	al, ' '
4074
	stosb
4084
	stosb
4075
	xor	eax, eax
4085
	xor	eax, eax
4076
	call	disasm_get_byte
4086
	call	disasm_get_byte
4077
	jmp	@b
4087
	jmp	@b
4078
 
4088
 
4079
cinc1:
4089
cinc1:
4080
; inc reg32
4090
; inc reg32
4081
cdec1:
4091
cdec1:
4082
; dec reg32
4092
; dec reg32
4083
cpush1:
4093
cpush1:
4084
; push reg32
4094
; push reg32
4085
cpop1:
4095
cpop1:
4086
; pop reg32
4096
; pop reg32
4087
cbswap:
4097
cbswap:
4088
; bswap reg32
4098
; bswap reg32
4089
	mov	edx, eax
4099
	mov	edx, eax
4090
	and	edx, 7
4100
	and	edx, 7
4091
	shr	eax, 3
4101
	shr	eax, 3
4092
	sub	al, 8
4102
	sub	al, 8
4093
	mov	esi, 'inc '
4103
	mov	esi, 'inc '
4094
	jz	@f
4104
	jz	@f
4095
	mov	esi, 'dec '
4105
	mov	esi, 'dec '
4096
	dec	al
4106
	dec	al
4097
	jz	@f
4107
	jz	@f
4098
	mov	esi, 'push'
4108
	mov	esi, 'push'
4099
	dec	al
4109
	dec	al
4100
	jz	@f
4110
	jz	@f
4101
	mov	esi, 'pop '
4111
	mov	esi, 'pop '
4102
	dec	al
4112
	dec	al
4103
	jz	@f
4113
	jz	@f
4104
	mov	esi, 'bswa'
4114
	mov	esi, 'bswa'
4105
@@:
4115
@@:
4106
	xchg	eax, esi
4116
	xchg	eax, esi
4107
	stosd
4117
	stosd
4108
	mov	eax, '    '
4118
	mov	eax, '    '
4109
	jz	@f
4119
	jz	@f
4110
	mov	al, 'p'
4120
	mov	al, 'p'
4111
@@:
4121
@@:
4112
	stosd
4122
	stosd
4113
	xchg	eax, edx
4123
	xchg	eax, edx
4114
	call	disasm_write_reg1632
4124
	call	disasm_write_reg1632
4115
	and	byte [edi], 0
4125
	and	byte [edi], 0
4116
	ret
4126
	ret
4117
 
4127
 
4118
cxchg1:
4128
cxchg1:
4119
; xchg eax,reg32
4129
; xchg eax,reg32
4120
	and	eax, 7
4130
	and	eax, 7
4121
	xchg	eax, edx
4131
	xchg	eax, edx
4122
	mov	eax, 'xchg'
4132
	mov	eax, 'xchg'
4123
	stosd
4133
	stosd
4124
	mov	eax, '    '
4134
	mov	eax, '    '
4125
	stosd
4135
	stosd
4126
	xor	eax, eax
4136
	xor	eax, eax
4127
	call	disasm_write_reg1632
4137
	call	disasm_write_reg1632
4128
	mov	ax, ', '
4138
	mov	ax, ', '
4129
	stosw
4139
	stosw
4130
	xchg	eax, edx
4140
	xchg	eax, edx
4131
	call	disasm_write_reg1632
4141
	call	disasm_write_reg1632
4132
	and	byte [edi], 0
4142
	and	byte [edi], 0
4133
	ret
4143
	ret
4134
 
4144
 
4135
cint:
4145
cint:
4136
	mov	eax, 'int '
4146
	mov	eax, 'int '
4137
	stosd
4147
	stosd
4138
	mov	eax, '    '
4148
	mov	eax, '    '
4139
	stosd
4149
	stosd
4140
disasm_i8u:
4150
disasm_i8u:
4141
	xor	eax, eax
4151
	xor	eax, eax
4142
	call	disasm_get_byte
4152
	call	disasm_get_byte
4143
	call	disasm_write_num
4153
	call	disasm_write_num
4144
	and	byte [edi], 0
4154
	and	byte [edi], 0
4145
	ret
4155
	ret
4146
 
4156
 
4147
cmov11:
4157
cmov11:
4148
; mov r8,i8
4158
; mov r8,i8
4149
	mov	ecx, eax
4159
	mov	ecx, eax
4150
	mov	eax, 'mov '
4160
	mov	eax, 'mov '
4151
	stosd
4161
	stosd
4152
	mov	eax, '    '
4162
	mov	eax, '    '
4153
	stosd
4163
	stosd
4154
	and	ecx, 7
4164
	and	ecx, 7
4155
	mov	ax, [disasm_regs8+ecx*2]
4165
	mov	ax, [disasm_regs8+ecx*2]
4156
	stosw
4166
	stosw
4157
	mov	ax, ', '
4167
	mov	ax, ', '
4158
	stosw
4168
	stosw
4159
	jmp	disasm_i8u
4169
	jmp	disasm_i8u
4160
 
4170
 
4161
cmov12:
4171
cmov12:
4162
; mov r32,i32
4172
; mov r32,i32
4163
	xchg	eax, edx
4173
	xchg	eax, edx
4164
	mov	eax, 'mov '
4174
	mov	eax, 'mov '
4165
	stosd
4175
	stosd
4166
	mov	eax, '    '
4176
	mov	eax, '    '
4167
	stosd
4177
	stosd
4168
	xchg	eax, edx
4178
	xchg	eax, edx
4169
	and	eax, 7
4179
	and	eax, 7
4170
	call	disasm_write_reg1632
4180
	call	disasm_write_reg1632
4171
	mov	ax, ', '
4181
	mov	ax, ', '
4172
	stosw
4182
	stosw
4173
	jmp	cmov2.1
4183
	jmp	cmov2.1
4174
 
4184
 
4175
iglobal
4185
iglobal
4176
disasm_shifts	dd	'rol ','ror ','rcl ','rcr ','shl ','shr ','sal ','sar '
4186
disasm_shifts	dd	'rol ','ror ','rcl ','rcr ','shl ','shr ','sal ','sar '
4177
endg
4187
endg
4178
cshift2:
4188
cshift2:
4179
; shift r/m,1 = D0/D1
4189
; shift r/m,1 = D0/D1
4180
cshift3:
4190
cshift3:
4181
; shift r/m,cl = D2/D3
4191
; shift r/m,cl = D2/D3
4182
	disasm_set_modew
4192
	disasm_set_modew
4183
	mov	dl, al
4193
	mov	dl, al
4184
	call	disasm_get_byte
4194
	call	disasm_get_byte
4185
	dec	[disasm_cur_pos]
4195
	dec	[disasm_cur_pos]
4186
	shr	al, 3
4196
	shr	al, 3
4187
	and	eax, 7
4197
	and	eax, 7
4188
	mov	eax, [disasm_shifts+eax*4]
4198
	mov	eax, [disasm_shifts+eax*4]
4189
	stosd
4199
	stosd
4190
	mov	eax, '    '
4200
	mov	eax, '    '
4191
	stosd
4201
	stosd
4192
	call	disasm_readrmop
4202
	call	disasm_readrmop
4193
	cmp	dl, 0xD2
4203
	cmp	dl, 0xD2
4194
	jb	.s1
4204
	jb	.s1
4195
	mov	eax, ', cl'
4205
	mov	eax, ', cl'
4196
	stosd
4206
	stosd
4197
	and	byte [edi], 0
4207
	and	byte [edi], 0
4198
	ret
4208
	ret
4199
.s1:
4209
.s1:
4200
	mov	eax, ', 1'
4210
	mov	eax, ', 1'
4201
	stosd
4211
	stosd
4202
	clc
4212
	clc
4203
	ret
4213
	ret
4204
 
4214
 
4205
cshift1:
4215
cshift1:
4206
; shift r/m,i8 = C0/C1
4216
; shift r/m,i8 = C0/C1
4207
	disasm_set_modew
4217
	disasm_set_modew
4208
	call	disasm_get_byte
4218
	call	disasm_get_byte
4209
	dec	[disasm_cur_pos]
4219
	dec	[disasm_cur_pos]
4210
	shr	al, 3
4220
	shr	al, 3
4211
	and	eax, 7
4221
	and	eax, 7
4212
	mov	eax, [disasm_shifts+eax*4]
4222
	mov	eax, [disasm_shifts+eax*4]
4213
	stosd
4223
	stosd
4214
	mov	eax, '    '
4224
	mov	eax, '    '
4215
	stosd
4225
	stosd
4216
	call	disasm_readrmop
4226
	call	disasm_readrmop
4217
	mov	ax, ', '
4227
	mov	ax, ', '
4218
	stosw
4228
	stosw
4219
	jmp	disasm_i8u
4229
	jmp	disasm_i8u
4220
 
4230
 
4221
caam:
4231
caam:
4222
	mov	eax, 'aam '
4232
	mov	eax, 'aam '
4223
	jmp	@f
4233
	jmp	@f
4224
caad:
4234
caad:
4225
	mov	eax, 'aad '
4235
	mov	eax, 'aad '
4226
@@:
4236
@@:
4227
	stosd
4237
	stosd
4228
	mov	eax, '    '
4238
	mov	eax, '    '
4229
	stosd
4239
	stosd
4230
	xor	eax, eax
4240
	xor	eax, eax
4231
	call	disasm_get_byte
4241
	call	disasm_get_byte
4232
	cmp	al, 10
4242
	cmp	al, 10
4233
	jz	@f
4243
	jz	@f
4234
	call	disasm_write_num
4244
	call	disasm_write_num
4235
@@:
4245
@@:
4236
	and	byte [edi], 0
4246
	and	byte [edi], 0
4237
	ret
4247
	ret
4238
 
4248
 
4239
cmov3:
4249
cmov3:
4240
; A0: mov al,[ofs32]
4250
; A0: mov al,[ofs32]
4241
; A1: mov ax/eax,[ofs32]
4251
; A1: mov ax/eax,[ofs32]
4242
; A2: mov [ofs32],al
4252
; A2: mov [ofs32],al
4243
; A3: mov [ofs32],ax/eax
4253
; A3: mov [ofs32],ax/eax
4244
	mov	edx, 'mov '
4254
	mov	edx, 'mov '
4245
	xchg	eax, edx
4255
	xchg	eax, edx
4246
	stosd
4256
	stosd
4247
	mov	eax, '    '
4257
	mov	eax, '    '
4248
	stosd
4258
	stosd
4249
	test	dl, 2
4259
	test	dl, 2
4250
	jnz	.1
4260
	jnz	.1
4251
	call	.write_acc
4261
	call	.write_acc
4252
	mov	ax, ', '
4262
	mov	ax, ', '
4253
	stosw
4263
	stosw
4254
	call	.write_ofs32
4264
	call	.write_ofs32
4255
	jmp	.2
4265
	jmp	.2
4256
.1:
4266
.1:
4257
	call	.write_ofs32
4267
	call	.write_ofs32
4258
	mov	ax, ', '
4268
	mov	ax, ', '
4259
	stosw
4269
	stosw
4260
	call	.write_acc
4270
	call	.write_acc
4261
.2:	and	byte [edi], 0
4271
.2:	and	byte [edi], 0
4262
	ret
4272
	ret
4263
.write_acc:
4273
.write_acc:
4264
	test	dl, 1
4274
	test	dl, 1
4265
	jz	.8bit
4275
	jz	.8bit
4266
	test	ch, 1
4276
	test	ch, 1
4267
	jnz	.16bit
4277
	jnz	.16bit
4268
	mov	eax, 'eax'
4278
	mov	eax, 'eax'
4269
	stosd
4279
	stosd
4270
	dec	edi
4280
	dec	edi
4271
	ret
4281
	ret
4272
.16bit:
4282
.16bit:
4273
	mov	ax, 'ax'
4283
	mov	ax, 'ax'
4274
	stosw
4284
	stosw
4275
	ret
4285
	ret
4276
.8bit:
4286
.8bit:
4277
	mov	ax, 'al'
4287
	mov	ax, 'al'
4278
	stosw
4288
	stosw
4279
	ret
4289
	ret
4280
.write_ofs32:
4290
.write_ofs32:
4281
	mov	al, '['
4291
	mov	al, '['
4282
	stosb
4292
	stosb
4283
	call	disasm_get_dword
4293
	call	disasm_get_dword
4284
	call	disasm_write_num
4294
	call	disasm_write_num
4285
	mov	al, ']'
4295
	mov	al, ']'
4286
	stosb
4296
	stosb
4287
	ret
4297
	ret
4288
 
4298
 
4289
disasm_write_reg:
4299
disasm_write_reg:
4290
	test	ch, 80h
4300
	test	ch, 80h
4291
	jnz	disasm_write_reg1632
4301
	jnz	disasm_write_reg1632
4292
	mov	ax, [disasm_regs8+eax*2]
4302
	mov	ax, [disasm_regs8+eax*2]
4293
	stosw
4303
	stosw
4294
	ret
4304
	ret
4295
disasm_write_reg1632:
4305
disasm_write_reg1632:
4296
	test	ch, 1
4306
	test	ch, 1
4297
	jnz	@f
4307
	jnz	@f
4298
	mov	eax, [disasm_regs32+eax*4]
4308
	mov	eax, [disasm_regs32+eax*4]
4299
	stosd
4309
	stosd
4300
	dec	edi
4310
	dec	edi
4301
	ret
4311
	ret
4302
@@:
4312
@@:
4303
	mov	ax, [disasm_regs16+eax*2]
4313
	mov	ax, [disasm_regs16+eax*2]
4304
	stosw
4314
	stosw
4305
	ret
4315
	ret
4306
 
4316
 
4307
cmovzx:		; 0F B6/B7
4317
cmovzx:		; 0F B6/B7
4308
cmovsx:		; 0F BE/BF
4318
cmovsx:		; 0F BE/BF
4309
	mov	edx, eax
4319
	mov	edx, eax
4310
	disasm_set_modew
4320
	disasm_set_modew
4311
	mov	eax, 'movz'
4321
	mov	eax, 'movz'
4312
	cmp	dl, 0xB8
4322
	cmp	dl, 0xB8
4313
	jb	@f
4323
	jb	@f
4314
	mov	eax, 'movs'
4324
	mov	eax, 'movs'
4315
@@:
4325
@@:
4316
	stosd
4326
	stosd
4317
	mov	eax, 'x   '
4327
	mov	eax, 'x   '
4318
	stosd
4328
	stosd
4319
	call	disasm_get_byte
4329
	call	disasm_get_byte
4320
	dec	[disasm_cur_pos]
4330
	dec	[disasm_cur_pos]
4321
	shr	al, 3
4331
	shr	al, 3
4322
	and	eax, 7
4332
	and	eax, 7
4323
	call	disasm_write_reg1632
4333
	call	disasm_write_reg1632
4324
	mov	ax, ', '
4334
	mov	ax, ', '
4325
	stosw
4335
	stosw
4326
	or	ch, 1	; 2nd operand - 8 or 16 bits
4336
	or	ch, 1	; 2nd operand - 8 or 16 bits
4327
	call	disasm_readrmop
4337
	call	disasm_readrmop
4328
	and	byte [edi], 0
4338
	and	byte [edi], 0
4329
	ret
4339
	ret
4330
 
4340
 
4331
iglobal
4341
iglobal
4332
disasm_op2cmds	dd 'add ','or  ','adc ','sbb ','and ','sub ','xor ','cmp '
4342
disasm_op2cmds	dd 'add ','or  ','adc ','sbb ','and ','sub ','xor ','cmp '
4333
endg
4343
endg
4334
cop21:
4344
cop21:
4335
	disasm_set_modew
4345
	disasm_set_modew
4336
	mov	esi, 'test'
4346
	mov	esi, 'test'
4337
	cmp	al, 0A8h
4347
	cmp	al, 0A8h
4338
	jae	@f
4348
	jae	@f
4339
	shr	al, 3
4349
	shr	al, 3
4340
	and	eax, 7
4350
	and	eax, 7
4341
	mov	esi, [disasm_op2cmds+eax*4]
4351
	mov	esi, [disasm_op2cmds+eax*4]
4342
@@:
4352
@@:
4343
	xchg	eax, esi
4353
	xchg	eax, esi
4344
	stosd
4354
	stosd
4345
	mov	eax, '    '
4355
	mov	eax, '    '
4346
	stosd
4356
	stosd
4347
	test	ch, 80h
4357
	test	ch, 80h
4348
	jnz	.1632
4358
	jnz	.1632
4349
	mov	eax, 'al, '
4359
	mov	eax, 'al, '
4350
	stosd
4360
	stosd
4351
	jmp	disasm_i8u
4361
	jmp	disasm_i8u
4352
.1632:
4362
.1632:
4353
	test	ch, 1
4363
	test	ch, 1
4354
	jnz	.16
4364
	jnz	.16
4355
	mov	eax, 'eax,'
4365
	mov	eax, 'eax,'
4356
	stosd
4366
	stosd
4357
	mov	al, ' '
4367
	mov	al, ' '
4358
	stosb
4368
	stosb
4359
	call	disasm_get_dword
4369
	call	disasm_get_dword
4360
	jmp	.x
4370
	jmp	.x
4361
.16:
4371
.16:
4362
	mov	eax, 'ax, '
4372
	mov	eax, 'ax, '
4363
	stosd
4373
	stosd
4364
	xor	eax, eax
4374
	xor	eax, eax
4365
	call	disasm_get_word
4375
	call	disasm_get_word
4366
.x:
4376
.x:
4367
	call	disasm_write_num
4377
	call	disasm_write_num
4368
	and	byte [edi], 0
4378
	and	byte [edi], 0
4369
	ret
4379
	ret
4370
 
4380
 
4371
carpl:
4381
carpl:
4372
	xor	edx, edx
4382
	xor	edx, edx
4373
	or	ch, 0C1h
4383
	or	ch, 0C1h
4374
	mov	eax, 'arpl'
4384
	mov	eax, 'arpl'
4375
	jmp	cop22.d2
4385
	jmp	cop22.d2
4376
 
4386
 
4377
ccmpxchg:
4387
ccmpxchg:
4378
	xor	edx, edx
4388
	xor	edx, edx
4379
	disasm_set_modew
4389
	disasm_set_modew
4380
	or	ch, 40h
4390
	or	ch, 40h
4381
	mov	eax, 'cmpx'
4391
	mov	eax, 'cmpx'
4382
	stosd
4392
	stosd
4383
	mov	eax, 'chg '
4393
	mov	eax, 'chg '
4384
	jmp	cop22.d1
4394
	jmp	cop22.d1
4385
 
4395
 
4386
cbsf:
4396
cbsf:
4387
cbsr:
4397
cbsr:
4388
	or	ch, 80h
4398
	or	ch, 80h
4389
 
4399
 
4390
cop22:
4400
cop22:
4391
	disasm_set_modew
4401
	disasm_set_modew
4392
	or	ch, 40h
4402
	or	ch, 40h
4393
	mov	edx, eax
4403
	mov	edx, eax
4394
	mov	esi, 'lea '
4404
	mov	esi, 'lea '
4395
	cmp	al, 8Dh
4405
	cmp	al, 8Dh
4396
	jz	@f
4406
	jz	@f
4397
	mov	esi, 'imul'
4407
	mov	esi, 'imul'
4398
	cmp	al, 0xAF
4408
	cmp	al, 0xAF
4399
	jz	@f
4409
	jz	@f
4400
	mov	esi, 'bsf '
4410
	mov	esi, 'bsf '
4401
	cmp	al, 0BCh
4411
	cmp	al, 0BCh
4402
	jz	@f
4412
	jz	@f
4403
	mov	esi, 'bsr '
4413
	mov	esi, 'bsr '
4404
	cmp	al, 0BDh
4414
	cmp	al, 0BDh
4405
	jz	@f
4415
	jz	@f
4406
	mov	esi, 'mov '
4416
	mov	esi, 'mov '
4407
	cmp	al, 88h
4417
	cmp	al, 88h
4408
	jae	@f
4418
	jae	@f
4409
	mov	esi, 'xchg'
4419
	mov	esi, 'xchg'
4410
	cmp	al, 86h
4420
	cmp	al, 86h
4411
	jae	@f
4421
	jae	@f
4412
	mov	esi, 'test'
4422
	mov	esi, 'test'
4413
	cmp	al, 84h
4423
	cmp	al, 84h
4414
	jae	@f
4424
	jae	@f
4415
	shr	al, 3
4425
	shr	al, 3
4416
	and	eax, 7
4426
	and	eax, 7
4417
	mov	esi, [disasm_op2cmds+eax*4]
4427
	mov	esi, [disasm_op2cmds+eax*4]
4418
@@:
4428
@@:
4419
	xchg	eax, esi
4429
	xchg	eax, esi
4420
.d2:
4430
.d2:
4421
	stosd
4431
	stosd
4422
	mov	eax, '    '
4432
	mov	eax, '    '
4423
.d1:
4433
.d1:
4424
	stosd
4434
	stosd
4425
	call	disasm_get_byte
4435
	call	disasm_get_byte
4426
	dec	[disasm_cur_pos]
4436
	dec	[disasm_cur_pos]
4427
	shr	al, 3
4437
	shr	al, 3
4428
	and	eax, 7
4438
	and	eax, 7
4429
	cmp	dl, 0x8D
4439
	cmp	dl, 0x8D
4430
	jz	@f
4440
	jz	@f
4431
	cmp	dl, 0x86
4441
	cmp	dl, 0x86
4432
	jz	@f
4442
	jz	@f
4433
	cmp	dl, 0x87
4443
	cmp	dl, 0x87
4434
	jz	@f
4444
	jz	@f
4435
	cmp	dl, 0xBC
4445
	cmp	dl, 0xBC
4436
	jz	@f
4446
	jz	@f
4437
	cmp	dl, 0xBD
4447
	cmp	dl, 0xBD
4438
	jz	@f
4448
	jz	@f
4439
	test	dl, 2
4449
	test	dl, 2
4440
	jz	.d0
4450
	jz	.d0
4441
@@:
4451
@@:
4442
	call	disasm_write_reg
4452
	call	disasm_write_reg
4443
	mov	ax, ', '
4453
	mov	ax, ', '
4444
	stosw
4454
	stosw
4445
	call	disasm_readrmop
4455
	call	disasm_readrmop
4446
	and	byte [edi], 0
4456
	and	byte [edi], 0
4447
	ret
4457
	ret
4448
.d0:
4458
.d0:
4449
	push	eax
4459
	push	eax
4450
	call	disasm_readrmop
4460
	call	disasm_readrmop
4451
	mov	ax, ', '
4461
	mov	ax, ', '
4452
	stosw
4462
	stosw
4453
	pop	eax
4463
	pop	eax
4454
	call	disasm_write_reg
4464
	call	disasm_write_reg
4455
	and	byte [edi], 0
4465
	and	byte [edi], 0
4456
	ret
4466
	ret
4457
 
4467
 
4458
cbound:
4468
cbound:
4459
	mov	edx, eax
4469
	mov	edx, eax
4460
	mov	eax, 'boun'
4470
	mov	eax, 'boun'
4461
	stosd
4471
	stosd
4462
	mov	eax, 'd   '
4472
	mov	eax, 'd   '
4463
	or	ch, 0xC0
4473
	or	ch, 0xC0
4464
	jmp	cop22.d1
4474
	jmp	cop22.d1
4465
 
4475
 
4466
cop23:
4476
cop23:
4467
	disasm_set_modew
4477
	disasm_set_modew
4468
	xchg	eax, edx
4478
	xchg	eax, edx
4469
	call	disasm_get_byte
4479
	call	disasm_get_byte
4470
	dec	[disasm_cur_pos]
4480
	dec	[disasm_cur_pos]
4471
	shr	eax, 3
4481
	shr	eax, 3
4472
	and	eax, 7
4482
	and	eax, 7
4473
	mov	eax, [disasm_op2cmds+eax*4]
4483
	mov	eax, [disasm_op2cmds+eax*4]
4474
ctest:
4484
ctest:
4475
	stosd
4485
	stosd
4476
	mov	eax, '    '
4486
	mov	eax, '    '
4477
	stosd
4487
	stosd
4478
	call	disasm_readrmop
4488
	call	disasm_readrmop
4479
	mov	ax, ', '
4489
	mov	ax, ', '
4480
	stosw
4490
	stosw
4481
	test	ch, 80h
4491
	test	ch, 80h
4482
	jz	.i8
4492
	jz	.i8
4483
	cmp	dl, 83h
4493
	cmp	dl, 83h
4484
	jz	.i8
4494
	jz	.i8
4485
	test	ch, 1
4495
	test	ch, 1
4486
	jnz	.i16
4496
	jnz	.i16
4487
	call	disasm_get_dword
4497
	call	disasm_get_dword
4488
	jmp	.ic
4498
	jmp	.ic
4489
.i8:
4499
.i8:
4490
	xor	eax, eax
4500
	xor	eax, eax
4491
	call	disasm_get_byte
4501
	call	disasm_get_byte
4492
	cmp	dl, 83h
4502
	cmp	dl, 83h
4493
	jnz	.ic
4503
	jnz	.ic
4494
	movsx	eax, al
4504
	movsx	eax, al
4495
	jmp	.ic
4505
	jmp	.ic
4496
.i16:
4506
.i16:
4497
	xor	eax, eax
4507
	xor	eax, eax
4498
	call	disasm_get_word
4508
	call	disasm_get_word
4499
.ic:
4509
.ic:
4500
	call	disasm_write_num
4510
	call	disasm_write_num
4501
	and	byte [edi], 0
4511
	and	byte [edi], 0
4502
	ret
4512
	ret
4503
 
4513
 
4504
cmovcc:
4514
cmovcc:
4505
	or	ch, 0C0h
4515
	or	ch, 0C0h
4506
	and	eax, 0xF
4516
	and	eax, 0xF
4507
	mov	ax, [disasm_jcc_codes + eax*2]
4517
	mov	ax, [disasm_jcc_codes + eax*2]
4508
	mov	dword [edi], 'cmov'
4518
	mov	dword [edi], 'cmov'
4509
	add	edi, 4
4519
	add	edi, 4
4510
	stosw
4520
	stosw
4511
	mov	ax, '  '
4521
	mov	ax, '  '
4512
	stosw
4522
	stosw
4513
	call	disasm_get_byte
4523
	call	disasm_get_byte
4514
	dec	[disasm_cur_pos]
4524
	dec	[disasm_cur_pos]
4515
	shr	eax, 3
4525
	shr	eax, 3
4516
	and	eax, 7
4526
	and	eax, 7
4517
	call	disasm_write_reg1632
4527
	call	disasm_write_reg1632
4518
	mov	ax, ', '
4528
	mov	ax, ', '
4519
	stosw
4529
	stosw
4520
	call	disasm_readrmop
4530
	call	disasm_readrmop
4521
	and	byte [edi], 0
4531
	and	byte [edi], 0
4522
	ret
4532
	ret
4523
 
4533
 
4524
cbtx1:
4534
cbtx1:
4525
; btx r/m,i8 = 0F BA
4535
; btx r/m,i8 = 0F BA
4526
	or	ch, 80h
4536
	or	ch, 80h
4527
	call	disasm_get_byte
4537
	call	disasm_get_byte
4528
	dec	[disasm_cur_pos]
4538
	dec	[disasm_cur_pos]
4529
	shr	al, 3
4539
	shr	al, 3
4530
	and	eax, 7
4540
	and	eax, 7
4531
	cmp	al, 4
4541
	cmp	al, 4
4532
	jb	cunk
4542
	jb	cunk
4533
	mov	eax, [btx1codes+eax*4-4*4]
4543
	mov	eax, [btx1codes+eax*4-4*4]
4534
	stosd
4544
	stosd
4535
	mov	eax, '    '
4545
	mov	eax, '    '
4536
	stosd
4546
	stosd
4537
	call	disasm_readrmop
4547
	call	disasm_readrmop
4538
	mov	ax, ', '
4548
	mov	ax, ', '
4539
	stosw
4549
	stosw
4540
	jmp	disasm_i8u
4550
	jmp	disasm_i8u
4541
iglobal
4551
iglobal
4542
btx1codes	dd	'bt  ','bts ','btr ','btc '
4552
btx1codes	dd	'bt  ','bts ','btr ','btc '
4543
endg
4553
endg
4544
cbtx2:
4554
cbtx2:
4545
; btx r/m,r = 0F 101xx011 (A3,AB,B3,BB)
4555
; btx r/m,r = 0F 101xx011 (A3,AB,B3,BB)
4546
	shr	al, 3
4556
	shr	al, 3
4547
	and	eax, 3
4557
	and	eax, 3
4548
	mov	eax, [btx1codes+eax*4]
4558
	mov	eax, [btx1codes+eax*4]
4549
	stosd
4559
	stosd
4550
	mov	eax, '    '
4560
	mov	eax, '    '
4551
	stosd
4561
	stosd
4552
	or	ch, 0xC0
4562
	or	ch, 0xC0
4553
	call	disasm_get_byte
4563
	call	disasm_get_byte
4554
	dec	[disasm_cur_pos]
4564
	dec	[disasm_cur_pos]
4555
	shr	al, 3
4565
	shr	al, 3
4556
	and	eax, 7
4566
	and	eax, 7
4557
	push	eax
4567
	push	eax
4558
	call	disasm_readrmop
4568
	call	disasm_readrmop
4559
	mov	ax, ', '
4569
	mov	ax, ', '
4560
	stosw
4570
	stosw
4561
	pop	eax
4571
	pop	eax
4562
	call	disasm_write_reg1632
4572
	call	disasm_write_reg1632
4563
	and	byte [edi], 0
4573
	and	byte [edi], 0
4564
	ret
4574
	ret
4565
 
4575
 
4566
csetcc:
4576
csetcc:
4567
	and	eax, 0xF
4577
	and	eax, 0xF
4568
	mov	ax, [disasm_jcc_codes + eax*2]
4578
	mov	ax, [disasm_jcc_codes + eax*2]
4569
	mov	dword [edi], 'setc'
4579
	mov	dword [edi], 'setc'
4570
	add	edi, 3
4580
	add	edi, 3
4571
	stosw
4581
	stosw
4572
	mov	ax, '  '
4582
	mov	ax, '  '
4573
	stosw
4583
	stosw
4574
	stosb
4584
	stosb
4575
	call	disasm_readrmop
4585
	call	disasm_readrmop
4576
	and	byte [edi], 0
4586
	and	byte [edi], 0
4577
	ret
4587
	ret
4578
 
4588
 
4579
iglobal
4589
iglobal
4580
disasm_jcc_codes dw 'o ','no','b ','ae','z ','nz','be','a ','s ','ns','p ','np','l ','ge','le','g '
4590
disasm_jcc_codes dw 'o ','no','b ','ae','z ','nz','be','a ','s ','ns','p ','np','l ','ge','le','g '
4581
endg
4591
endg
4582
cjcc1:
4592
cjcc1:
4583
cjmp2:
4593
cjmp2:
4584
	cmp	al, 0xEB
4594
	cmp	al, 0xEB
4585
	jz	.1
4595
	jz	.1
4586
	and	eax, 0xF
4596
	and	eax, 0xF
4587
	mov	ax, [disasm_jcc_codes + eax*2]
4597
	mov	ax, [disasm_jcc_codes + eax*2]
4588
	jmp	.2
4598
	jmp	.2
4589
.1:
4599
.1:
4590
	mov	ax, 'mp'
4600
	mov	ax, 'mp'
4591
.2:
4601
.2:
4592
	mov	byte [edi], 'j'
4602
	mov	byte [edi], 'j'
4593
	inc	edi
4603
	inc	edi
4594
	stosw
4604
	stosw
4595
	mov	eax, '    '
4605
	mov	eax, '    '
4596
	stosb
4606
	stosb
4597
	stosd
4607
	stosd
4598
	call	disasm_get_byte
4608
	call	disasm_get_byte
4599
	movsx	eax, al
4609
	movsx	eax, al
4600
disasm_rva:
4610
disasm_rva:
4601
	add	eax, [disasm_cur_pos]
4611
	add	eax, [disasm_cur_pos]
4602
	call	disasm_write_num
4612
	call	disasm_write_num
4603
	and	byte [edi], 0
4613
	and	byte [edi], 0
4604
	ret
4614
	ret
4605
 
4615
 
4606
ccall1:
4616
ccall1:
4607
cjmp1:
4617
cjmp1:
4608
cjcc2:
4618
cjcc2:
4609
	mov	edx, 'call'
4619
	mov	edx, 'call'
4610
	cmp	al, 0xE8
4620
	cmp	al, 0xE8
4611
	jz	@f
4621
	jz	@f
4612
	mov	edx, 'jmp '
4622
	mov	edx, 'jmp '
4613
	cmp	al, 0xE9
4623
	cmp	al, 0xE9
4614
	jz	@f
4624
	jz	@f
4615
	mov	edx, '    '
4625
	mov	edx, '    '
4616
	and	eax, 0xF
4626
	and	eax, 0xF
4617
	mov	dx, [disasm_jcc_codes+eax*2]
4627
	mov	dx, [disasm_jcc_codes+eax*2]
4618
	shl	edx, 8
4628
	shl	edx, 8
4619
	mov	dl, 'j'
4629
	mov	dl, 'j'
4620
@@:
4630
@@:
4621
	xchg	eax, edx
4631
	xchg	eax, edx
4622
	stosd
4632
	stosd
4623
	mov	eax, '    '
4633
	mov	eax, '    '
4624
	stosd
4634
	stosd
4625
	test	ch, 1
4635
	test	ch, 1
4626
	jnz	@f
4636
	jnz	@f
4627
	call	disasm_get_dword
4637
	call	disasm_get_dword
4628
	jmp	disasm_rva
4638
	jmp	disasm_rva
4629
@@:
4639
@@:
4630
	call	disasm_get_word
4640
	call	disasm_get_word
4631
	add	eax, [disasm_cur_pos]
4641
	add	eax, [disasm_cur_pos]
4632
	and	eax, 0xFFFF
4642
	and	eax, 0xFFFF
4633
	call	disasm_write_num
4643
	call	disasm_write_num
4634
	and	byte [edi], 0
4644
	and	byte [edi], 0
4635
	ret
4645
	ret
4636
 
4646
 
4637
ccallf:
4647
ccallf:
4638
	mov	eax, 'call'
4648
	mov	eax, 'call'
4639
	stosd
4649
	stosd
4640
	mov	eax, '    '
4650
	mov	eax, '    '
4641
	stosd
4651
	stosd
4642
	mov	al, 'd'
4652
	mov	al, 'd'
4643
	test	ch, 1
4653
	test	ch, 1
4644
	jnz	@f
4654
	jnz	@f
4645
	mov	al, 'p'
4655
	mov	al, 'p'
4646
@@:
4656
@@:
4647
	stosb
4657
	stosb
4648
	mov	eax, 'word'
4658
	mov	eax, 'word'
4649
	stosd
4659
	stosd
4650
	mov	al, ' '
4660
	mov	al, ' '
4651
	stosb
4661
	stosb
4652
	test	ch, 1
4662
	test	ch, 1
4653
	jnz	.1
4663
	jnz	.1
4654
	call	disasm_get_dword
4664
	call	disasm_get_dword
4655
	jmp	.2
4665
	jmp	.2
4656
.1:
4666
.1:
4657
	xor	eax, eax
4667
	xor	eax, eax
4658
	call	disasm_get_word
4668
	call	disasm_get_word
4659
.2:
4669
.2:
4660
	push	eax
4670
	push	eax
4661
	xor	eax, eax
4671
	xor	eax, eax
4662
	call	disasm_get_word
4672
	call	disasm_get_word
4663
	call	disasm_write_num
4673
	call	disasm_write_num
4664
	mov	al, ':'
4674
	mov	al, ':'
4665
	stosb
4675
	stosb
4666
	pop	eax
4676
	pop	eax
4667
	call	disasm_write_num
4677
	call	disasm_write_num
4668
	and	byte [edi], 0
4678
	and	byte [edi], 0
4669
	ret
4679
	ret
4670
 
4680
 
4671
iglobal
4681
iglobal
4672
op11codes	dd	'test',0,'not ','neg ','mul ','imul','div ','idiv'
4682
op11codes	dd	'test',0,'not ','neg ','mul ','imul','div ','idiv'
4673
op12codes	dd	'inc ','dec ','call',0,'jmp ',0,'push',0
4683
op12codes	dd	'inc ','dec ','call',0,'jmp ',0,'push',0
4674
endg
4684
endg
4675
cop1:
4685
cop1:
4676
	disasm_set_modew
4686
	disasm_set_modew
4677
	xchg	eax, edx
4687
	xchg	eax, edx
4678
	call	disasm_get_byte
4688
	call	disasm_get_byte
4679
	movzx	esi, al
4689
	movzx	esi, al
4680
	dec	[disasm_cur_pos]
4690
	dec	[disasm_cur_pos]
4681
	shr	al, 3
4691
	shr	al, 3
4682
	and	eax, 7
4692
	and	eax, 7
4683
	cmp	dl, 0xFE
4693
	cmp	dl, 0xFE
4684
	jnz	@f
4694
	jnz	@f
4685
	cmp	al, 1
4695
	cmp	al, 1
4686
	jbe	@f
4696
	jbe	@f
4687
.0:
4697
.0:
4688
	inc	[disasm_cur_pos]
4698
	inc	[disasm_cur_pos]
4689
	jmp	cunk
4699
	jmp	cunk
4690
@@:
4700
@@:
4691
	and	edx, 8
4701
	and	edx, 8
4692
	add	eax, edx
4702
	add	eax, edx
4693
	cmp	al, 11
4703
	cmp	al, 11
4694
	jz	.callfar
4704
	jz	.callfar
4695
	cmp	al, 13
4705
	cmp	al, 13
4696
	jz	.jmpfar
4706
	jz	.jmpfar
4697
	mov	eax, [op11codes+eax*4]
4707
	mov	eax, [op11codes+eax*4]
4698
	test	eax, eax
4708
	test	eax, eax
4699
	jz	.0
4709
	jz	.0
4700
	cmp	eax, 'test'
4710
	cmp	eax, 'test'
4701
	jz	ctest
4711
	jz	ctest
4702
.2:
4712
.2:
4703
	stosd
4713
	stosd
4704
	mov	eax, '    '
4714
	mov	eax, '    '
4705
	stosd
4715
	stosd
4706
	call	disasm_readrmop
4716
	call	disasm_readrmop
4707
	and	byte [edi], 0
4717
	and	byte [edi], 0
4708
	ret
4718
	ret
4709
.callfar:
4719
.callfar:
4710
	mov	eax, 'call'
4720
	mov	eax, 'call'
4711
.1:
4721
.1:
4712
	cmp	esi, 0xC0
4722
	cmp	esi, 0xC0
4713
	jae	.0
4723
	jae	.0
4714
	stosd
4724
	stosd
4715
	mov	eax, '    '
4725
	mov	eax, '    '
4716
	stosd
4726
	stosd
4717
	mov	eax, 'far '
4727
	mov	eax, 'far '
4718
	stosd
4728
	stosd
4719
	mov	al, 'd'
4729
	mov	al, 'd'
4720
	test	ch, 1
4730
	test	ch, 1
4721
	jnz	@f
4731
	jnz	@f
4722
	mov	al, 'p'
4732
	mov	al, 'p'
4723
@@:
4733
@@:
4724
	stosb
4734
	stosb
4725
	or	ch, 1
4735
	or	ch, 1
4726
	call	disasm_readrmop
4736
	call	disasm_readrmop
4727
	and	byte [edi], 0
4737
	and	byte [edi], 0
4728
	ret
4738
	ret
4729
.jmpfar:
4739
.jmpfar:
4730
	mov	eax, 'jmp '
4740
	mov	eax, 'jmp '
4731
	jmp	.1
4741
	jmp	.1
4732
 
4742
 
4733
cpop2:
4743
cpop2:
4734
	or	ch, 80h
4744
	or	ch, 80h
4735
	call	disasm_get_byte
4745
	call	disasm_get_byte
4736
	dec	[disasm_cur_pos]
4746
	dec	[disasm_cur_pos]
4737
	test	al, 00111000b
4747
	test	al, 00111000b
4738
	jnz	cunk
4748
	jnz	cunk
4739
	mov	eax, 'pop '
4749
	mov	eax, 'pop '
4740
	jmp	cop1.2
4750
	jmp	cop1.2
4741
 
4751
 
4742
cloopnz:
4752
cloopnz:
4743
	mov	eax, 'loop'
4753
	mov	eax, 'loop'
4744
	stosd
4754
	stosd
4745
	mov	eax, 'nz  '
4755
	mov	eax, 'nz  '
4746
	test	ch, 2
4756
	test	ch, 2
4747
	jz	@f
4757
	jz	@f
4748
	mov	ah, 'w'
4758
	mov	ah, 'w'
4749
@@:	jmp	cloop.cmn
4759
@@:	jmp	cloop.cmn
4750
cloopz:
4760
cloopz:
4751
	mov	eax, 'loop'
4761
	mov	eax, 'loop'
4752
	stosd
4762
	stosd
4753
	mov	eax, 'z   '
4763
	mov	eax, 'z   '
4754
	test	ch, 2
4764
	test	ch, 2
4755
	jz	@f
4765
	jz	@f
4756
	mov	eax, 'zw  '
4766
	mov	eax, 'zw  '
4757
@@:	jmp	cloop.cmn
4767
@@:	jmp	cloop.cmn
4758
 
4768
 
4759
cjcxz:
4769
cjcxz:
4760
cloop:
4770
cloop:
4761
	cmp	al, 0xE2
4771
	cmp	al, 0xE2
4762
	jz	.loop
4772
	jz	.loop
4763
	test	ch, 2
4773
	test	ch, 2
4764
	jnz	.jcxz
4774
	jnz	.jcxz
4765
	mov	eax, 'jecx'
4775
	mov	eax, 'jecx'
4766
	stosd
4776
	stosd
4767
	mov	eax, 'z   '
4777
	mov	eax, 'z   '
4768
	jmp	.cmn
4778
	jmp	.cmn
4769
.jcxz:
4779
.jcxz:
4770
	mov	eax, 'jcxz'
4780
	mov	eax, 'jcxz'
4771
	stosd
4781
	stosd
4772
	mov	eax, '    '
4782
	mov	eax, '    '
4773
	jmp	.cmn
4783
	jmp	.cmn
4774
.loop:
4784
.loop:
4775
	mov	eax, 'loop'
4785
	mov	eax, 'loop'
4776
	stosd
4786
	stosd
4777
	mov	eax, '    '
4787
	mov	eax, '    '
4778
	test	ch, 2
4788
	test	ch, 2
4779
	jz	.cmn
4789
	jz	.cmn
4780
	mov	al, 'w'
4790
	mov	al, 'w'
4781
.cmn:
4791
.cmn:
4782
	stosd
4792
	stosd
4783
	call	disasm_get_byte
4793
	call	disasm_get_byte
4784
	movsx	eax, al
4794
	movsx	eax, al
4785
	add	eax, [disasm_cur_pos]
4795
	add	eax, [disasm_cur_pos]
4786
	test	ch, 1
4796
	test	ch, 1
4787
	jz	@f
4797
	jz	@f
4788
	and	eax, 0xFFFF
4798
	and	eax, 0xFFFF
4789
@@:
4799
@@:
4790
disasm_write_num_done:
4800
disasm_write_num_done:
4791
	call	disasm_write_num
4801
	call	disasm_write_num
4792
	and	byte [edi], 0
4802
	and	byte [edi], 0
4793
	ret
4803
	ret
4794
 
4804
 
4795
cimul1:
4805
cimul1:
4796
; imul r,r/m,i
4806
; imul r,r/m,i
4797
	or	ch, 80h		; 32bit operation
4807
	or	ch, 80h		; 32bit operation
4798
	xchg	eax, edx
4808
	xchg	eax, edx
4799
	mov	eax, 'imul'
4809
	mov	eax, 'imul'
4800
	stosd
4810
	stosd
4801
	mov	eax, '    '
4811
	mov	eax, '    '
4802
	stosd
4812
	stosd
4803
	call	disasm_get_byte
4813
	call	disasm_get_byte
4804
	dec	[disasm_cur_pos]
4814
	dec	[disasm_cur_pos]
4805
	shr	al, 3
4815
	shr	al, 3
4806
	and	eax, 7
4816
	and	eax, 7
4807
	call	disasm_write_reg1632
4817
	call	disasm_write_reg1632
4808
	mov	ax, ', '
4818
	mov	ax, ', '
4809
	stosw
4819
	stosw
4810
	call	disasm_readrmop
4820
	call	disasm_readrmop
4811
	mov	ax, ', '
4821
	mov	ax, ', '
4812
	stosw
4822
	stosw
4813
	test	ch, 1
4823
	test	ch, 1
4814
	jnz	.16
4824
	jnz	.16
4815
	cmp	dl, 0x69
4825
	cmp	dl, 0x69
4816
	jz	.op32
4826
	jz	.op32
4817
	call	disasm_get_byte
4827
	call	disasm_get_byte
4818
	movsx	eax, al
4828
	movsx	eax, al
4819
	jmp	disasm_write_num_done
4829
	jmp	disasm_write_num_done
4820
.op32:
4830
.op32:
4821
	call	disasm_get_dword
4831
	call	disasm_get_dword
4822
	jmp	disasm_write_num_done
4832
	jmp	disasm_write_num_done
4823
.16:
4833
.16:
4824
	cmp	dl, 0x69
4834
	cmp	dl, 0x69
4825
	jz	.op16
4835
	jz	.op16
4826
	call	disasm_get_byte
4836
	call	disasm_get_byte
4827
	cbw
4837
	cbw
4828
	jmp	disasm_write_num_done
4838
	jmp	disasm_write_num_done
4829
.op16:
4839
.op16:
4830
	xor	eax, eax
4840
	xor	eax, eax
4831
	call	disasm_get_word
4841
	call	disasm_get_word
4832
	jmp	disasm_write_num_done
4842
	jmp	disasm_write_num_done
4833
 
4843
 
4834
cshld:
4844
cshld:
4835
cshrd:
4845
cshrd:
4836
	mov	edx, 'shld'
4846
	mov	edx, 'shld'
4837
	test	al, 8
4847
	test	al, 8
4838
	jz	@f
4848
	jz	@f
4839
	mov	edx, 'shrd'
4849
	mov	edx, 'shrd'
4840
@@:
4850
@@:
4841
	xchg	eax, edx
4851
	xchg	eax, edx
4842
	stosd
4852
	stosd
4843
	mov	eax, '    '
4853
	mov	eax, '    '
4844
	stosd
4854
	stosd
4845
	call	disasm_get_byte
4855
	call	disasm_get_byte
4846
	dec	[disasm_cur_pos]
4856
	dec	[disasm_cur_pos]
4847
	shr	al, 3
4857
	shr	al, 3
4848
	and	eax, 7
4858
	and	eax, 7
4849
	push	eax
4859
	push	eax
4850
	or	ch, 80h
4860
	or	ch, 80h
4851
	call	disasm_readrmop
4861
	call	disasm_readrmop
4852
	mov	ax, ', '
4862
	mov	ax, ', '
4853
	stosw
4863
	stosw
4854
	pop	eax
4864
	pop	eax
4855
	call	disasm_write_reg1632
4865
	call	disasm_write_reg1632
4856
	mov	ax, ', '
4866
	mov	ax, ', '
4857
	stosw
4867
	stosw
4858
	test	dl, 1
4868
	test	dl, 1
4859
	jz	disasm_i8u
4869
	jz	disasm_i8u
4860
	mov	ax, 'cl'
4870
	mov	ax, 'cl'
4861
	stosw
4871
	stosw
4862
	and	byte [edi], 0
4872
	and	byte [edi], 0
4863
	ret
4873
	ret
4864
 
4874
 
4865
ccbw:
4875
ccbw:
4866
	mov	eax, 'cbw '
4876
	mov	eax, 'cbw '
4867
	test	ch, 1
4877
	test	ch, 1
4868
	jnz	@f
4878
	jnz	@f
4869
	mov	eax, 'cwde'
4879
	mov	eax, 'cwde'
4870
@@:	stosd
4880
@@:	stosd
4871
	and	byte [edi], 0
4881
	and	byte [edi], 0
4872
	ret
4882
	ret
4873
ccwd:
4883
ccwd:
4874
	mov	eax, 'cwd '
4884
	mov	eax, 'cwd '
4875
	test	ch, 1
4885
	test	ch, 1
4876
	jnz	@b
4886
	jnz	@b
4877
	mov	eax, 'cdq '
4887
	mov	eax, 'cdq '
4878
	jmp	@b
4888
	jmp	@b
4879
 
4889
 
4880
ccmpxchg8b:
4890
ccmpxchg8b:
4881
	call	disasm_get_byte
4891
	call	disasm_get_byte
4882
	cmp	al, 0xC0
4892
	cmp	al, 0xC0
4883
	jae	cerr
4893
	jae	cerr
4884
	shr	al, 3
4894
	shr	al, 3
4885
	and	al, 7
4895
	and	al, 7
4886
	cmp	al, 1
4896
	cmp	al, 1
4887
	jnz	cerr
4897
	jnz	cerr
4888
	dec	[disasm_cur_pos]
4898
	dec	[disasm_cur_pos]
4889
	mov	eax, 'cmpx'
4899
	mov	eax, 'cmpx'
4890
	stosd
4900
	stosd
4891
	mov	eax, 'chg8'
4901
	mov	eax, 'chg8'
4892
	stosd
4902
	stosd
4893
	mov	al, 'b'
4903
	mov	al, 'b'
4894
	stosb
4904
	stosb
4895
	mov	al, ' '
4905
	mov	al, ' '
4896
	stosb
4906
	stosb
4897
	or	ch, 40h
4907
	or	ch, 40h
4898
	call	disasm_readrmop
4908
	call	disasm_readrmop
4899
	and	byte [edi], 0
4909
	and	byte [edi], 0
4900
	ret
4910
	ret
4901
 
4911
 
4902
iglobal
4912
iglobal
4903
fpuD8	dd	'add ','mul ','com ','comp','sub ','subr','div ','divr'
4913
fpuD8	dd	'add ','mul ','com ','comp','sub ','subr','div ','divr'
4904
endg
4914
endg
4905
 
4915
 
4906
cD8:
4916
cD8:
4907
	call	disasm_get_byte
4917
	call	disasm_get_byte
4908
	dec	[disasm_cur_pos]
4918
	dec	[disasm_cur_pos]
4909
	push	eax
4919
	push	eax
4910
	shr	al, 3
4920
	shr	al, 3
4911
	and	eax, 7
4921
	and	eax, 7
4912
	mov	byte [edi], 'f'
4922
	mov	byte [edi], 'f'
4913
	inc	edi
4923
	inc	edi
4914
	xchg	eax, edx
4924
	xchg	eax, edx
4915
	mov	eax, [fpuD8+edx*4]
4925
	mov	eax, [fpuD8+edx*4]
4916
	stosd
4926
	stosd
4917
	mov	ax, '  '
4927
	mov	ax, '  '
4918
	stosw
4928
	stosw
4919
	stosb
4929
	stosb
4920
	pop	eax
4930
	pop	eax
4921
	cmp	dl, 2
4931
	cmp	dl, 2
4922
	jb	.1
4932
	jb	.1
4923
	cmp	dl, 3
4933
	cmp	dl, 3
4924
	jbe	.2
4934
	jbe	.2
4925
.1:
4935
.1:
4926
	cmp	al, 0xC0
4936
	cmp	al, 0xC0
4927
	jb	.2
4937
	jb	.2
4928
	mov	eax, 'st0,'
4938
	mov	eax, 'st0,'
4929
	stosd
4939
	stosd
4930
	mov	al, ' '
4940
	mov	al, ' '
4931
	stosb
4941
	stosb
4932
.2:
4942
.2:
4933
	or	ch, 80h or 20h
4943
	or	ch, 80h or 20h
4934
	and	ch, not 1
4944
	and	ch, not 1
4935
	call	disasm_readrmop
4945
	call	disasm_readrmop
4936
	and	byte [edi], 0
4946
	and	byte [edi], 0
4937
	ret
4947
	ret
4938
 
4948
 
4939
iglobal
4949
iglobal
4940
fpuD9_2:
4950
fpuD9_2:
4941
	dq	'fchs    ','fabs    ',0,0,'ftst    ','fxam    ',0,0
4951
	dq	'fchs    ','fabs    ',0,0,'ftst    ','fxam    ',0,0
4942
	db	'fld1    fldl2t  fldl2e  fldpi   fldlg2  fldln2  fldz    '
4952
	db	'fld1    fldl2t  fldl2e  fldpi   fldlg2  fldln2  fldz    '
4943
	dq	0
4953
	dq	0
4944
	db	'f2xm1   fyl2x   fptan   fpatan  fxtract fprem1  fdecstp fincstp '
4954
	db	'f2xm1   fyl2x   fptan   fpatan  fxtract fprem1  fdecstp fincstp '
4945
	db	'fprem   fyl2xp1 fsqrt   fsincos frndint fscale  fsin    fcos    '
4955
	db	'fprem   fyl2xp1 fsqrt   fsincos frndint fscale  fsin    fcos    '
4946
fpuD9_fnop	db	'fnop    '
4956
fpuD9_fnop	db	'fnop    '
4947
endg
4957
endg
4948
cD9:
4958
cD9:
4949
	call	disasm_get_byte
4959
	call	disasm_get_byte
4950
	sub	al, 0xC0
4960
	sub	al, 0xC0
4951
	jae	.l1
4961
	jae	.l1
4952
	dec	[disasm_cur_pos]
4962
	dec	[disasm_cur_pos]
4953
	shr	al, 3
4963
	shr	al, 3
4954
	and	eax, 7
4964
	and	eax, 7
4955
	cmp	al, 7
4965
	cmp	al, 7
4956
	jnz	@f
4966
	jnz	@f
4957
	mov	eax, 'fnst'
4967
	mov	eax, 'fnst'
4958
	stosd
4968
	stosd
4959
	mov	eax, 'cw  '
4969
	mov	eax, 'cw  '
4960
	jmp	.x1
4970
	jmp	.x1
4961
@@:
4971
@@:
4962
	cmp	al, 5
4972
	cmp	al, 5
4963
	jnz	@f
4973
	jnz	@f
4964
	mov	eax, 'fldc'
4974
	mov	eax, 'fldc'
4965
	stosd
4975
	stosd
4966
	mov	eax, 'w   '
4976
	mov	eax, 'w   '
4967
.x1:
4977
.x1:
4968
	stosd
4978
	stosd
4969
	or	ch, 0C1h
4979
	or	ch, 0C1h
4970
	jmp	.cmn
4980
	jmp	.cmn
4971
@@:
4981
@@:
4972
	mov	edx, 'fld '
4982
	mov	edx, 'fld '
4973
	test	al, al
4983
	test	al, al
4974
	jz	@f
4984
	jz	@f
4975
	mov	edx, 'fst '
4985
	mov	edx, 'fst '
4976
	cmp	al, 2
4986
	cmp	al, 2
4977
	jz	@f
4987
	jz	@f
4978
	mov	edx, 'fstp'
4988
	mov	edx, 'fstp'
4979
	cmp	al, 3
4989
	cmp	al, 3
4980
	jnz	cunk
4990
	jnz	cunk
4981
@@:
4991
@@:
4982
	xchg	eax, edx
4992
	xchg	eax, edx
4983
	stosd
4993
	stosd
4984
	mov	eax, '    '
4994
	mov	eax, '    '
4985
	stosd
4995
	stosd
4986
	or	ch, 80h
4996
	or	ch, 80h
4987
	and	ch, not 1
4997
	and	ch, not 1
4988
.cmn:
4998
.cmn:
4989
	call	disasm_readrmop
4999
	call	disasm_readrmop
4990
	and	byte [edi], 0
5000
	and	byte [edi], 0
4991
	ret
5001
	ret
4992
.l1:
5002
.l1:
4993
	cmp	al, 10h
5003
	cmp	al, 10h
4994
	jae	.l2
5004
	jae	.l2
4995
	mov	edx, 'fld '
5005
	mov	edx, 'fld '
4996
	cmp	al, 8
5006
	cmp	al, 8
4997
	jb	@f
5007
	jb	@f
4998
	mov	edx, 'fxch'
5008
	mov	edx, 'fxch'
4999
@@:
5009
@@:
5000
	xchg	eax, edx
5010
	xchg	eax, edx
5001
	stosd
5011
	stosd
5002
	mov	eax, '    '
5012
	mov	eax, '    '
5003
	stosd
5013
	stosd
5004
	xchg	eax, edx
5014
	xchg	eax, edx
5005
	and	al, 7
5015
	and	al, 7
5006
	add	al, '0'
5016
	add	al, '0'
5007
	shl	eax, 16
5017
	shl	eax, 16
5008
	mov	ax, 'st'
5018
	mov	ax, 'st'
5009
	stosd
5019
	stosd
5010
	clc
5020
	clc
5011
	ret
5021
	ret
5012
.l2:
5022
.l2:
5013
	cmp	al, 0x10
5023
	cmp	al, 0x10
5014
	jnz	@f
5024
	jnz	@f
5015
	mov	esi, fpuD9_fnop
5025
	mov	esi, fpuD9_fnop
5016
	jmp	.l3
5026
	jmp	.l3
5017
@@:
5027
@@:
5018
	sub	al, 0x20
5028
	sub	al, 0x20
5019
	jb	cerr
5029
	jb	cerr
5020
	lea	esi, [fpuD9_2+eax*8]
5030
	lea	esi, [fpuD9_2+eax*8]
5021
	cmp	byte [esi], 0
5031
	cmp	byte [esi], 0
5022
	jz	cerr
5032
	jz	cerr
5023
.l3:
5033
.l3:
5024
	movsd
5034
	movsd
5025
	movsd
5035
	movsd
5026
	and	byte [edi-1], 0
5036
	and	byte [edi-1], 0
5027
	ret
5037
	ret
5028
 
5038
 
5029
cDA:
5039
cDA:
5030
	call	disasm_get_byte
5040
	call	disasm_get_byte
5031
	cmp	al, 0xC0
5041
	cmp	al, 0xC0
5032
	jae	cunk
5042
	jae	cunk
5033
	dec	[disasm_cur_pos]
5043
	dec	[disasm_cur_pos]
5034
	shr	al, 3
5044
	shr	al, 3
5035
	and	eax, 7
5045
	and	eax, 7
5036
	mov	word [edi], 'fi'
5046
	mov	word [edi], 'fi'
5037
	inc	edi
5047
	inc	edi
5038
	inc	edi
5048
	inc	edi
5039
	mov	eax, [fpuD8+eax*4]
5049
	mov	eax, [fpuD8+eax*4]
5040
	stosd
5050
	stosd
5041
	mov	ax, '  '
5051
	mov	ax, '  '
5042
	stosw
5052
	stosw
5043
	or	ch, 80h
5053
	or	ch, 80h
5044
	and	ch, not 1	; 32-bit operand
5054
	and	ch, not 1	; 32-bit operand
5045
	call	disasm_readrmop
5055
	call	disasm_readrmop
5046
	and	byte [edi], 0
5056
	and	byte [edi], 0
5047
	ret
5057
	ret
5048
 
5058
 
5049
iglobal
5059
iglobal
5050
fpuDB	dd	'ild ',0,'ist ','istp',0,'ld  ',0,'stp '
5060
fpuDB	dd	'ild ',0,'ist ','istp',0,'ld  ',0,'stp '
5051
endg
5061
endg
5052
cDB:
5062
cDB:
5053
	call	disasm_get_byte
5063
	call	disasm_get_byte
5054
	cmp	al, 0xC0
5064
	cmp	al, 0xC0
5055
	jae	.1
5065
	jae	.1
5056
	dec	[disasm_cur_pos]
5066
	dec	[disasm_cur_pos]
5057
	shr	al, 3
5067
	shr	al, 3
5058
	and	eax, 7
5068
	and	eax, 7
5059
	xchg	eax, edx
5069
	xchg	eax, edx
5060
	mov	eax, [fpuDB+edx*4]
5070
	mov	eax, [fpuDB+edx*4]
5061
	test	eax, eax
5071
	test	eax, eax
5062
	jz	cerr
5072
	jz	cerr
5063
	mov	byte [edi], 'f'
5073
	mov	byte [edi], 'f'
5064
	inc	edi
5074
	inc	edi
5065
	stosd
5075
	stosd
5066
	mov	ax, '  '
5076
	mov	ax, '  '
5067
	stosw
5077
	stosw
5068
	stosb
5078
	stosb
5069
	or	ch, 80h
5079
	or	ch, 80h
5070
	and	ch, not 1	; 32-bit operand
5080
	and	ch, not 1	; 32-bit operand
5071
	cmp	dl, 4
5081
	cmp	dl, 4
5072
	jb	@f
5082
	jb	@f
5073
	or	ch, 20h
5083
	or	ch, 20h
5074
	and	ch, not 80h	; 80-bit operand
5084
	and	ch, not 80h	; 80-bit operand
5075
@@:
5085
@@:
5076
	call	disasm_readrmop
5086
	call	disasm_readrmop
5077
	and	byte [edi], 0
5087
	and	byte [edi], 0
5078
	ret
5088
	ret
5079
.1:
5089
.1:
5080
	cmp	al, 0xE3
5090
	cmp	al, 0xE3
5081
	jnz	cunk
5091
	jnz	cunk
5082
	mov	eax, 'fnin'
5092
	mov	eax, 'fnin'
5083
	stosd
5093
	stosd
5084
	mov	eax, 'it'
5094
	mov	eax, 'it'
5085
	stosd
5095
	stosd
5086
	dec	edi
5096
	dec	edi
5087
	ret		; CF cleared
5097
	ret		; CF cleared
5088
 
5098
 
5089
iglobal
5099
iglobal
5090
fpuDC	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
5100
fpuDC	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
5091
endg
5101
endg
5092
cDC:
5102
cDC:
5093
	call	disasm_get_byte
5103
	call	disasm_get_byte
5094
	cmp	al, 0xC0
5104
	cmp	al, 0xC0
5095
	jae	.1
5105
	jae	.1
5096
	dec	[disasm_cur_pos]
5106
	dec	[disasm_cur_pos]
5097
	shr	al, 3
5107
	shr	al, 3
5098
	and	eax, 7
5108
	and	eax, 7
5099
	mov	byte [edi], 'f'
5109
	mov	byte [edi], 'f'
5100
	inc	edi
5110
	inc	edi
5101
	mov	eax, [fpuD8+eax*4]
5111
	mov	eax, [fpuD8+eax*4]
5102
	stosd
5112
	stosd
5103
	mov	ax, '  '
5113
	mov	ax, '  '
5104
	stosw
5114
	stosw
5105
	stosb
5115
	stosb
5106
	or	ch, 0A1h	; qword
5116
	or	ch, 0A1h	; qword
5107
	call	disasm_readrmop
5117
	call	disasm_readrmop
5108
	and	byte [edi], 0
5118
	and	byte [edi], 0
5109
	ret
5119
	ret
5110
.1:
5120
.1:
5111
	mov	dl, al
5121
	mov	dl, al
5112
	shr	al, 3
5122
	shr	al, 3
5113
	and	eax, 7
5123
	and	eax, 7
5114
	mov	eax, [fpuDC+eax*4]
5124
	mov	eax, [fpuDC+eax*4]
5115
	test	eax, eax
5125
	test	eax, eax
5116
	jz	cerr
5126
	jz	cerr
5117
	mov	byte [edi], 'f'
5127
	mov	byte [edi], 'f'
5118
	inc	edi
5128
	inc	edi
5119
	stosd
5129
	stosd
5120
	mov	eax, '   s'
5130
	mov	eax, '   s'
5121
	stosd
5131
	stosd
5122
	mov	al, 't'
5132
	mov	al, 't'
5123
	stosb
5133
	stosb
5124
	and	edx, 7
5134
	and	edx, 7
5125
	lea	eax, [edx+'0']
5135
	lea	eax, [edx+'0']
5126
	stosb
5136
	stosb
5127
	mov	eax, ', st'
5137
	mov	eax, ', st'
5128
	stosd
5138
	stosd
5129
	mov	ax, '0'
5139
	mov	ax, '0'
5130
	stosw
5140
	stosw
5131
	ret	; CF cleared
5141
	ret	; CF cleared
5132
 
5142
 
5133
iglobal
5143
iglobal
5134
fpuDD	dd	'fld ',0,'fst ','fstp',0,0,0,0
5144
fpuDD	dd	'fld ',0,'fst ','fstp',0,0,0,0
5135
fpuDD_2	dq	'ffree   ',0,'fst     ','fstp    ','fucom   ','fucomp  ',0,0
5145
fpuDD_2	dq	'ffree   ',0,'fst     ','fstp    ','fucom   ','fucomp  ',0,0
5136
endg
5146
endg
5137
cDD:
5147
cDD:
5138
	call	disasm_get_byte
5148
	call	disasm_get_byte
5139
	cmp	al, 0xC0
5149
	cmp	al, 0xC0
5140
	jae	.1
5150
	jae	.1
5141
	dec	[disasm_cur_pos]
5151
	dec	[disasm_cur_pos]
5142
	shr	al, 3
5152
	shr	al, 3
5143
	and	eax, 7
5153
	and	eax, 7
5144
	xchg	eax, edx
5154
	xchg	eax, edx
5145
	mov	eax, [fpuDD+edx*4]
5155
	mov	eax, [fpuDD+edx*4]
5146
	test	eax, eax
5156
	test	eax, eax
5147
	jz	cunk
5157
	jz	cunk
5148
	stosd
5158
	stosd
5149
	mov	eax, '    '
5159
	mov	eax, '    '
5150
	stosd
5160
	stosd
5151
	or	ch, 0A1h	; qword operand
5161
	or	ch, 0A1h	; qword operand
5152
	call	disasm_readrmop
5162
	call	disasm_readrmop
5153
	and	byte [edi], 0
5163
	and	byte [edi], 0
5154
	ret
5164
	ret
5155
.1:
5165
.1:
5156
	push	eax
5166
	push	eax
5157
	shr	al, 3
5167
	shr	al, 3
5158
	and	eax, 7
5168
	and	eax, 7
5159
	xchg	eax, edx
5169
	xchg	eax, edx
5160
	mov	eax, dword [fpuDD_2+edx*8]
5170
	mov	eax, dword [fpuDD_2+edx*8]
5161
	test	eax, eax
5171
	test	eax, eax
5162
	jz	cerr
5172
	jz	cerr
5163
	stosd
5173
	stosd
5164
	mov	eax, dword [fpuDD_2+4+edx*8]
5174
	mov	eax, dword [fpuDD_2+4+edx*8]
5165
	stosd
5175
	stosd
5166
	mov	ax, 'st'
5176
	mov	ax, 'st'
5167
	stosw
5177
	stosw
5168
	pop	eax
5178
	pop	eax
5169
	and	al, 7
5179
	and	al, 7
5170
	add	al, '0'
5180
	add	al, '0'
5171
	stosb
5181
	stosb
5172
	and	byte [edi], 0
5182
	and	byte [edi], 0
5173
	ret
5183
	ret
5174
 
5184
 
5175
iglobal
5185
iglobal
5176
fpuDE	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
5186
fpuDE	dd	'add ','mul ',0,0,'subr','sub ','divr','div '
5177
endg
5187
endg
5178
cDE:
5188
cDE:
5179
	call	disasm_get_byte
5189
	call	disasm_get_byte
5180
	cmp	al, 0xC0
5190
	cmp	al, 0xC0
5181
	jae	.1
5191
	jae	.1
5182
	dec	[disasm_cur_pos]
5192
	dec	[disasm_cur_pos]
5183
	mov	word [edi], 'fi'
5193
	mov	word [edi], 'fi'
5184
	inc	edi
5194
	inc	edi
5185
	inc	edi
5195
	inc	edi
5186
	shr	al, 3
5196
	shr	al, 3
5187
	and	eax, 7
5197
	and	eax, 7
5188
	mov	eax, [fpuD8+eax*4]
5198
	mov	eax, [fpuD8+eax*4]
5189
	stosd
5199
	stosd
5190
	mov	ax, '  '
5200
	mov	ax, '  '
5191
	stosw
5201
	stosw
5192
	or	ch, 81h		; force 16-bit
5202
	or	ch, 81h		; force 16-bit
5193
	call	disasm_readrmop
5203
	call	disasm_readrmop
5194
	and	byte [edi], 0
5204
	and	byte [edi], 0
5195
	ret
5205
	ret
5196
.1:
5206
.1:
5197
	push	eax
5207
	push	eax
5198
	shr	al, 3
5208
	shr	al, 3
5199
	and	eax, 7
5209
	and	eax, 7
5200
	xchg	eax, edx
5210
	xchg	eax, edx
5201
	mov	eax, [fpuDE+edx*4]
5211
	mov	eax, [fpuDE+edx*4]
5202
	test	eax, eax
5212
	test	eax, eax
5203
	jz	.fcompp
5213
	jz	.fcompp
5204
	mov	byte [edi], 'f'
5214
	mov	byte [edi], 'f'
5205
	inc	edi
5215
	inc	edi
5206
	stosd
5216
	stosd
5207
	mov	al, 'p'
5217
	mov	al, 'p'
5208
	cmp	byte [edi-1], ' '
5218
	cmp	byte [edi-1], ' '
5209
	jnz	@f
5219
	jnz	@f
5210
	mov	byte [edi-1], al
5220
	mov	byte [edi-1], al
5211
	mov	al, ' '
5221
	mov	al, ' '
5212
@@:	stosb
5222
@@:	stosb
5213
	mov	eax, '  st'
5223
	mov	eax, '  st'
5214
	stosd
5224
	stosd
5215
	pop	eax
5225
	pop	eax
5216
	and	al, 7
5226
	and	al, 7
5217
	add	al, '0'
5227
	add	al, '0'
5218
	stosb
5228
	stosb
5219
	mov	ax, ', '
5229
	mov	ax, ', '
5220
	stosw
5230
	stosw
5221
	mov	eax, 'st0'
5231
	mov	eax, 'st0'
5222
	stosd
5232
	stosd
5223
	ret	; CF cleared
5233
	ret	; CF cleared
5224
.fcompp:
5234
.fcompp:
5225
	pop	eax
5235
	pop	eax
5226
	cmp	al, 0xD9
5236
	cmp	al, 0xD9
5227
	jnz	cerr
5237
	jnz	cerr
5228
	mov	eax, 'fcom'
5238
	mov	eax, 'fcom'
5229
	stosd
5239
	stosd
5230
	mov	ax, 'pp'
5240
	mov	ax, 'pp'
5231
	stosw
5241
	stosw
5232
	and	byte [edi], 0
5242
	and	byte [edi], 0
5233
	ret
5243
	ret
5234
 
5244
 
5235
iglobal
5245
iglobal
5236
fpuDF	dd	'ild ',0,'ist ','istp','bld ','ild ','bstp','istp'
5246
fpuDF	dd	'ild ',0,'ist ','istp','bld ','ild ','bstp','istp'
5237
endg
5247
endg
5238
 
5248
 
5239
cDF:
5249
cDF:
5240
	call	disasm_get_byte
5250
	call	disasm_get_byte
5241
	cmp	al, 0xC0
5251
	cmp	al, 0xC0
5242
	jae	.1
5252
	jae	.1
5243
	dec	[disasm_cur_pos]
5253
	dec	[disasm_cur_pos]
5244
	shr	al, 3
5254
	shr	al, 3
5245
	and	eax, 7
5255
	and	eax, 7
5246
	xchg	eax, edx
5256
	xchg	eax, edx
5247
	mov	eax, [fpuDF+edx*4]
5257
	mov	eax, [fpuDF+edx*4]
5248
	test	eax, eax
5258
	test	eax, eax
5249
	jz	cerr
5259
	jz	cerr
5250
	mov	byte [edi], 'f'
5260
	mov	byte [edi], 'f'
5251
	inc	edi
5261
	inc	edi
5252
	stosd
5262
	stosd
5253
	mov	ax, '  '
5263
	mov	ax, '  '
5254
	stosw
5264
	stosw
5255
	stosb
5265
	stosb
5256
	or	ch, 81h		; force 16-bit operand
5266
	or	ch, 81h		; force 16-bit operand
5257
	cmp	dl, 4
5267
	cmp	dl, 4
5258
	jb	@f
5268
	jb	@f
5259
	or	ch, 20h
5269
	or	ch, 20h
5260
	test	dl, 1
5270
	test	dl, 1
5261
	jnz	@f
5271
	jnz	@f
5262
	or	ch, 40h
5272
	or	ch, 40h
5263
@@:
5273
@@:
5264
	call	disasm_readrmop
5274
	call	disasm_readrmop
5265
	and	byte [edi], 0
5275
	and	byte [edi], 0
5266
	ret
5276
	ret
5267
.1:
5277
.1:
5268
	cmp	al, 0xE0
5278
	cmp	al, 0xE0
5269
	jnz	cunk
5279
	jnz	cunk
5270
	mov	eax, 'fnst'
5280
	mov	eax, 'fnst'
5271
	stosd
5281
	stosd
5272
	mov	eax, 'sw  '
5282
	mov	eax, 'sw  '
5273
	stosd
5283
	stosd
5274
	mov	ax, 'ax'
5284
	mov	ax, 'ax'
5275
	stosw
5285
	stosw
5276
	and	byte [edi], 0
5286
	and	byte [edi], 0
5277
	ret
5287
	ret
5278
 
5288
 
5279
cmovd1:
5289
cmovd1:
5280
	mov	eax, 'movd'
5290
	mov	eax, 'movd'
5281
	stosd
5291
	stosd
5282
	mov	eax, '    '
5292
	mov	eax, '    '
5283
	stosd
5293
	stosd
5284
	call	disasm_get_byte
5294
	call	disasm_get_byte
5285
	dec	[disasm_cur_pos]
5295
	dec	[disasm_cur_pos]
5286
	shr	al, 3
5296
	shr	al, 3
5287
	and	eax, 7
5297
	and	eax, 7
5288
	call	disasm_write_mmreg
5298
	call	disasm_write_mmreg
5289
	mov	ax, ', '
5299
	mov	ax, ', '
5290
	stosw
5300
	stosw
5291
	or	ch, 0C0h
5301
	or	ch, 0C0h
5292
	and	ch, not 1
5302
	and	ch, not 1
5293
	call	disasm_readrmop
5303
	call	disasm_readrmop
5294
	and	byte [edi], 0
5304
	and	byte [edi], 0
5295
	ret
5305
	ret
5296
cmovd2:
5306
cmovd2:
5297
	mov	eax, 'movd'
5307
	mov	eax, 'movd'
5298
	stosd
5308
	stosd
5299
	mov	eax, '    '
5309
	mov	eax, '    '
5300
	stosd
5310
	stosd
5301
	call	disasm_get_byte
5311
	call	disasm_get_byte
5302
	dec	[disasm_cur_pos]
5312
	dec	[disasm_cur_pos]
5303
	shr	al, 3
5313
	shr	al, 3
5304
	and	eax, 7
5314
	and	eax, 7
5305
	push	eax ecx
5315
	push	eax ecx
5306
	or	ch, 0C0h
5316
	or	ch, 0C0h
5307
	and	ch, not 1
5317
	and	ch, not 1
5308
	call	disasm_readrmop
5318
	call	disasm_readrmop
5309
	mov	ax, ', '
5319
	mov	ax, ', '
5310
	stosw
5320
	stosw
5311
	pop	ecx eax
5321
	pop	ecx eax
5312
	call	disasm_write_mmreg
5322
	call	disasm_write_mmreg
5313
	and	byte [edi], 0
5323
	and	byte [edi], 0
5314
	ret
5324
	ret
5315
 
5325
 
5316
cmovq1:
5326
cmovq1:
5317
	test	ch, 1
5327
	test	ch, 1
5318
	jz	.mm
5328
	jz	.mm
5319
	mov	eax, 'movd'
5329
	mov	eax, 'movd'
5320
	stosd
5330
	stosd
5321
	mov	eax, 'qa  '
5331
	mov	eax, 'qa  '
5322
	stosd
5332
	stosd
5323
	jmp	disasm_mmx1
5333
	jmp	disasm_mmx1
5324
.mm:
5334
.mm:
5325
	mov	eax, 'movq'
5335
	mov	eax, 'movq'
5326
	stosd
5336
	stosd
5327
	mov	eax, '    '
5337
	mov	eax, '    '
5328
	stosd
5338
	stosd
5329
	jmp	disasm_mmx1
5339
	jmp	disasm_mmx1
5330
cmovq2:
5340
cmovq2:
5331
	test	ch, 1
5341
	test	ch, 1
5332
	jz	.mm
5342
	jz	.mm
5333
	mov	eax, 'movd'
5343
	mov	eax, 'movd'
5334
	stosd
5344
	stosd
5335
	mov	eax, 'qa  '
5345
	mov	eax, 'qa  '
5336
	stosd
5346
	stosd
5337
	jmp	disasm_mmx3
5347
	jmp	disasm_mmx3
5338
.mm:
5348
.mm:
5339
	mov	eax, 'movq'
5349
	mov	eax, 'movq'
5340
disasm_mmx2:
5350
disasm_mmx2:
5341
	stosd
5351
	stosd
5342
	mov	eax, '    '
5352
	mov	eax, '    '
5343
	stosd
5353
	stosd
5344
disasm_mmx3:
5354
disasm_mmx3:
5345
	or	ch, 50h
5355
	or	ch, 50h
5346
	call	disasm_get_byte
5356
	call	disasm_get_byte
5347
	dec	[disasm_cur_pos]
5357
	dec	[disasm_cur_pos]
5348
	push	eax
5358
	push	eax
5349
	call	disasm_readrmop
5359
	call	disasm_readrmop
5350
	mov	ax, ', '
5360
	mov	ax, ', '
5351
	stosw
5361
	stosw
5352
	pop	eax
5362
	pop	eax
5353
	shr	al, 3
5363
	shr	al, 3
5354
	and	eax, 7
5364
	and	eax, 7
5355
	call	disasm_write_mmreg
5365
	call	disasm_write_mmreg
5356
	and	byte [edi], 0
5366
	and	byte [edi], 0
5357
	ret
5367
	ret
5358
 
5368
 
5359
iglobal
5369
iglobal
5360
mmx_cmds:
5370
mmx_cmds:
5361
	db	0x60,'unpcklbw'
5371
	db	0x60,'unpcklbw'
5362
	db	0x61,'unpcklwd'
5372
	db	0x61,'unpcklwd'
5363
	db	0x62,'unpckldq'
5373
	db	0x62,'unpckldq'
5364
	db	0x63,'packsswb'
5374
	db	0x63,'packsswb'
5365
	db	0x64,'pcmpgtb '
5375
	db	0x64,'pcmpgtb '
5366
	db	0x65,'pcmpgtw '
5376
	db	0x65,'pcmpgtw '
5367
	db	0x66,'pcmpgtd '
5377
	db	0x66,'pcmpgtd '
5368
	db	0x67,'packuswb'
5378
	db	0x67,'packuswb'
5369
	db	0x68,'unpckhbw'
5379
	db	0x68,'unpckhbw'
5370
	db	0x69,'unpckhwd'
5380
	db	0x69,'unpckhwd'
5371
	db	0x6A,'unpckhdq'
5381
	db	0x6A,'unpckhdq'
5372
	db	0x6B,'packssdw'
5382
	db	0x6B,'packssdw'
5373
	db	0x74,'pcmpeqb '
5383
	db	0x74,'pcmpeqb '
5374
	db	0x75,'pcmpeqw '
5384
	db	0x75,'pcmpeqw '
5375
	db	0x76,'pcmpeqd '
5385
	db	0x76,'pcmpeqd '
5376
	db	0xD4,'paddq   '
5386
	db	0xD4,'paddq   '
5377
	db	0xD5,'pmullw  '
5387
	db	0xD5,'pmullw  '
5378
	db	0xD8,'psubusb '
5388
	db	0xD8,'psubusb '
5379
	db	0xD9,'psubusw '
5389
	db	0xD9,'psubusw '
5380
	db	0xDA,'pminub  '
5390
	db	0xDA,'pminub  '
5381
	db	0xDB,'pand    '
5391
	db	0xDB,'pand    '
5382
	db	0xDC,'paddusb '
5392
	db	0xDC,'paddusb '
5383
	db	0xDD,'paddusw '
5393
	db	0xDD,'paddusw '
5384
	db	0xDE,'pmaxub  '
5394
	db	0xDE,'pmaxub  '
5385
	db	0xDF,'pandn   '
5395
	db	0xDF,'pandn   '
5386
	db	0xE0,'pavgb   '
5396
	db	0xE0,'pavgb   '
5387
	db	0xE3,'pavgw   '
5397
	db	0xE3,'pavgw   '
5388
	db	0xE4,'pmulhuw '
5398
	db	0xE4,'pmulhuw '
5389
	db	0xE5,'pmulhw  '
5399
	db	0xE5,'pmulhw  '
5390
	db	0xE8,'psubsb  '
5400
	db	0xE8,'psubsb  '
5391
	db	0xE9,'psubsw  '
5401
	db	0xE9,'psubsw  '
5392
	db	0xEA,'pminsw  '
5402
	db	0xEA,'pminsw  '
5393
	db	0xEB,'por     '
5403
	db	0xEB,'por     '
5394
	db	0xEC,'paddsb  '
5404
	db	0xEC,'paddsb  '
5395
	db	0xED,'paddsw  '
5405
	db	0xED,'paddsw  '
5396
	db	0xEE,'pmaxsw  '
5406
	db	0xEE,'pmaxsw  '
5397
	db	0xEF,'pxor    '
5407
	db	0xEF,'pxor    '
5398
	db	0xF4,'pmuludq '
5408
	db	0xF4,'pmuludq '
5399
	db	0xF5,'pmaddwd '
5409
	db	0xF5,'pmaddwd '
5400
	db	0xF6,'psadbw  '
5410
	db	0xF6,'psadbw  '
5401
	db	0xF8,'psubb   '
5411
	db	0xF8,'psubb   '
5402
	db	0xF9,'psubw   '
5412
	db	0xF9,'psubw   '
5403
	db	0xFA,'psubd   '
5413
	db	0xFA,'psubd   '
5404
	db	0xFB,'psubq   '
5414
	db	0xFB,'psubq   '
5405
	db	0xFC,'paddb   '
5415
	db	0xFC,'paddb   '
5406
	db	0xFD,'paddw   '
5416
	db	0xFD,'paddw   '
5407
	db	0xFE,'paddd   '
5417
	db	0xFE,'paddd   '
5408
endg
5418
endg
5409
cpcmn:
5419
cpcmn:
5410
	mov	esi, mmx_cmds
5420
	mov	esi, mmx_cmds
5411
@@:
5421
@@:
5412
	cmp	al, [esi]
5422
	cmp	al, [esi]
5413
	jz	@f
5423
	jz	@f
5414
	add	esi, 9
5424
	add	esi, 9
5415
	jmp	@b
5425
	jmp	@b
5416
@@:
5426
@@:
5417
	inc	esi
5427
	inc	esi
5418
	mov	al, 'p'
5428
	mov	al, 'p'
5419
	cmp	byte [esi], al
5429
	cmp	byte [esi], al
5420
	jz	@f
5430
	jz	@f
5421
	stosb
5431
	stosb
5422
@@:
5432
@@:
5423
	movsd
5433
	movsd
5424
	movsd
5434
	movsd
5425
	cmp	byte [edi-1], ' '
5435
	cmp	byte [edi-1], ' '
5426
	jz	@f
5436
	jz	@f
5427
	mov	al, ' '
5437
	mov	al, ' '
5428
	stosb
5438
	stosb
5429
@@:
5439
@@:
5430
 
5440
 
5431
disasm_mmx1:
5441
disasm_mmx1:
5432
	or	ch, 50h
5442
	or	ch, 50h
5433
	call	disasm_get_byte
5443
	call	disasm_get_byte
5434
	dec	[disasm_cur_pos]
5444
	dec	[disasm_cur_pos]
5435
	shr	al, 3
5445
	shr	al, 3
5436
	and	eax, 7
5446
	and	eax, 7
5437
	call	disasm_write_mmreg
5447
	call	disasm_write_mmreg
5438
	mov	ax, ', '
5448
	mov	ax, ', '
5439
	stosw
5449
	stosw
5440
	call	disasm_readrmop
5450
	call	disasm_readrmop
5441
	cmp	word [disasm_string], 'cm'
5451
	cmp	word [disasm_string], 'cm'
5442
	jz	.cmp
5452
	jz	.cmp
5443
	and	byte [edi], 0
5453
	and	byte [edi], 0
5444
	ret
5454
	ret
5445
.cmp:
5455
.cmp:
5446
	call	disasm_get_byte
5456
	call	disasm_get_byte
5447
	and	eax, 7
5457
	and	eax, 7
5448
	mov	dx, 'eq'
5458
	mov	dx, 'eq'
5449
	dec	eax
5459
	dec	eax
5450
	js	@f
5460
	js	@f
5451
	mov	dx, 'lt'
5461
	mov	dx, 'lt'
5452
	jz	@f
5462
	jz	@f
5453
	mov	dh, 'e'
5463
	mov	dh, 'e'
5454
	dec	eax
5464
	dec	eax
5455
	jnz	.no2
5465
	jnz	.no2
5456
@@:
5466
@@:
5457
	xchg	dx, word [disasm_string+3]
5467
	xchg	dx, word [disasm_string+3]
5458
	mov	word [disasm_string+5], dx
5468
	mov	word [disasm_string+5], dx
5459
	and	byte [edi], 0
5469
	and	byte [edi], 0
5460
	ret
5470
	ret
5461
.no2:
5471
.no2:
5462
	dec	eax
5472
	dec	eax
5463
	jnz	@f
5473
	jnz	@f
5464
	add	edi, 2
5474
	add	edi, 2
5465
	push	edi
5475
	push	edi
5466
	lea	esi, [edi-3]
5476
	lea	esi, [edi-3]
5467
	lea	ecx, [esi-(disasm_string+8)+2]
5477
	lea	ecx, [esi-(disasm_string+8)+2]
5468
	std
5478
	std
5469
	rep	movsb
5479
	rep	movsb
5470
	cld
5480
	cld
5471
	mov	cx, word [esi-3]
5481
	mov	cx, word [esi-3]
5472
	mov	dword [esi-3], 'unor'
5482
	mov	dword [esi-3], 'unor'
5473
	mov	byte [esi+1], 'd'
5483
	mov	byte [esi+1], 'd'
5474
	mov	word [esi+2], cx
5484
	mov	word [esi+2], cx
5475
	pop	edi
5485
	pop	edi
5476
	and	byte [edi+1], 0
5486
	and	byte [edi+1], 0
5477
	ret
5487
	ret
5478
@@:
5488
@@:
5479
	mov	edx, 'neq'
5489
	mov	edx, 'neq'
5480
	dec	eax
5490
	dec	eax
5481
	jz	@f
5491
	jz	@f
5482
	mov	edx, 'nlt'
5492
	mov	edx, 'nlt'
5483
	dec	eax
5493
	dec	eax
5484
	jz	@f
5494
	jz	@f
5485
	mov	edx, 'nle'
5495
	mov	edx, 'nle'
5486
	dec	eax
5496
	dec	eax
5487
	jz	@f
5497
	jz	@f
5488
	mov	edx, 'ord'
5498
	mov	edx, 'ord'
5489
@@:
5499
@@:
5490
	push	edi
5500
	push	edi
5491
	lea	esi, [edi-1]
5501
	lea	esi, [edi-1]
5492
	lea	ecx, [esi-(disasm_string+8)+2]
5502
	lea	ecx, [esi-(disasm_string+8)+2]
5493
	std
5503
	std
5494
	rep	movsb
5504
	rep	movsb
5495
	cld
5505
	cld
5496
	mov	cx, word [esi-3]
5506
	mov	cx, word [esi-3]
5497
	mov	dword [esi-3], edx
5507
	mov	dword [esi-3], edx
5498
	mov	word [esi], cx
5508
	mov	word [esi], cx
5499
	pop	edi
5509
	pop	edi
5500
	and	byte [edi+1], 0
5510
	and	byte [edi+1], 0
5501
	ret
5511
	ret
5502
 
5512
 
5503
cpsrlw:
5513
cpsrlw:
5504
	mov	eax, 'psrl'
5514
	mov	eax, 'psrl'
5505
	jmp	@f
5515
	jmp	@f
5506
cpsraw:
5516
cpsraw:
5507
	mov	eax, 'psra'
5517
	mov	eax, 'psra'
5508
	jmp	@f
5518
	jmp	@f
5509
cpsllw:
5519
cpsllw:
5510
	mov	eax, 'psll'
5520
	mov	eax, 'psll'
5511
@@:
5521
@@:
5512
	stosd
5522
	stosd
5513
	mov	eax, 'w   '
5523
	mov	eax, 'w   '
5514
	stosd
5524
	stosd
5515
	jmp	disasm_mmx1
5525
	jmp	disasm_mmx1
5516
cpsrld:
5526
cpsrld:
5517
	mov	eax, 'psrl'
5527
	mov	eax, 'psrl'
5518
	jmp	@f
5528
	jmp	@f
5519
cpsrad:
5529
cpsrad:
5520
	mov	eax, 'psra'
5530
	mov	eax, 'psra'
5521
	jmp	@f
5531
	jmp	@f
5522
cpslld:
5532
cpslld:
5523
	mov	eax, 'psll'
5533
	mov	eax, 'psll'
5524
@@:
5534
@@:
5525
	stosd
5535
	stosd
5526
	mov	eax, 'd   '
5536
	mov	eax, 'd   '
5527
	stosd
5537
	stosd
5528
	jmp	disasm_mmx1
5538
	jmp	disasm_mmx1
5529
cpsrlq:
5539
cpsrlq:
5530
	mov	eax, 'psrl'
5540
	mov	eax, 'psrl'
5531
	jmp	@f
5541
	jmp	@f
5532
cpsllq:
5542
cpsllq:
5533
	mov	eax, 'psll'
5543
	mov	eax, 'psll'
5534
@@:
5544
@@:
5535
	stosd
5545
	stosd
5536
	mov	eax, 'q   '
5546
	mov	eax, 'q   '
5537
	stosd
5547
	stosd
5538
	jmp	disasm_mmx1
5548
	jmp	disasm_mmx1
5539
 
5549
 
5540
csse1:
5550
csse1:
5541
iglobal
5551
iglobal
5542
sse_cmds1:
5552
sse_cmds1:
5543
	db	0x2F,4,'comi'
5553
	db	0x2F,4,'comi'
5544
	db	0x54,3,'and'
5554
	db	0x54,3,'and'
5545
	db	0x55,4,'andn'
5555
	db	0x55,4,'andn'
5546
	db	0x58,3,'add'
5556
	db	0x58,3,'add'
5547
	db	0xC2,3,'cmp'
5557
	db	0xC2,3,'cmp'
5548
endg
5558
endg
5549
	mov	esi, sse_cmds1+1
5559
	mov	esi, sse_cmds1+1
5550
.1:
5560
.1:
5551
@@:
5561
@@:
5552
	movzx	edx, byte [esi]
5562
	movzx	edx, byte [esi]
5553
	cmp	al, [esi-1]
5563
	cmp	al, [esi-1]
5554
	jz	@f
5564
	jz	@f
5555
	lea	esi, [esi+edx+2]
5565
	lea	esi, [esi+edx+2]
5556
	jmp	@b
5566
	jmp	@b
5557
@@:
5567
@@:
5558
	push	ecx
5568
	push	ecx
5559
	mov	ecx, edx
5569
	mov	ecx, edx
5560
	inc	esi
5570
	inc	esi
5561
	rep	movsb
5571
	rep	movsb
5562
	pop	ecx
5572
	pop	ecx
5563
	mov	al, 's'
5573
	mov	al, 's'
5564
	cmp	byte [edi-1], 'i'
5574
	cmp	byte [edi-1], 'i'
5565
	jz	@f
5575
	jz	@f
5566
	mov	al, 'p'
5576
	mov	al, 'p'
5567
@@:
5577
@@:
5568
	stosb
5578
	stosb
5569
	mov	al, 'd'
5579
	mov	al, 'd'
5570
	test	ch, 1
5580
	test	ch, 1
5571
	jnz	@f
5581
	jnz	@f
5572
	mov	al, 's'
5582
	mov	al, 's'
5573
@@:
5583
@@:
5574
	stosb
5584
	stosb
5575
	push	ecx
5585
	push	ecx
5576
	push	5
5586
	push	5
5577
	pop	ecx
5587
	pop	ecx
5578
	sub	ecx, edx
5588
	sub	ecx, edx
5579
	adc	ecx, 1
5589
	adc	ecx, 1
5580
	mov	al, ' '
5590
	mov	al, ' '
5581
	rep	stosb
5591
	rep	stosb
5582
	pop	ecx
5592
	pop	ecx
5583
	or	ch, 1		; force XMM reg
5593
	or	ch, 1		; force XMM reg
5584
	jmp	disasm_mmx1
5594
	jmp	disasm_mmx1
5585
 
5595
 
5586
csse2:
5596
csse2:
5587
iglobal
5597
iglobal
5588
sse_cmds2:
5598
sse_cmds2:
5589
	db	0xD0,6,'addsub'
5599
	db	0xD0,6,'addsub'
5590
	db	0,0
5600
	db	0,0
5591
endg
5601
endg
5592
	test	ch, 1
5602
	test	ch, 1
5593
	jz	cerr
5603
	jz	cerr
5594
	mov	esi, sse_cmds2+1
5604
	mov	esi, sse_cmds2+1
5595
	jmp	csse1.1
5605
	jmp	csse1.1
5596
 
5606
 
5597
cpshift:
5607
cpshift:
5598
	mov	dl, al
5608
	mov	dl, al
5599
	mov	ax, 'ps'
5609
	mov	ax, 'ps'
5600
	stosw
5610
	stosw
5601
	call	disasm_get_byte
5611
	call	disasm_get_byte
5602
	push	eax
5612
	push	eax
5603
	and	al, 0xC0
5613
	and	al, 0xC0
5604
	cmp	al, 0xC0
5614
	cmp	al, 0xC0
5605
	jnz	.pop_cunk
5615
	jnz	.pop_cunk
5606
	pop	eax
5616
	pop	eax
5607
	push	eax
5617
	push	eax
5608
	shr	al, 3
5618
	shr	al, 3
5609
	and	eax, 7
5619
	and	eax, 7
5610
	cmp	al, 2
5620
	cmp	al, 2
5611
	jz	.rl
5621
	jz	.rl
5612
	cmp	al, 4
5622
	cmp	al, 4
5613
	jz	.ra
5623
	jz	.ra
5614
	cmp	al, 6
5624
	cmp	al, 6
5615
	jz	.ll
5625
	jz	.ll
5616
.pop_cunk:
5626
.pop_cunk:
5617
	pop	eax
5627
	pop	eax
5618
	jmp	cunk
5628
	jmp	cunk
5619
.ll:
5629
.ll:
5620
	mov	ax, 'll'
5630
	mov	ax, 'll'
5621
	jmp	@f
5631
	jmp	@f
5622
.rl:
5632
.rl:
5623
	mov	ax, 'rl'
5633
	mov	ax, 'rl'
5624
	jmp	@f
5634
	jmp	@f
5625
.ra:
5635
.ra:
5626
	cmp	dl, 0x73
5636
	cmp	dl, 0x73
5627
	jz	.pop_cunk
5637
	jz	.pop_cunk
5628
	mov	ax, 'ra'
5638
	mov	ax, 'ra'
5629
@@:
5639
@@:
5630
	stosw
5640
	stosw
5631
	mov	al, 'w'
5641
	mov	al, 'w'
5632
	cmp	dl, 0x71
5642
	cmp	dl, 0x71
5633
	jz	@f
5643
	jz	@f
5634
	mov	al, 'd'
5644
	mov	al, 'd'
5635
	cmp	dl, 0x72
5645
	cmp	dl, 0x72
5636
	jz	@f
5646
	jz	@f
5637
	mov	al, 'q'
5647
	mov	al, 'q'
5638
@@:
5648
@@:
5639
	stosb
5649
	stosb
5640
	mov	ax, '  '
5650
	mov	ax, '  '
5641
	stosw
5651
	stosw
5642
	stosb
5652
	stosb
5643
	pop	eax
5653
	pop	eax
5644
	and	eax, 7
5654
	and	eax, 7
5645
	call	disasm_write_mmreg
5655
	call	disasm_write_mmreg
5646
	mov	ax, ', '
5656
	mov	ax, ', '
5647
	stosw
5657
	stosw
5648
	xor	eax, eax
5658
	xor	eax, eax
5649
	call	disasm_get_byte
5659
	call	disasm_get_byte
5650
	call	disasm_write_num
5660
	call	disasm_write_num
5651
	and	byte [edi], 0
5661
	and	byte [edi], 0
5652
	ret
5662
	ret
5653
 
5663
 
5654
iglobal
5664
iglobal
5655
grp15c1	dq	'fxsave  ','fxrstor ','ldmxcsr ','stmxcsr ',0,0,0,'clflush '
5665
grp15c1	dq	'fxsave  ','fxrstor ','ldmxcsr ','stmxcsr ',0,0,0,'clflush '
5656
endg
5666
endg
5657
cgrp15:
5667
cgrp15:
5658
	call	disasm_get_byte
5668
	call	disasm_get_byte
5659
	cmp	al, 0xC0
5669
	cmp	al, 0xC0
5660
	jae	cunk
5670
	jae	cunk
5661
	shr	al, 3
5671
	shr	al, 3
5662
	and	eax, 7
5672
	and	eax, 7
5663
	mov	edx, eax
5673
	mov	edx, eax
5664
	mov	eax, dword [grp15c1+eax*8]
5674
	mov	eax, dword [grp15c1+eax*8]
5665
	test	eax, eax
5675
	test	eax, eax
5666
	jz	cerr
5676
	jz	cerr
5667
	dec	[disasm_cur_pos]
5677
	dec	[disasm_cur_pos]
5668
	stosd
5678
	stosd
5669
	mov	eax, dword [grp15c1+4+edx*8]
5679
	mov	eax, dword [grp15c1+4+edx*8]
5670
	stosd
5680
	stosd
5671
	or	ch, 40h
5681
	or	ch, 40h
5672
	call	disasm_readrmop
5682
	call	disasm_readrmop
5673
	and	byte [edi], 0
5683
	and	byte [edi], 0
5674
	ret
5684
	ret
5675
 
5685
 
5676
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5686
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5677
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5687
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5678
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5688
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5679
 
5689
 
5680
caption_str db 'Kolibri Debugger',0
5690
caption_str db 'Kolibri Debugger',0
5681
caption_len = $ - caption_str
5691
caption_len = $ - caption_str
5682
begin_str db	'Kolibri Debugger, version 0.32',10
5692
begin_str db	'Kolibri Debugger, version 0.32',10
5683
	db	'Hint: type "help" for help, "quit" for quit'
5693
	db	'Hint: type "help" for help, "quit" for quit'
5684
newline	db	10,0
5694
newline	db	10,0
5685
prompt	db	'> ',0
5695
prompt	db	'> ',0
5686
 
5696
 
5687
help_groups:
5697
help_groups:
5688
	dd	aControl, 0, 0, help_control_msg
5698
	dd	aControl, 0, 0, help_control_msg
5689
	db	0
5699
	db	0
5690
	dd	aData, 0, 0, help_data_msg
5700
	dd	aData, 0, 0, help_data_msg
5691
	db	0
5701
	db	0
5692
	dd	aBreakpoints, 0, 0, help_breaks_msg
5702
	dd	aBreakpoints, 0, 0, help_breaks_msg
5693
	db	0
5703
	db	0
5694
; flags field:
5704
; flags field:
5695
; &1: command may be called without parameters
5705
; &1: command may be called without parameters
5696
; &2: command may be called with parameters
5706
; &2: command may be called with parameters
5697
; &4: command may be called without loaded program
5707
; &4: command may be called without loaded program
5698
; &8: command may be called with loaded program
5708
; &8: command may be called with loaded program
5699
commands:
5709
commands:
5700
	dd	_aH, OnHelp, HelpSyntax, HelpHelp
5710
	dd	_aH, OnHelp, HelpSyntax, HelpHelp
5701
	db	0Fh
5711
	db	0Fh
5702
	dd	aHelp, OnHelp, HelpSyntax, HelpHelp
5712
	dd	aHelp, OnHelp, HelpSyntax, HelpHelp
5703
	db	0Fh
5713
	db	0Fh
5704
	dd	aQuit, OnQuit, QuitSyntax, QuitHelp
5714
	dd	aQuit, OnQuit, QuitSyntax, QuitHelp
5705
	db	0Dh
5715
	db	0Dh
5706
	dd	aLoad, OnLoad, LoadSyntax, LoadHelp
5716
	dd	aLoad, OnLoad, LoadSyntax, LoadHelp
5707
	db	6
5717
	db	6
5708
	dd	aReload, OnReload, ReloadSyntax, ReloadHelp
5718
	dd	aReload, OnReload, ReloadSyntax, ReloadHelp
5709
	db	0Dh
5719
	db	0Dh
5710
	dd	aTerminate, OnTerminate, TerminateSyntax, TerminateHelp
5720
	dd	aTerminate, OnTerminate, TerminateSyntax, TerminateHelp
5711
	db	9
5721
	db	9
5712
	dd	aDetach, OnDetach, DetachSyntax, DetachHelp
5722
	dd	aDetach, OnDetach, DetachSyntax, DetachHelp
5713
	db	9
5723
	db	9
5714
	dd	aSuspend, OnSuspend, SuspendSyntax, SuspendHelp
5724
	dd	aSuspend, OnSuspend, SuspendSyntax, SuspendHelp
5715
	db	9
5725
	db	9
5716
	dd	aResume, OnResume, ResumeSyntax, ResumeHelp
5726
	dd	aResume, OnResume, ResumeSyntax, ResumeHelp
5717
	db	0Bh
5727
	db	0Bh
5718
	dd	aStep, OnStep, StepSyntax, StepHelp
5728
	dd	aStep, OnStep, StepSyntax, StepHelp
5719
	db	9
5729
	db	9
5720
	dd	aProceed, OnProceed, ProceedSyntax, ProceedHelp
5730
	dd	aProceed, OnProceed, ProceedSyntax, ProceedHelp
5721
	db	9
5731
	db	9
5722
	dd	aCalc, OnCalc, CalcSyntax, CalcHelp
5732
	dd	aCalc, OnCalc, CalcSyntax, CalcHelp
5723
	db	0Eh
5733
	db	0Eh
5724
	dd	aDump, OnDump, DumpSyntax, DumpHelp
5734
	dd	aDump, OnDump, DumpSyntax, DumpHelp
5725
	db	0Bh
5735
	db	0Bh
5726
	dd	aUnassemble, OnUnassemble, UnassembleSyntax, UnassembleHelp
5736
	dd	aUnassemble, OnUnassemble, UnassembleSyntax, UnassembleHelp
5727
	db	0Bh
5737
	db	0Bh
5728
	dd	aBp, OnBp, BpSyntax, BpHelp
5738
	dd	aBp, OnBp, BpSyntax, BpHelp
5729
	db	0Ah
5739
	db	0Ah
5730
	dd	aBpm, OnBpmb, BpmSyntax, BpmHelp
5740
	dd	aBpm, OnBpmb, BpmSyntax, BpmHelp
5731
	db	0Ah
5741
	db	0Ah
5732
	dd	aBpmb, OnBpmb, BpmSyntax, BpmHelp
5742
	dd	aBpmb, OnBpmb, BpmSyntax, BpmHelp
5733
	db	0Ah
5743
	db	0Ah
5734
	dd	aBpmw, OnBpmw, BpmSyntax, BpmHelp
5744
	dd	aBpmw, OnBpmw, BpmSyntax, BpmHelp
5735
	db	0Ah
5745
	db	0Ah
5736
	dd	aBpmd, OnBpmd, BpmSyntax, BpmHelp
5746
	dd	aBpmd, OnBpmd, BpmSyntax, BpmHelp
5737
	db	0Ah
5747
	db	0Ah
5738
	dd	aBl, OnBl, BlSyntax, BlHelp
5748
	dd	aBl, OnBl, BlSyntax, BlHelp
5739
	db	0Bh
5749
	db	0Bh
5740
	dd	aBc, OnBc, BcSyntax, BcHelp
5750
	dd	aBc, OnBc, BcSyntax, BcHelp
5741
	db	0Ah
5751
	db	0Ah
5742
	dd	aBd, OnBd, BdSyntax, BdHelp
5752
	dd	aBd, OnBd, BdSyntax, BdHelp
5743
	db	0Ah
5753
	db	0Ah
5744
	dd	aBe, OnBe, BeSyntax, BeHelp
5754
	dd	aBe, OnBe, BeSyntax, BeHelp
5745
	db	0Ah
5755
	db	0Ah
5746
	dd	aReg, OnReg, RSyntax, RHelp
5756
	dd	aReg, OnReg, RSyntax, RHelp
5747
	db	0Ah
5757
	db	0Ah
5748
	dd	aUnpack, OnUnpack, UnpackSyntax, UnpackHelp
5758
	dd	aUnpack, OnUnpack, UnpackSyntax, UnpackHelp
5749
	db	9
5759
	db	9
5750
	dd	aLoadSymbols, OnLoadSymbols, LoadSymbolsSyntax, LoadSymbolsHelp
5760
	dd	aLoadSymbols, OnLoadSymbols, LoadSymbolsSyntax, LoadSymbolsHelp
5751
	db	0Ah
5761
	db	0Ah
5752
	dd	0
5762
	dd	0
5753
aHelp	db	5,'help',0
5763
aHelp	db	5,'help',0
5754
_aH	db	2,'h',0
5764
_aH	db	2,'h',0
5755
HelpHelp db	'Help on specified function',10
5765
HelpHelp db	'Help on specified function',10
5756
HelpSyntax db	'Usage: h or help [group | command]',10,0
5766
HelpSyntax db	'Usage: h or help [group | command]',10,0
5757
 
5767
 
5758
help_msg db	'List of known command groups:',10
5768
help_msg db	'List of known command groups:',10
5759
	db	'"help control"     - display list of control commands',10
5769
	db	'"help control"     - display list of control commands',10
5760
	db	'"help data"        - display list of commands concerning data',10
5770
	db	'"help data"        - display list of commands concerning data',10
5761
	db	'"help breakpoints" - display list of commands concerning breakpoints',10,0
5771
	db	'"help breakpoints" - display list of commands concerning breakpoints',10,0
5762
aControl db	8,'control',0
5772
aControl db	8,'control',0
5763
help_control_msg db	'List of control commands:',10
5773
help_control_msg db	'List of control commands:',10
5764
	db	'h = help             - help',10
5774
	db	'h = help             - help',10
5765
	db	'quit                 - exit from debugger',10
5775
	db	'quit                 - exit from debugger',10
5766
	db	'load  [params] - load program for debugging',10
5776
	db	'load  [params] - load program for debugging',10
5767
	db	'reload               - reload debugging program',10
5777
	db	'reload               - reload debugging program',10
5768
	db	'load-symbols   - load information on symbols for program',10
5778
	db	'load-symbols   - load information on symbols for program',10
5769
	db	'terminate            - terminate loaded program',10
5779
	db	'terminate            - terminate loaded program',10
5770
	db	'detach               - detach from debugging program',10
5780
	db	'detach               - detach from debugging program',10
5771
	db	'stop                 - suspend execution of debugging program',10
5781
	db	'stop                 - suspend execution of debugging program',10
5772
	db	'g []     - go on (resume execution of debugging program)',10
5782
	db	'g []     - go on (resume execution of debugging program)',10
5773
	db	's =         - program step',10
5783
	db	's =         - program step',10
5774
	db	'p =         - program wide step',10
5784
	db	'p =         - program wide step',10
5775
	db	'unpack               - try to bypass unpacker code (heuristic)',10,0
5785
	db	'unpack               - try to bypass unpacker code (heuristic)',10,0
5776
aData	db	5,'data',0
5786
aData	db	5,'data',0
5777
help_data_msg db	'List of data commands:',10
5787
help_data_msg db	'List of data commands:',10
5778
	db	'?        - calculate value of expression',10
5788
	db	'?        - calculate value of expression',10
5779
	db	'd []     - dump data at given address',10
5789
	db	'd []     - dump data at given address',10
5780
	db	'u []     - unassemble instructions at given address',10
5790
	db	'u []     - unassemble instructions at given address',10
5781
	db	'r   or',10
5791
	db	'r   or',10
5782
	db	'r = - set register value',10,0
5792
	db	'r = - set register value',10,0
5783
aBreakpoints db 12,'breakpoints',0
5793
aBreakpoints db 12,'breakpoints',0
5784
help_breaks_msg db	'List of breakpoints commands:',10
5794
help_breaks_msg db	'List of breakpoints commands:',10
5785
	db	'bp       - set breakpoint on execution',10
5795
	db	'bp       - set breakpoint on execution',10
5786
	db	'bpm[b|w|d]   - set breakpoint on memory access',10
5796
	db	'bpm[b|w|d]   - set breakpoint on memory access',10
5787
	db	'bl []        - breakpoint(s) info',10
5797
	db	'bl []        - breakpoint(s) info',10
5788
	db	'bc ...       - clear breakpoint',10
5798
	db	'bc ...       - clear breakpoint',10
5789
	db	'bd ...       - disable breakpoint',10
5799
	db	'bd ...       - disable breakpoint',10
5790
	db	'be ...       - enable breakpoint',10,0
5800
	db	'be ...       - enable breakpoint',10,0
5791
 
5801
 
5792
aQuit	db	5,'quit',0
5802
aQuit	db	5,'quit',0
5793
QuitHelp db	'Quit from debugger',10
5803
QuitHelp db	'Quit from debugger',10
5794
QuitSyntax db	'Usage: quit',10,0
5804
QuitSyntax db	'Usage: quit',10,0
5795
 
5805
 
5796
aLoad	db	5,'load',0
5806
aLoad	db	5,'load',0
5797
LoadHelp db	'Load program for debugging',10
5807
LoadHelp db	'Load program for debugging',10
5798
LoadSyntax db	'Usage: load  [parameters]',10,0
5808
LoadSyntax db	'Usage: load  [parameters]',10,0
5799
 
5809
 
5800
aReload db	7,'reload',0
5810
aReload db	7,'reload',0
5801
ReloadHelp db	'Reload debugging program (restart debug session)',10
5811
ReloadHelp db	'Reload debugging program (restart debug session)',10
5802
ReloadSyntax db	'Usage: reload',10,0
5812
ReloadSyntax db	'Usage: reload',10,0
5803
 
5813
 
5804
aTerminate db	10,'terminate',0
5814
aTerminate db	10,'terminate',0
5805
TerminateHelp db 'Terminate debugged program',10
5815
TerminateHelp db 'Terminate debugged program',10
5806
TerminateSyntax db 'Usage: terminate',10,0
5816
TerminateSyntax db 'Usage: terminate',10,0
5807
 
5817
 
5808
aDetach	db	7,'detach',0
5818
aDetach	db	7,'detach',0
5809
DetachHelp db	'Detach from debugged program',10
5819
DetachHelp db	'Detach from debugged program',10
5810
DetachSyntax db	'Usage: detach',10,0
5820
DetachSyntax db	'Usage: detach',10,0
5811
 
5821
 
5812
aSuspend db	5,'stop',0
5822
aSuspend db	5,'stop',0
5813
SuspendHelp db	'Suspend execution of debugged program',10
5823
SuspendHelp db	'Suspend execution of debugged program',10
5814
SuspendSyntax db 'Usage: stop',10,0
5824
SuspendSyntax db 'Usage: stop',10,0
5815
 
5825
 
5816
aResume db	2,'g',0
5826
aResume db	2,'g',0
5817
ResumeHelp db	'Go (resume execution of debugged program)',10
5827
ResumeHelp db	'Go (resume execution of debugged program)',10
5818
ResumeSyntax db	'Usage: g',10
5828
ResumeSyntax db	'Usage: g',10
5819
	db	'   or: g  - wait until specified address is reached',10,0
5829
	db	'   or: g  - wait until specified address is reached',10,0
5820
 
5830
 
5821
aStep	db	2,'s',0
5831
aStep	db	2,'s',0
5822
StepHelp db	'Make step in debugged program',10
5832
StepHelp db	'Make step in debugged program',10
5823
StepSyntax db	'Usage: s',10,0
5833
StepSyntax db	'Usage: s',10,0
5824
 
5834
 
5825
aProceed db	2,'p',0
5835
aProceed db	2,'p',0
5826
ProceedHelp db	'Make wide step in debugged program (step over CALL, REPxx, LOOP)',10
5836
ProceedHelp db	'Make wide step in debugged program (step over CALL, REPxx, LOOP)',10
5827
ProceedSyntax db 'Usage: p',10,0
5837
ProceedSyntax db 'Usage: p',10,0
5828
 
5838
 
5829
aDump	db	2,'d',0
5839
aDump	db	2,'d',0
5830
DumpHelp db	'Dump data of debugged program',10
5840
DumpHelp db	'Dump data of debugged program',10
5831
DumpSyntax db	'Usage: d  - dump data at specified address',10
5841
DumpSyntax db	'Usage: d  - dump data at specified address',10
5832
	db	'   or: d              - continue current dump',10,0
5842
	db	'   or: d              - continue current dump',10,0
5833
 
5843
 
5834
aCalc	db	2,'?',0
5844
aCalc	db	2,'?',0
5835
CalcHelp db	'Calculate value of expression',10
5845
CalcHelp db	'Calculate value of expression',10
5836
CalcSyntax db	'Usage: ? ',10,0
5846
CalcSyntax db	'Usage: ? ',10,0
5837
 
5847
 
5838
aUnassemble db	2,'u',0
5848
aUnassemble db	2,'u',0
5839
UnassembleHelp db 'Unassemble',10
5849
UnassembleHelp db 'Unassemble',10
5840
UnassembleSyntax:
5850
UnassembleSyntax:
5841
	db	'Usage: u  - unassemble instructions at specified address',10
5851
	db	'Usage: u  - unassemble instructions at specified address',10
5842
	db	'   or: u              - continue current unassemble screen',10,0
5852
	db	'   or: u              - continue current unassemble screen',10,0
5843
 
5853
 
5844
aReg	db	2,'r',0
5854
aReg	db	2,'r',0
5845
RHelp	db	'Set register value',10
5855
RHelp	db	'Set register value',10
5846
RSyntax:
5856
RSyntax:
5847
	db	'Usage: r  ',10
5857
	db	'Usage: r  ',10
5848
	db	'   or: r = - set value of  to ',10,0
5858
	db	'   or: r = - set value of  to ',10,0
5849
 
5859
 
5850
aBp	db	3,'bp',0
5860
aBp	db	3,'bp',0
5851
BpHelp	db	'set BreakPoint on execution',10
5861
BpHelp	db	'set BreakPoint on execution',10
5852
BpSyntax db	'Usage: bp ',10,0
5862
BpSyntax db	'Usage: bp ',10,0
5853
 
5863
 
5854
aBpm	db	4,'bpm',0
5864
aBpm	db	4,'bpm',0
5855
aBpmb	db	5,'bpmb',0
5865
aBpmb	db	5,'bpmb',0
5856
aBpmw	db	5,'bpmw',0
5866
aBpmw	db	5,'bpmw',0
5857
aBpmd	db	5,'bpmd',0
5867
aBpmd	db	5,'bpmd',0
5858
BpmHelp	db	'set BreakPoint on Memory access',10
5868
BpmHelp	db	'set BreakPoint on Memory access',10
5859
	db	'Maximum 4 breakpoints of this type are allowed',10
5869
	db	'Maximum 4 breakpoints of this type are allowed',10
5860
	db	'Note that for this breaks debugger is activated after access',10
5870
	db	'Note that for this breaks debugger is activated after access',10
5861
BpmSyntax db	'Usage: bpmb [w] ',10
5871
BpmSyntax db	'Usage: bpmb [w] ',10
5862
	db	'       bpmw [w] ',10
5872
	db	'       bpmw [w] ',10
5863
	db	'       bpmd [w] ',10
5873
	db	'       bpmd [w] ',10
5864
	db	'       bpm is synonym for bpmd',10
5874
	db	'       bpm is synonym for bpmd',10
5865
	db	'"w" means break only on writes (default is on read/write)',10,0
5875
	db	'"w" means break only on writes (default is on read/write)',10,0
5866
 
5876
 
5867
aBl	db	3,'bl',0
5877
aBl	db	3,'bl',0
5868
BlHelp	db	'Breakpoint List',10
5878
BlHelp	db	'Breakpoint List',10
5869
BlSyntax db	'Usage: bl          - list all breakpoints',10
5879
BlSyntax db	'Usage: bl          - list all breakpoints',10
5870
	db	'       bl  - display info on particular breakpoint',10,0
5880
	db	'       bl  - display info on particular breakpoint',10,0
5871
 
5881
 
5872
aBc	db	3,'bc',0
5882
aBc	db	3,'bc',0
5873
BcHelp	db	'Breakpoint Clear',10
5883
BcHelp	db	'Breakpoint Clear',10
5874
BcSyntax db	'Usage: bc ',10
5884
BcSyntax db	'Usage: bc ',10
5875
	db	'Examples: bc 2',10
5885
	db	'Examples: bc 2',10
5876
	db	'          bc 1 3 4 A',10,0
5886
	db	'          bc 1 3 4 A',10,0
5877
 
5887
 
5878
aBd	db	3,'bd',0
5888
aBd	db	3,'bd',0
5879
BdHelp	db	'Breakpoint Disable',10
5889
BdHelp	db	'Breakpoint Disable',10
5880
BdSyntax db	'Usage: bd ',10
5890
BdSyntax db	'Usage: bd ',10
5881
	db	'Examples: bd 2',10
5891
	db	'Examples: bd 2',10
5882
	db	'          bd 1 3 4 A',10,0
5892
	db	'          bd 1 3 4 A',10,0
5883
 
5893
 
5884
aBe	db	3,'be',0
5894
aBe	db	3,'be',0
5885
BeHelp	db	'Breakpoint Enable',10
5895
BeHelp	db	'Breakpoint Enable',10
5886
BeSyntax db	'Usage: be ',10
5896
BeSyntax db	'Usage: be ',10
5887
	db	'Examples: be 2',10
5897
	db	'Examples: be 2',10
5888
	db	'          be 1 3 4 A',10,0
5898
	db	'          be 1 3 4 A',10,0
5889
 
5899
 
5890
aUnpack	db	7,'unpack',0
5900
aUnpack	db	7,'unpack',0
5891
UnpackHelp db	'Try to bypass unpacker code',10
5901
UnpackHelp db	'Try to bypass unpacker code',10
5892
UnpackSyntax db	'Usage: unpack',10,0
5902
UnpackSyntax db	'Usage: unpack',10,0
5893
 
5903
 
5894
aLoadSymbols db	13,'load-symbols',0
5904
aLoadSymbols db	13,'load-symbols',0
5895
LoadSymbolsHelp db 'Load symbolic information for executable',10
5905
LoadSymbolsHelp db 'Load symbolic information for executable',10
5896
LoadSymbolsSyntax db 'Usage: load-symbols ',10,0
5906
LoadSymbolsSyntax db 'Usage: load-symbols ',10,0
5897
 
5907
 
5898
aUnknownCommand db 'Unknown command',10,0
5908
aUnknownCommand db 'Unknown command',10,0
5899
 
5909
 
5900
load_err_msg	db	'Cannot load program. ',0
5910
load_err_msg	db	'Cannot load program. ',0
5901
unk_err_msg	db	'Unknown error code -%4X',10,0
5911
unk_err_msg	db	'Unknown error code -%4X',10,0
5902
aCannotLoadFile	db	'Cannot load file. ',0
5912
aCannotLoadFile	db	'Cannot load file. ',0
5903
unk_err_msg2	db	'Unknown error code %4X.',10,0
5913
unk_err_msg2	db	'Unknown error code %4X.',10,0
5904
load_err_msgs:
5914
load_err_msgs:
5905
	dd	.1, 0, .3, 0, .5, .6, 0, 0, .9, .A, 0, 0, 0, 0, 0, 0
5915
	dd	.1, 0, .3, 0, .5, .6, 0, 0, .9, .A, 0, 0, 0, 0, 0, 0
5906
	dd	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .1E, .1F, .20
5916
	dd	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .1E, .1F, .20
5907
.1		db	'HD undefined.',10,0
5917
.1		db	'HD undefined.',10,0
5908
.3		db	'Unknown FS.',10,0
5918
.3		db	'Unknown FS.',10,0
5909
.5		db	'File not found.',10,0
5919
.5		db	'File not found.',10,0
5910
.6		db	'Unexpected EOF.',10,0
5920
.6		db	'Unexpected EOF.',10,0
5911
.9		db	'FAT table corrupted.',10,0
5921
.9		db	'FAT table corrupted.',10,0
5912
.A		db	'Access denied.',10,0
5922
.A		db	'Access denied.',10,0
5913
.1E		db	'No memory.',10,0
5923
.1E		db	'No memory.',10,0
5914
.1F		db	'Not Menuet/Kolibri executable.',10,0
5924
.1F		db	'Not Menuet/Kolibri executable.',10,0
5915
.20		db	'Too many processes.',10,0
5925
.20		db	'Too many processes.',10,0
5916
load_succ_msg	db	'Program loaded successfully! PID=%4X. Use "g" to run.',10,0
5926
load_succ_msg	db	'Program loaded successfully! PID=%4X. Use "g" to run.',10,0
5917
need_debuggee	db	'No program loaded. Use "load" command.',10,0
5927
need_debuggee	db	'No program loaded. Use "load" command.',10,0
5918
aAlreadyLoaded	db	'Program is already loaded. Use "terminate" or "detach" commands',10,0
5928
aAlreadyLoaded	db	'Program is already loaded. Use "terminate" or "detach" commands',10,0
5919
terminated_msg	db	'Program terminated.',10,0
5929
terminated_msg	db	'Program terminated.',10,0
5920
aException	db	'Debugged program caused an exception %2X. '
5930
aException	db	'Debugged program caused an exception %2X. '
5921
aSuspended	db	'Suspended',10,0
5931
aSuspended	db	'Suspended',10,0
5922
aContinued	db	'Continuing',10,0
5932
aContinued	db	'Continuing',10,0
5923
aRunningErr	db	'Program is running',10,0
5933
aRunningErr	db	'Program is running',10,0
5924
read_mem_err	db	'ERROR: cannot read process memory!!!',10,0
5934
read_mem_err	db	'ERROR: cannot read process memory!!!',10,0
5925
aBreakpointLimitExceeded db 'Breakpoint limit exceeded',10,0
5935
aBreakpointLimitExceeded db 'Breakpoint limit exceeded',10,0
5926
aBreakErr	db	'Cannot activate breakpoint, it will be disabled',10,0
5936
aBreakErr	db	'Cannot activate breakpoint, it will be disabled',10,0
5927
aDuplicateBreakpoint db	'Duplicate breakpoint',10,0
5937
aDuplicateBreakpoint db	'Duplicate breakpoint',10,0
5928
aInvalidBreak	db	'Invalid breakpoint number',10,0
5938
aInvalidBreak	db	'Invalid breakpoint number',10,0
5929
OnBeErrMsg	db	'There is already enabled breakpoint on this address',10,0
5939
OnBeErrMsg	db	'There is already enabled breakpoint on this address',10,0
5930
aBreakNum	db	'%2X: at %8X',0
5940
aBreakNum	db	'%2X: at %8X',0
5931
aMemBreak1	db	'%2X: on ',0
5941
aMemBreak1	db	'%2X: on ',0
5932
aMemBreak2	db	'read from ',0
5942
aMemBreak2	db	'read from ',0
5933
aMemBreak3	db	'access of ',0
5943
aMemBreak3	db	'access of ',0
5934
aMemBreak4	db	'byte',0
5944
aMemBreak4	db	'byte',0
5935
aMemBreak5	db	'word',0
5945
aMemBreak5	db	'word',0
5936
aMemBreak6	db	'dword',0
5946
aMemBreak6	db	'dword',0
5937
aMemBreak7	db	' at %8X',0
5947
aMemBreak7	db	' at %8X',0
5938
aOneShot	db	', one-shot',0
5948
aOneShot	db	', one-shot',0
5939
aDisabled	db	', disabled',0
5949
aDisabled	db	', disabled',0
5940
aBreakStop	db	'Breakpoint #%2X',10,0
5950
aBreakStop	db	'Breakpoint #%2X',10,0
5941
aUserBreak	db	'int3 command at %8X',10,0
5951
aUserBreak	db	'int3 command at %8X',10,0
5942
;dbgmsg_str	db	'Debug message for process %4X.',10,0
5952
;dbgmsg_str	db	'Debug message for process %4X.',10,0
5943
aInvAddr	db	'Invalid address',10,0
5953
aInvAddr	db	'Invalid address',10,0
5944
NoPrgLoaded_str	db	'No program loaded'
5954
NoPrgLoaded_str	db	'No program loaded'
5945
NoPrgLoaded_len = $ - NoPrgLoaded_str
5955
NoPrgLoaded_len = $ - NoPrgLoaded_str
5946
aRunning	db	'Running'
5956
aRunning	db	'Running'
5947
aPaused		db	'Paused'
5957
aPaused		db	'Paused'
5948
aPoint		db	0x1C
5958
aPoint		db	0x1C
5949
aMinus		db	'-'
5959
aMinus		db	'-'
5950
aColon		db	':'
5960
aColon		db	':'
5951
aSpace		db	' '
5961
aSpace		db	' '
5952
aQuests		db	'??'
5962
aQuests		db	'??'
5953
aDots		db	'...'
5963
aDots		db	'...'
5954
aParseError	db	'Parse error',10,0
5964
aParseError	db	'Parse error',10,0
5955
aDivByZero	db	'Division by 0',10,0
5965
aDivByZero	db	'Division by 0',10,0
5956
calc_string	db	'%8X',10,0
5966
calc_string	db	'%8X',10,0
5957
aNoMemory	db	'No memory',10,0
5967
aNoMemory	db	'No memory',10,0
5958
aSymbolsLoaded	db	'Symbols loaded',10,0
5968
aSymbolsLoaded	db	'Symbols loaded',10,0
5959
aUnaligned	db	'Unaligned address',10,0
5969
aUnaligned	db	'Unaligned address',10,0
5960
aEnabledBreakErr db	'Enabled breakpoints are not allowed',10,0
5970
aEnabledBreakErr db	'Enabled breakpoints are not allowed',10,0
5961
aInterrupted	db	'Interrupted',10,0
5971
aInterrupted	db	'Interrupted',10,0
5962
aUnpacked	db	'Unpacked successful!',10,0
5972
aUnpacked	db	'Unpacked successful!',10,0
5963
aPacked1	db	'Program is probably packed with ',0
5973
aPacked1	db	'Program is probably packed with ',0
5964
aPacked2	db	'.',10,'Try to unpack automatically? [y/n]: ',0
5974
aPacked2	db	'.',10,'Try to unpack automatically? [y/n]: ',0
5965
aY_str		db	'y',10,0
5975
aY_str		db	'y',10,0
5966
aN_str		db	'n',10,0
5976
aN_str		db	'n',10,0
5967
mxp_nrv_name	db	'mxp_nrv',0
5977
mxp_nrv_name	db	'mxp_nrv',0
5968
mxp_name	db	'mxp',0
5978
mxp_name	db	'mxp',0
5969
mxp_lzo_name	db	'mxp_lzo',0
5979
mxp_lzo_name	db	'mxp_lzo',0
5970
mtappack_name	db	'mtappack',0
5980
mtappack_name	db	'mtappack',0
5971
flags		db	'CPAZSDO'
5981
flags		db	'CPAZSDO'
5972
flags_bits	db	0,2,4,6,7,10,11
5982
flags_bits	db	0,2,4,6,7,10,11
5973
regs_strs:
5983
regs_strs:
5974
	db	'EAX='
5984
	db	'EAX='
5975
	db	'EBX='
5985
	db	'EBX='
5976
	db	'ECX='
5986
	db	'ECX='
5977
	db	'EDX='
5987
	db	'EDX='
5978
	db	'ESI='
5988
	db	'ESI='
5979
	db	'EDI='
5989
	db	'EDI='
5980
	db	'EBP='
5990
	db	'EBP='
5981
	db	'ESP='
5991
	db	'ESP='
5982
	db	'EIP='
5992
	db	'EIP='
5983
	db	'EFLAGS='
5993
	db	'EFLAGS='
5984
 
5994
 
5985
debuggee_pid	dd	0
5995
debuggee_pid	dd	0
5986
bSuspended	db	0
5996
bSuspended	db	0
5987
bAfterGo	db	0
5997
bAfterGo	db	0
5988
temp_break	dd	0
5998
temp_break	dd	0
5989
 
5999
 
5990
disasm_table_1:
6000
disasm_table_1:
5991
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 0x
6001
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 0x
5992
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cF
6002
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cF
5993
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 1x
6003
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0		; 1x
5994
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0
6004
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cop0,  cop0
5995
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cseges,cop0		; 2x
6005
	dd	cop22, cop22, cop22, cop22, cop21, cop21, cseges,cop0		; 2x
5996
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegcs,cop0
6006
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegcs,cop0
5997
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegss,cop0		; 3x
6007
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegss,cop0		; 3x
5998
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegds,cop0
6008
	dd	cop22, cop22, cop22, cop22, cop21, cop21, csegds,cop0
5999
	dd	cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1		; 4x
6009
	dd	cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1, cinc1		; 4x
6000
	dd	cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1
6010
	dd	cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1, cdec1
6001
	dd	cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1		; 5x
6011
	dd	cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1,cpush1		; 5x
6002
	dd	cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1
6012
	dd	cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1, cpop1
6003
	dd	cop0,  cop0,  cbound,carpl, csegfs,cseggs,c66,   c67		; 6x
6013
	dd	cop0,  cop0,  cbound,carpl, csegfs,cseggs,c66,   c67		; 6x
6004
	dd	cpush21,cimul1,cpush22,cimul1,cunk,cunk,  cunk,  cunk
6014
	dd	cpush21,cimul1,cpush22,cimul1,cunk,cunk,  cunk,  cunk
6005
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1		; 7x
6015
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1		; 7x
6006
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1
6016
	dd	cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1, cjcc1
6007
	dd	cop23, cop23, cop23, cop23, cop22, cop22, cop22, cop22		; 8x
6017
	dd	cop23, cop23, cop23, cop23, cop22, cop22, cop22, cop22		; 8x
6008
	dd	cop22, cop22, cop22, cop22, cunk,  cop22, cunk,  cpop2
6018
	dd	cop22, cop22, cop22, cop22, cunk,  cop22, cunk,  cpop2
6009
	dd	cop0,  cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1		; 9x
6019
	dd	cop0,  cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1,cxchg1		; 9x
6010
	dd	ccbw,  ccwd,  ccallf,cop0,  cop0,  cop0,  cop0,  cop0
6020
	dd	ccbw,  ccwd,  ccallf,cop0,  cop0,  cop0,  cop0,  cop0
6011
	dd	cmov3, cmov3, cmov3, cmov3, cop0,  cop0,  cop0,  cop0		; Ax
6021
	dd	cmov3, cmov3, cmov3, cmov3, cop0,  cop0,  cop0,  cop0		; Ax
6012
	dd	cop21, cop21, cop0,  cop0,  cop0,  cop0,  cop0,  cop0
6022
	dd	cop21, cop21, cop0,  cop0,  cop0,  cop0,  cop0,  cop0
6013
	dd	cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11		; Bx
6023
	dd	cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11,cmov11		; Bx
6014
	dd	cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12
6024
	dd	cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12,cmov12
6015
	dd	cshift1,cshift1,cret2,cop0, cunk,  cunk,  cmov2, cmov2		; Cx
6025
	dd	cshift1,cshift1,cret2,cop0, cunk,  cunk,  cmov2, cmov2		; Cx
6016
	dd	center,cop0,  cunk,  cunk,  cop0,  cint,  cunk,  cunk
6026
	dd	center,cop0,  cunk,  cunk,  cop0,  cint,  cunk,  cunk
6017
	dd	cshift2,cshift2,cshift3,cshift3,caam,caad,cunk,  cxlat		; Dx
6027
	dd	cshift2,cshift2,cshift3,cshift3,caam,caad,cunk,  cxlat		; Dx
6018
	dd	cD8,   cD9,   cDA,   cDB,   cDC,   cDD,   cDE,   cDF
6028
	dd	cD8,   cD9,   cDA,   cDB,   cDC,   cDD,   cDE,   cDF
6019
	dd	cloopnz,cloopz,cloop,cjcxz, cunk,  cunk,  cunk,  cunk		; Ex
6029
	dd	cloopnz,cloopz,cloop,cjcxz, cunk,  cunk,  cunk,  cunk		; Ex
6020
	dd	ccall1,cjmp1, cunk,  cjmp2, cunk,  cunk,  cunk,  cunk
6030
	dd	ccall1,cjmp1, cunk,  cjmp2, cunk,  cunk,  cunk,  cunk
6021
	dd	clock, cunk,  crepnz,crep,  cunk,  cop0,  cop1,  cop1		; Fx
6031
	dd	clock, cunk,  crepnz,crep,  cunk,  cop0,  cop1,  cop1		; Fx
6022
	dd	cop0,  cop0,  cop0,  cop0,  cop0,  cop0,  cop1,  cop1
6032
	dd	cop0,  cop0,  cop0,  cop0,  cop0,  cop0,  cop1,  cop1
6023
 
6033
 
6024
disasm_table_2:
6034
disasm_table_2:
6025
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cop0_F,cop0_F,cunk		; 0x
6035
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cop0_F,cop0_F,cunk		; 0x
6026
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6036
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6027
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 1x
6037
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 1x
6028
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6038
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6029
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 2x
6039
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk		; 2x
6030
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  csse1
6040
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  csse1
6031
	dd	cunk,  crdtsc,cunk,  cunk,  cop0_F,cunk,  cunk,  cunk		; 3x
6041
	dd	cunk,  crdtsc,cunk,  cunk,  cop0_F,cunk,  cunk,  cunk		; 3x
6032
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6042
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6033
	dd	cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc		; 4x
6043
	dd	cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc		; 4x
6034
	dd	cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc
6044
	dd	cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc,cmovcc
6035
	dd	cunk,  cunk,  cunk,  cunk,  csse1, csse1, cunk,  cunk		; 5x
6045
	dd	cunk,  cunk,  cunk,  cunk,  csse1, csse1, cunk,  cunk		; 5x
6036
	dd	csse1, cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6046
	dd	csse1, cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cunk
6037
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn		; 6x
6047
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn		; 6x
6038
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cunk,  cunk,  cmovd1,cmovq1
6048
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cunk,  cunk,  cmovd1,cmovq1
6039
	dd	cunk,  cpshift,cpshift,cpshift,cpcmn,cpcmn,cpcmn,cemms		; 7x
6049
	dd	cunk,  cpshift,cpshift,cpshift,cpcmn,cpcmn,cpcmn,cemms		; 7x
6040
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cmovd2,cmovq2
6050
	dd	cunk,  cunk,  cunk,  cunk,  cunk,  cunk,  cmovd2,cmovq2
6041
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2		; 8x
6051
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2		; 8x
6042
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2
6052
	dd	cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2, cjcc2
6043
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc		; 9x
6053
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc		; 9x
6044
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc
6054
	dd	csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc,csetcc
6045
	dd	cunk,  cunk,  ccpuid,cbtx2, cshld, cshld, cunk,  cunk		; Ax
6055
	dd	cunk,  cunk,  ccpuid,cbtx2, cshld, cshld, cunk,  cunk		; Ax
6046
	dd	cunk,  cunk,  cunk,  cbtx2, cshrd, cshrd, cgrp15,cop22
6056
	dd	cunk,  cunk,  cunk,  cbtx2, cshrd, cshrd, cgrp15,cop22
6047
	dd	ccmpxchg,ccmpxchg,cunk,cbtx2,cunk, cunk,  cmovzx,cmovzx		; Bx
6057
	dd	ccmpxchg,ccmpxchg,cunk,cbtx2,cunk, cunk,  cmovzx,cmovzx		; Bx
6048
	dd	cunk,  cunk,  cbtx1, cbtx2, cbsf,  cbsr,  cmovsx,cmovsx
6058
	dd	cunk,  cunk,  cbtx1, cbtx2, cbsf,  cbsr,  cmovsx,cmovsx
6049
	dd	cunk,  cunk,  csse1, cunk,  cunk,  cunk,  cunk,  ccmpxchg8b	; Cx
6059
	dd	cunk,  cunk,  csse1, cunk,  cunk,  cunk,  cunk,  ccmpxchg8b	; Cx
6050
	dd	cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap
6060
	dd	cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap,cbswap
6051
	dd	csse2, cpsrlw,cpsrlw,cpsrlq,cpcmn, cpcmn, cunk,  cunk		; Dx
6061
	dd	csse2, cpsrlw,cpsrlw,cpsrlq,cpcmn, cpcmn, cunk,  cunk		; Dx
6052
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn
6062
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn
6053
	dd	cpcmn, cpsraw,cpsrad,cpcmn, cpcmn, cpcmn, cunk,  cunk		; Ex
6063
	dd	cpcmn, cpsraw,cpsrad,cpcmn, cpcmn, cpcmn, cunk,  cunk		; Ex
6054
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn
6064
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn
6055
	dd	cunk,  cpsllw,cpslld,cpsllq,cpcmn, cpcmn, cpcmn, cunk		; Fx
6065
	dd	cunk,  cpsllw,cpslld,cpsllq,cpcmn, cpcmn, cpcmn, cunk		; Fx
6056
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cunk
6066
	dd	cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cpcmn, cunk
6057
 
6067
 
6058
reg_table:
6068
reg_table:
6059
	db	2,'al',0
6069
	db	2,'al',0
6060
	db	2,'cl',1
6070
	db	2,'cl',1
6061
	db	2,'dl',2
6071
	db	2,'dl',2
6062
	db	2,'bl',3
6072
	db	2,'bl',3
6063
	db	2,'ah',4
6073
	db	2,'ah',4
6064
	db	2,'ch',5
6074
	db	2,'ch',5
6065
	db	2,'dh',6
6075
	db	2,'dh',6
6066
	db	2,'bh',7
6076
	db	2,'bh',7
6067
	db	2,'ax',8
6077
	db	2,'ax',8
6068
	db	2,'cx',9
6078
	db	2,'cx',9
6069
	db	2,'dx',10
6079
	db	2,'dx',10
6070
	db	2,'bx',11
6080
	db	2,'bx',11
6071
	db	2,'sp',12
6081
	db	2,'sp',12
6072
	db	2,'bp',13
6082
	db	2,'bp',13
6073
	db	2,'si',14
6083
	db	2,'si',14
6074
	db	2,'di',15
6084
	db	2,'di',15
6075
	db	3,'eax',16
6085
	db	3,'eax',16
6076
	db	3,'ecx',17
6086
	db	3,'ecx',17
6077
	db	3,'edx',18
6087
	db	3,'edx',18
6078
	db	3,'ebx',19
6088
	db	3,'ebx',19
6079
	db	3,'esp',20
6089
	db	3,'esp',20
6080
	db	3,'ebp',21
6090
	db	3,'ebp',21
6081
	db	3,'esi',22
6091
	db	3,'esi',22
6082
	db	3,'edi',23
6092
	db	3,'edi',23
6083
	db	3,'eip',24
6093
	db	3,'eip',24
6084
	db	0
6094
	db	0
6085
 
6095
 
6086
IncludeIGlobals
6096
IncludeIGlobals
6087
 
6097
 
6088
fn70_read_block:
6098
fn70_read_block:
6089
	dd	0
6099
	dd	0
6090
	dq	0
6100
	dq	0
6091
	dd	?
6101
	dd	?
6092
	dd	?
6102
	dd	?
6093
	db	0
6103
	db	0
6094
	dd	?
6104
	dd	?
6095
 
6105
 
6096
fn70_attr_block:
6106
fn70_attr_block:
6097
	dd	5
6107
	dd	5
6098
	dd	0,0,0
6108
	dd	0,0,0
6099
	dd	fileattr
6109
	dd	fileattr
6100
	db	0
6110
	db	0
6101
	dd	?
6111
	dd	?
6102
 
6112
 
6103
fn70_load_block:
6113
fn70_load_block:
6104
	dd	7
6114
	dd	7
6105
	dd	1
6115
	dd	1
6106
load_params dd	0
6116
load_params dd	0
6107
	dd	0
6117
	dd	0
6108
	dd	0
6118
	dd	0
6109
i_end:
6119
i_end:
6110
loadname:
6120
loadname:
6111
	db	0
6121
	db	0
6112
	rb	255
6122
	rb	255
6113
 
6123
 
6114
symbolsfile	rb	260
6124
symbolsfile	rb	260
6115
 
6125
 
6116
prgname_ptr dd ?
6126
prgname_ptr dd ?
6117
prgname_len dd ?
6127
prgname_len dd ?
6118
 
6128
 
6119
IncludeUGlobals
6129
IncludeUGlobals
6120
 
6130
 
6121
dbgwnd		dd	?
6131
dbgwnd		dd	?
6122
 
6132
 
6123
messages	rb	messages_height*messages_width
6133
messages	rb	messages_height*messages_width
6124
messages_pos	dd	?
6134
messages_pos	dd	?
6125
 
6135
 
6126
cmdline		rb	cmdline_width+1
6136
cmdline		rb	cmdline_width+1
6127
cmdline_len	dd	?
6137
cmdline_len	dd	?
6128
cmdline_pos	dd	?
6138
cmdline_pos	dd	?
6129
curarg		dd	?
6139
curarg		dd	?
6130
 
6140
 
6131
was_temp_break	db	?
6141
was_temp_break	db	?
6132
 
6142
 
6133
dbgbufsize	dd	?
6143
dbgbufsize	dd	?
6134
dbgbuflen	dd	?
6144
dbgbuflen	dd	?
6135
dbgbuf		rb	256
6145
dbgbuf		rb	256
6136
 
6146
 
6137
fileattr	rb	40
6147
fileattr	rb	40
6138
 
6148
 
6139
needzerostart:
6149
needzerostart:
6140
 
6150
 
6141
context:
6151
context:
6142
_eip	dd	?
6152
_eip	dd	?
6143
_eflags	dd	?
6153
_eflags	dd	?
6144
_eax	dd	?
6154
_eax	dd	?
6145
_ecx	dd	?
6155
_ecx	dd	?
6146
_edx	dd	?
6156
_edx	dd	?
6147
_ebx	dd	?
6157
_ebx	dd	?
6148
_esp	dd	?
6158
_esp	dd	?
6149
_ebp	dd	?
6159
_ebp	dd	?
6150
_esi	dd	?
6160
_esi	dd	?
6151
_edi	dd	?
6161
_edi	dd	?
6152
 
6162
 
6153
oldcontext rb $-context
6163
oldcontext rb $-context
6154
 
6164
 
6155
dumpread dd	?
6165
dumpread dd	?
6156
dumppos dd	?
6166
dumppos dd	?
6157
dumpdata rb	dump_height*10h
6167
dumpdata rb	dump_height*10h
6158
 
6168
 
6159
; breakpoint structure:
6169
; breakpoint structure:
6160
; dword +0: address
6170
; dword +0: address
6161
; byte +4: flags
6171
; byte +4: flags
6162
; bit 0: 1 <=> breakpoint valid
6172
; bit 0: 1 <=> breakpoint valid
6163
; bit 1: 1 <=> breakpoint disabled
6173
; bit 1: 1 <=> breakpoint disabled
6164
; bit 2: 1 <=> one-shot breakpoint
6174
; bit 2: 1 <=> one-shot breakpoint
6165
; bit 3: 1 <=> DRx breakpoint
6175
; bit 3: 1 <=> DRx breakpoint
6166
; byte +5: overwritten byte
6176
; byte +5: overwritten byte
6167
;          for DRx breaks: flags + (index shl 6)
6177
;          for DRx breaks: flags + (index shl 6)
6168
breakpoints_n = 256
6178
breakpoints_n = 256
6169
breakpoints	rb	breakpoints_n*6
6179
breakpoints	rb	breakpoints_n*6
6170
drx_break	rd	4
6180
drx_break	rd	4
6171
 
6181
 
6172
disasm_buf_size		dd	?
6182
disasm_buf_size		dd	?
6173
 
6183
 
6174
symbols		dd	?
6184
symbols		dd	?
6175
num_symbols	dd	?
6185
num_symbols	dd	?
6176
 
6186
 
6177
bReload			db	?
6187
bReload			db	?
6178
 
6188
 
6179
needzeroend:
6189
needzeroend:
6180
 
6190
 
6181
disasm_buffer		rb	256
6191
disasm_buffer		rb	256
6182
disasm_start_pos	dd	?
6192
disasm_start_pos	dd	?
6183
disasm_cur_pos		dd	?
6193
disasm_cur_pos		dd	?
6184
disasm_cur_str		dd	?
6194
disasm_cur_str		dd	?
6185
disasm_string		rb	256
6195
disasm_string		rb	256
6186
 
6196
 
6187
i_param		rb	256
6197
i_param		rb	256
6188
 
6198
 
6189
; stack
6199
; stack
6190
	align	400h
6200
	align	400h
6191
	rb	400h
6201
	rb	400h
6192
used_mem:
6202
used_mem: