Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9353 | leency | 1 | ;----------------------------------------------------------------------------- |
2 | OS = 0 |
||
3 | Loader = 1 |
||
4 | ;----------------------------------------------------------------------------- |
||
5 | SkipAddr = 8 |
||
6 | ;----------------------------------------------------------------------------- |
||
7 | Bitness equ 32 |
||
8 | ;----------------------------------------------------------------------------- |
||
9 | include "globals!.inc" |
||
10 | include "fasm\fasm.asm" |
||
11 | include "disasm\disasm32.asm" |
||
12 | if ~OS |
||
13 | include "loadmap.inc" |
||
14 | end if |
||
15 | include "assemble.inc" |
||
16 | ;----------------------------------------------------------------------------- |
||
17 | xglobal |
||
18 | even 16 |
||
19 | StdMemStr rb 4*1024 |
||
20 | StdMemEnd: |
||
21 | AddMemStr rb 4*1024 |
||
22 | AddMemEnd: |
||
23 | endg |
||
24 | ;----------------------------------------------------------------------------- |
||
25 | uglobal |
||
26 | even 16 |
||
27 | Inst TInstruction |
||
28 | even 16 |
||
29 | DefInst TInstruction |
||
30 | endg |
||
31 | ;----------------------------------------------------------------------------- |
||
32 | virtual at 0 |
||
33 | dq ? |
||
34 | sizeof.dq = $ |
||
35 | end virtual |
||
36 | ;---------------------------------------; |
||
37 | JccCalls: ; |
||
38 | seto al ; 0 |
||
39 | ret ; |
||
40 | setno al ; 1 |
||
41 | ret ; |
||
42 | setc al ; 2 |
||
43 | ret ; |
||
44 | setnc al ; 3 |
||
45 | ret ; |
||
46 | setz al ; 4 |
||
47 | ret ; |
||
48 | setnz al ; 5 |
||
49 | ret ; |
||
50 | setbe al ; 6 |
||
51 | ret ; |
||
52 | seta al ; 7 |
||
53 | ret ; |
||
54 | sets al ; 8 |
||
55 | ret ; |
||
56 | setns al ; 9 |
||
57 | ret ; |
||
58 | setpe al ; A |
||
59 | ret ; |
||
60 | setpo al ; B |
||
61 | ret ; |
||
62 | setl al ; C |
||
63 | ret ; |
||
64 | setge al ; D |
||
65 | ret ; |
||
66 | setle al ; E |
||
67 | ret ; |
||
68 | setg al ; F |
||
69 | ret ; |
||
70 | ;----------------------------------------------------------------------------- |
||
71 | ShowCPU: |
||
72 | mov [XPos],3 |
||
73 | mov [YPos],0 |
||
74 | mov edx,Msg00 |
||
75 | call PrintS |
||
76 | movzx edx,[CPUType] |
||
77 | cmp dl,6 |
||
78 | jb @F |
||
79 | mov dl,6 |
||
80 | @@: |
||
81 | lea edx,[CPUTable+rdx*4] |
||
82 | jmp PrintS |
||
83 | ;----------------------------------------------------------------------------- |
||
84 | ShowFPU: |
||
85 | movzx edx,[CPUType] |
||
86 | cmp dl,6 |
||
87 | jb @F |
||
88 | mov dl,6 |
||
89 | @@: |
||
90 | lea edx,[FPUTable+rdx*8] |
||
91 | jmp PrintS |
||
92 | ;----------------------------------------------------------------------------- |
||
93 | DetectCPU: |
||
94 | mov dl,1 |
||
95 | push sp |
||
96 | pop ax |
||
97 | cmp ax,sp |
||
98 | jnz .RetCPU |
||
99 | inc edx |
||
100 | pushfw |
||
101 | pop ax |
||
102 | mov cx,ax |
||
103 | xor ah,40h |
||
104 | push ax |
||
105 | popfw |
||
106 | pushfw |
||
107 | pop ax |
||
108 | push cx |
||
109 | popfw |
||
110 | xor ah,ch |
||
111 | jz .RetCPU |
||
112 | inc edx |
||
113 | pushfd |
||
114 | pop eax |
||
115 | mov ecx,eax |
||
116 | btc eax,18 |
||
117 | push eax |
||
118 | popfd |
||
119 | pushfd |
||
120 | pop eax |
||
121 | push ecx |
||
122 | popfd |
||
123 | xor eax,ecx |
||
124 | jz .RetCPU |
||
125 | inc edx |
||
126 | mov eax,ecx |
||
127 | btc eax,21 |
||
128 | push eax |
||
129 | popfd |
||
130 | pushfd |
||
131 | pop eax |
||
132 | push ecx |
||
133 | popfd |
||
134 | xor eax,ecx |
||
135 | jz .RetCPU |
||
136 | inc edx |
||
137 | xor eax,eax |
||
138 | cpuid |
||
139 | test eax,eax |
||
140 | jz .RetCPU |
||
141 | xor eax,eax |
||
142 | inc eax |
||
143 | cpuid |
||
144 | mov dl,ah |
||
145 | and dl,0Fh |
||
146 | .RetCPU:ret |
||
147 | ;----------------------------------------------------------------------------- |
||
148 | DetectFPU: |
||
149 | xor eax,eax |
||
150 | push ax |
||
151 | mov ebp,esp |
||
152 | fninit |
||
153 | fnstcw word [ebp] |
||
154 | mov dx,[ebp] |
||
155 | cmp dh,03h |
||
156 | jnz .Done ; done: no FPU present |
||
157 | inc eax |
||
158 | and word [ebp],0FF7Fh |
||
159 | wait |
||
160 | fldcw word [ebp] |
||
161 | fdisi |
||
162 | fstcw word [ebp] |
||
163 | wait |
||
164 | test byte [ebp],0080h |
||
165 | jnz .Done ; done: 8087 is present |
||
166 | inc eax |
||
167 | fninit |
||
168 | wait |
||
169 | fld1 |
||
170 | wait |
||
171 | fldz |
||
172 | wait |
||
173 | fdivp st1,st0 |
||
174 | wait |
||
175 | fld st0 |
||
176 | wait |
||
177 | fchs |
||
178 | wait |
||
179 | fcompp |
||
180 | wait |
||
181 | fnstsw ax |
||
182 | wait |
||
183 | fnclex |
||
184 | wait |
||
185 | sahf |
||
186 | jz .Done ; done: 80287 is present |
||
187 | inc eax |
||
188 | mov ah,[CPUType] |
||
189 | cmp ah,4 |
||
190 | jb .Done ; done: 80387 is present |
||
191 | mov al,ah ; done: 80487+ (build-in) |
||
192 | .Done: or al,al |
||
193 | jz .Exit |
||
194 | mov ecx,8 |
||
195 | .Loop: fldz ; set ST(0) to ST(7) to +ZERO |
||
196 | loop .Loop |
||
197 | finit ; reinitialize FPU |
||
198 | .Exit: pop dx |
||
199 | ret |
||
200 | ;----------------------------------------------------------------------------- |
||
201 | ClearCmdLine: |
||
202 | mov [XPos],1 |
||
203 | mov [YPos],MinHeight-1 |
||
204 | mov [Color],7 |
||
205 | mov al,32 |
||
206 | mov ecx,[CurWidth] |
||
207 | sub ecx,2 |
||
208 | .Loop: call PrintC |
||
209 | loop .Loop |
||
210 | ret |
||
211 | ;----------------------------------------------------------------------------- |
||
212 | PrintCmdLine: |
||
213 | call ClearCmdLine |
||
214 | mov [XPos],1 |
||
215 | lea edx,[Msg50] |
||
216 | jmp PrintS |
||
217 | ;----------------------------------------------------------------------------- |
||
218 | Decode: push rax rcx rsi rdi |
||
219 | xor ecx,ecx |
||
220 | mov [Origin],rsi |
||
221 | mov rdi,rsi |
||
222 | @@: |
||
223 | mov rsi,rdi |
||
224 | add rsi,rcx |
||
225 | call GetDataByte |
||
226 | mov [rcx+BufferI],al |
||
227 | inc ecx |
||
228 | cmp cl,15 |
||
229 | jb @B |
||
230 | pop rdi rsi rcx rax |
||
231 | pushad |
||
232 | mov [DefInst.Addr],BufferI |
||
233 | mov [TheBufferO],BufferO |
||
234 | call DisAsmLine |
||
235 | mov [rsp+1Ch],rax |
||
236 | popad |
||
237 | add rsi,rax |
||
238 | ret |
||
239 | DisAsmLine: |
||
240 | push rbp |
||
241 | mov al,[CodeType] |
||
242 | mov ah,0 |
||
243 | cmp al,16 |
||
244 | jz @F |
||
245 | mov ah,1 |
||
246 | cmp al,32 |
||
247 | jz @F |
||
248 | mov ah,2 |
||
249 | @@: |
||
250 | mov [DefInst.Arch],ah |
||
251 | mov [DefInst.Emulated],-1 ;# |
||
252 | lea ebp,[Inst+128] |
||
253 | mov ecx,sizeof.TInstruction |
||
254 | lea esi,[DefInst] |
||
255 | lea edi,[Inst] |
||
256 | rep movsb |
||
257 | mov [SpaceSize],8 |
||
258 | call DisAsm |
||
259 | push rax |
||
260 | call PrnAsm |
||
261 | pop rax |
||
262 | pop rbp |
||
263 | ret |
||
264 | ;----------------------------------------------------------------------------- |
||
265 | ShowText: |
||
266 | MakeText: |
||
267 | xor ebp,ebp |
||
268 | mov [CPUXPtr],ebp |
||
269 | mov rsi,[CodeAddr] |
||
270 | mov [AddrBuffer],rsi |
||
271 | mov [YPos],0 |
||
272 | .Loop: mov [Color],30h |
||
273 | mov [BufferO-1],byte 30h ;Default Color |
||
274 | inc [YPos] |
||
275 | mov [XPos],1 |
||
276 | call Decode |
||
277 | mov eax,[_EIP] |
||
278 | inc ebp |
||
279 | cmp [AddrBuffer+(rbp-1)*sizeof.dq],rax |
||
280 | jnz .1 |
||
281 | mov [CPUXPtr],ebp |
||
282 | mov [BufferO+SkipAddr+1],byte 10h ;'>>' |
||
283 | cmp [Inst.IsAddress],0 |
||
284 | je .1 |
||
285 | call CheckJump |
||
286 | cmp [JumpTaken],0 |
||
287 | jz .1 |
||
288 | mov [BufferO+SkipAddr+2*16+1],byte 18h |
||
289 | mov rax,[Inst.Arg1.Imm] |
||
290 | cmp rax,rsi |
||
291 | jbe .1 |
||
292 | .0: mov [BufferO+SkipAddr+2*16+1],byte 19h |
||
293 | |||
294 | .1: mov [AddrBuffer+rbp*sizeof.dq],rsi |
||
295 | lea edx,[BufferO] |
||
296 | cmp byte [rdx-1],30h |
||
297 | jnz .2 |
||
298 | mov ax,'+' |
||
299 | xchg ax,[rdx+9+9] |
||
300 | cmp al,32 |
||
301 | ifz mov [rdx+9+9],al |
||
302 | call PrintS |
||
303 | add edx,9+15*2 |
||
304 | jmp .3 |
||
305 | .2: mov eax,edx |
||
306 | .N: cmp [eax],byte 32 |
||
307 | jz .F |
||
308 | inc eax |
||
309 | jmp .N |
||
310 | .F: mov [rax],byte 0 |
||
311 | sub eax,edx |
||
312 | cmp eax,(MinWidth-2) |
||
313 | jbe .X |
||
314 | mov [rdx+(MinWidth-2)],byte 0 |
||
315 | .X: add edx,43 |
||
316 | mov [Color],30h |
||
317 | mov [XPos],9+15*2-(9+9)+3 |
||
318 | call PrintS |
||
319 | sub edx,43 |
||
320 | mov al,[rdx-1] |
||
321 | mov [Color],al |
||
322 | mov [XPos],1 |
||
323 | .3: call PrintS |
||
324 | mov rax,[AddrBuffer+(rbp-1)*sizeof.dq] |
||
325 | call BChk |
||
326 | cmp ebp,28 |
||
327 | jb .Loop |
||
328 | ret |
||
329 | ;----------------------------------------------------------------------------- |
||
330 | BChk: push rbp rbx rcx rsi rdi |
||
331 | xor ebp,ebp |
||
332 | .001: cmp [DrXBreak+rbp*4],eax |
||
333 | jnz .NotFound |
||
334 | push rax |
||
335 | mov esi,1 |
||
336 | movzx edi,[YPos] |
||
337 | mov ecx,[CurWidth] |
||
338 | sub ecx,25 |
||
339 | mov ax,7F00h |
||
340 | call Cursor |
||
341 | mov eax,ebp ; EBP = breakpoint number |
||
342 | shl eax,16 |
||
343 | add eax,60306023h ; show #X (X=BrkPnt) |
||
344 | add esi,ecx ; adjust X-pos |
||
345 | push rdx |
||
346 | mov edx,[CurWidth] |
||
347 | add edx,edx |
||
348 | imul edx,edi |
||
349 | lea esi,[rdx+rsi*2] |
||
350 | add esi,ConsoleDataPtr |
||
351 | mov [rsi],eax |
||
352 | pop rdx |
||
353 | pop rax |
||
354 | .NotFound: |
||
355 | inc ebp |
||
356 | cmp ebp,4 |
||
357 | jnz .001 |
||
358 | |||
359 | push rax |
||
360 | call FindEnabledBreakPoint;FindBreakPoint |
||
361 | inc eax |
||
362 | jz .NoFound2 |
||
363 | mov esi,1 |
||
364 | movzx edi,[YPos] |
||
365 | mov ecx,[CurWidth] |
||
366 | sub ecx,21 |
||
367 | mov ax,7F00h |
||
368 | call Cursor |
||
369 | .NoFound2: |
||
370 | pop rax |
||
371 | |||
372 | pop rdi rsi rcx rbx rbp |
||
373 | ret |
||
374 | ;----------------------------------------------------------------------------- |
||
375 | CheckJump: |
||
376 | pushf |
||
377 | push rax rdx |
||
378 | pushf |
||
379 | and dword [rsp],$FFFFF700 |
||
380 | mov eax,[_EFL] |
||
381 | and eax,000008FFh |
||
382 | or [rsp],eax |
||
383 | mov rax,[Inst.SaveRSI] |
||
384 | movzx edx,byte [rax-2] |
||
385 | movzx eax,byte [rax-1] |
||
386 | mov [JumpTaken],ah ;ah=0 |
||
387 | cmp al,0xE8 |
||
388 | jz .2 |
||
389 | cmp al,0xE9 |
||
390 | jz .2 |
||
391 | cmp al,0xEB |
||
392 | jz .2 |
||
393 | cmp al,0xE0 ;LOOPNZ |
||
394 | jz .3 |
||
395 | cmp al,0xE1 ;LOOPZ |
||
396 | jz .4 |
||
397 | cmp al,0xE2 ;LOOP |
||
398 | jz .5 |
||
399 | cmp al,0xE3 ;JxCXZ |
||
400 | jz .6 |
||
401 | and al,7Fh ;70-7F |
||
402 | cmp al,0Fh ;0F80-0F8F |
||
403 | jbe .1 |
||
404 | sub al,70h |
||
405 | .1: |
||
406 | popf |
||
407 | lea eax,[JccCalls+rax*4] |
||
408 | call rax |
||
409 | mov [JumpTaken],al |
||
410 | pop rdx rax |
||
411 | popf |
||
412 | ret |
||
413 | .2: |
||
414 | mov [JumpTaken],1 |
||
415 | popf |
||
416 | pop rdx rax |
||
417 | popf |
||
418 | ret |
||
419 | .3: |
||
420 | popf |
||
421 | call JccCalls+5*4 |
||
422 | mov [JumpTaken],al |
||
423 | call TypeLoop |
||
424 | pop rdx rax |
||
425 | popf |
||
426 | ret |
||
427 | .4: |
||
428 | popf |
||
429 | call JccCalls+4*4 |
||
430 | mov [JumpTaken],al |
||
431 | call TypeLoop |
||
432 | pop rdx rax |
||
433 | popf |
||
434 | ret |
||
435 | .5: |
||
436 | popf |
||
437 | call TypeLoop |
||
438 | pop rdx rax |
||
439 | popf |
||
440 | ret |
||
441 | .6: |
||
442 | popf |
||
443 | call TypeJxCXZ |
||
444 | pop rdx rax |
||
445 | popf |
||
446 | ret |
||
447 | ;----------------------------------------------------------------------------- |
||
448 | TypeJxCXZ: |
||
449 | cmp [CodeType],32 |
||
450 | jz JCXZ32 |
||
451 | cmp [CodeType],16 |
||
452 | jz JCXZ16 |
||
453 | if %B=64 |
||
454 | cmp dl,67h |
||
455 | jnz .1 |
||
456 | cmp [Reg.ECX],0 |
||
457 | jmp .2 |
||
458 | .1: cmp [Reg.RCX],0 |
||
459 | .2: setz [JumpTaken] |
||
460 | end if |
||
461 | ret |
||
462 | ;----------------------------------------------------------------------------- |
||
463 | JCXZ16: cmp dl,67h |
||
464 | jz .1 |
||
465 | cmp word [_ECX],0 |
||
466 | setz [JumpTaken] |
||
467 | jmp .2 |
||
468 | .1: cmp [_ECX],0 |
||
469 | setz [JumpTaken] |
||
470 | .2: ret |
||
471 | ;----------------------------------------------------------------------------- |
||
472 | JCXZ32: cmp dl,67h |
||
473 | jz .1 |
||
474 | cmp [_ECX],0 |
||
475 | setz [JumpTaken] |
||
476 | jmp .2 |
||
477 | .1: cmp word [_ECX],0 |
||
478 | setz [JumpTaken] |
||
479 | .2: ret |
||
480 | ;----------------------------------------------------------------------------- |
||
481 | TypeLoop: |
||
482 | cmp [CodeType],32 |
||
483 | jz .32 |
||
484 | cmp [CodeType],16 |
||
485 | jz .16 |
||
486 | if %B=64 |
||
487 | mov rax,[_RCX] |
||
488 | cmp dl,67h ; check for ECX or RCX == 0 |
||
489 | jnz .1X |
||
490 | mov eax,eax |
||
491 | .1X: dec rax |
||
492 | setnz al |
||
493 | or [JumpTaken],al |
||
494 | end if |
||
495 | ret |
||
496 | .32: mov eax,[_ECX] |
||
497 | cmp dl,67h ; check for CX or ECX == 0 |
||
498 | jnz .1Y |
||
499 | movzx eax,ax |
||
500 | .1Y: dec eax |
||
501 | setnz al |
||
502 | or [JumpTaken],al |
||
503 | ret |
||
504 | .16: mov eax,[_ECX] |
||
505 | cmp dl,67h ; check for CX or ECX == 0 |
||
506 | jz .1Z |
||
507 | movzx eax,ax |
||
508 | .1Z: dec eax |
||
509 | setnz al |
||
510 | or [JumpTaken],al |
||
511 | ret |
||
512 | ;----------------------------------------------------------------------------- |
||
513 | CPUCursor: |
||
514 | mov esi,[CPUXPos] |
||
515 | mov edi,[CPUYPos] |
||
516 | mov ecx,[CurWidth] |
||
517 | sub ecx,23 |
||
518 | mov ax,2F00h |
||
519 | call Cursor |
||
520 | mov eax,[CPUYPos] |
||
521 | mov rsi,[(rax-1)*sizeof.dq+AddrBuffer] |
||
522 | call Decode |
||
523 | call ShowAddress |
||
524 | ret |
||
525 | ;----------------------------------------------------------------------------- |
||
526 | RegCursor: |
||
527 | mov esi,[RegXPos] |
||
528 | mov edi,[RegYPos] |
||
529 | mov ecx,[RegLDat] |
||
530 | jmp CursorXY |
||
531 | ;----------------------------------------------------------------------------- |
||
532 | MemCursor: |
||
533 | mov esi,[MemXPos] |
||
534 | mov edi,[MemYPos] |
||
535 | mov ecx,2 |
||
536 | mov ax,2F00h |
||
537 | jmp Cursor |
||
538 | ;----------------------------------------------------------------------------- |
||
539 | StkCursor: |
||
540 | mov esi,[StkXPos] |
||
541 | mov edi,[StkYPos] |
||
542 | mov ecx,20 |
||
543 | mov ax,2F00h |
||
544 | jmp Cursor |
||
545 | ;----------------------------------------------------------------------------- |
||
546 | CursorXY: |
||
547 | pushad |
||
548 | mov eax,[CurWidth] |
||
549 | add eax,eax |
||
550 | imul eax,edi |
||
551 | lea esi,[rax+rsi*2] |
||
552 | add esi,ConsoleDataPtr |
||
553 | .Loop: mov al,[rsi+1] |
||
554 | cmp al,17h |
||
555 | jz .1 |
||
556 | cmp al,1Fh |
||
557 | jz .2 |
||
558 | cmp al,30h |
||
559 | jz .3 |
||
560 | cmp al,3Fh |
||
561 | jz .4 |
||
562 | jmp .Next |
||
563 | .1: mov al,3Fh |
||
564 | jmp .Next |
||
565 | .2: mov al,30h |
||
566 | jmp .Next |
||
567 | .3: mov al,1Fh |
||
568 | jmp .Next |
||
569 | .4: mov al,17h |
||
570 | .Next: mov [rsi+1],al |
||
571 | add esi,2 |
||
572 | dec cl |
||
573 | jnz .Loop |
||
574 | popad |
||
575 | ret |
||
576 | ;----------------------------------------------------------------------------- |
||
577 | Cursor: push rcx rdx rsi |
||
578 | mov edx,eax |
||
579 | mov eax,[CurWidth] |
||
580 | add eax,eax |
||
581 | imul eax,edi |
||
582 | xchg edx,eax |
||
583 | lea esi,[rdx+rsi*2] |
||
584 | add esi,ConsoleDataPtr |
||
585 | .Loop: xor [rsi],ax |
||
586 | add esi,2 |
||
587 | dec cl |
||
588 | jnz .Loop |
||
589 | pop rsi rdx rcx |
||
590 | ret |
||
591 | ;----------------------------------------------------------------------------- |
||
592 | ShowCursor: |
||
593 | mov ebp,CursorTab |
||
594 | GotoWindow: |
||
595 | mov ebx,[CurrentWindow] |
||
596 | and ebx,3 |
||
597 | jmp dword [rbp+rbx*4] |
||
598 | ;----------------------------------------------------------------------------- |
||
599 | WindowSwitch: |
||
600 | test [CtrlState],3 |
||
601 | jz .1 |
||
602 | dec [CurrentWindow] |
||
603 | jmp .2 |
||
604 | .1: inc [CurrentWindow] |
||
605 | .2: and [CurrentWindow],3 |
||
606 | xor eax,eax |
||
607 | WinSwitch: |
||
608 | mov [AfterKey],1 |
||
609 | call ShowImage |
||
610 | mov ebp,WindowTab |
||
611 | jmp GotoWindow |
||
612 | ;----------------------------------------------------------------------------- |
||
613 | DrawChar: |
||
614 | mov [rdi+rdx*2],ax |
||
615 | inc edx |
||
616 | ret |
||
617 | ;----------------------------------------------------------------------------- |
||
618 | DrawLine: |
||
619 | mov [rdi+rdx*2],ax |
||
620 | inc edx |
||
621 | loop DrawLine |
||
622 | ret |
||
623 | ;----------------------------------------------------------------------------- |
||
624 | DrawDown: |
||
625 | mov [rdi+rdx*2],ax |
||
626 | add edx,[CurWidth] |
||
627 | loop DrawDown |
||
628 | ret |
||
629 | ;----------------------------------------------------------------------------- |
||
630 | PrintAL:push rdi |
||
631 | mov edi,HexBuf |
||
632 | call MakeHex |
||
633 | lea edi,[rdi+6] |
||
634 | jmp PrintHex |
||
635 | ;----------------------------------------------------------------------------- |
||
636 | PrintAX:push rdi |
||
637 | mov edi,HexBuf |
||
638 | call MakeHex |
||
639 | lea edi,[rdi+4] |
||
640 | jmp PrintHex |
||
641 | ;----------------------------------------------------------------------------- |
||
642 | PrintEAX: |
||
643 | push rdi |
||
644 | mov edi,HexBuf |
||
645 | call MakeHex |
||
646 | PrintHex: |
||
647 | push rdx |
||
648 | mov edx,edi |
||
649 | call PrintS |
||
650 | pop rdx rdi |
||
651 | ret |
||
652 | ;----------------------------------------------------------------------------- |
||
653 | MakeHex:push rax rdx rsi |
||
654 | mov edx,3 |
||
655 | .Loop: mov esi,eax |
||
656 | and eax,$FF |
||
657 | mov ax,[rax*2+HexString] |
||
658 | mov [rdi+rdx*2],ax |
||
659 | mov eax,esi |
||
660 | shr eax,8 |
||
661 | sub edx,1 |
||
662 | jnc .Loop |
||
663 | pop rsi rdx rax |
||
664 | ret |
||
665 | ;----------------------------------------------------------------------------- |
||
666 | DrawFrame: |
||
667 | mov ah,3Fh ; color |
||
668 | mov edi,ConsoleDataPtr |
||
669 | xor edx,edx |
||
670 | xor ecx,ecx |
||
671 | |||
672 | mov al, 'É' |
||
673 | call DrawChar |
||
674 | mov al, 'Í' |
||
675 | mov cl,byte [CurWidth] |
||
676 | sub cl,2 |
||
677 | call DrawLine |
||
678 | mov al, '»' |
||
679 | call DrawChar |
||
680 | |||
681 | mov al, 'º' ; left border |
||
682 | mov edx,[CurWidth] |
||
683 | mov cl,byte [CurHeight] |
||
684 | sub cl,2 |
||
685 | call DrawDown |
||
686 | mov al, 'È' |
||
687 | call DrawChar |
||
688 | mov al, 'º' ; right border |
||
689 | imul edx,[CurWidth],2 |
||
690 | dec edx |
||
691 | mov cl,byte [CurHeight] |
||
692 | sub cl,2 |
||
693 | call DrawDown |
||
694 | mov al, '¼' |
||
695 | call DrawChar |
||
696 | |||
697 | mov al, 'Ç' |
||
698 | imul edx,[CurWidth],29 |
||
699 | call DrawChar |
||
700 | mov al, 'Ä' |
||
701 | mov cl,byte [CurWidth] |
||
702 | sub cl,2 |
||
703 | call DrawLine |
||
704 | mov al, '¶' |
||
705 | call DrawChar |
||
706 | |||
707 | mov al, 'Ç' |
||
708 | imul edx,[CurWidth],40 |
||
709 | call DrawChar |
||
710 | mov al, 'Ä' |
||
711 | mov cl,byte [CurWidth] |
||
712 | sub cl,(2+45) |
||
713 | call DrawLine |
||
714 | mov al, '´' |
||
715 | call DrawChar |
||
716 | |||
717 | mov al, 'Ç' |
||
718 | imul edx,[CurWidth],49 |
||
719 | call DrawChar |
||
720 | mov al, 'Ä' |
||
721 | mov cl,byte [CurWidth] |
||
722 | sub cl,2 |
||
723 | call DrawLine |
||
724 | mov al, '¶' |
||
725 | call DrawChar |
||
726 | |||
727 | mov al, 'Â' |
||
728 | imul edx,[CurWidth],30 |
||
729 | sub edx,46 |
||
730 | call DrawChar |
||
731 | imul edx,[CurWidth],31 |
||
732 | sub edx,46 |
||
733 | mov al, '³' |
||
734 | mov cl,10 |
||
735 | call DrawDown |
||
736 | |||
737 | imul edx,[CurWidth],40 |
||
738 | sub edx,46 |
||
739 | mov al, '³' |
||
740 | mov cl,10 |
||
741 | call DrawDown |
||
742 | |||
743 | mov al, 'Ã' |
||
744 | imul edx,[CurWidth],46 |
||
745 | sub edx,46 |
||
746 | call DrawChar |
||
747 | mov al, 'Ä' |
||
748 | mov cl,44 |
||
749 | call DrawLine |
||
750 | mov al, '¶' |
||
751 | call DrawChar |
||
752 | mov al, 'Ñ' |
||
753 | mov edx,[CurWidth] |
||
754 | sub edx,22 |
||
755 | call DrawChar |
||
756 | |||
757 | mov al, '³' |
||
758 | imul edx,[CurWidth],2 |
||
759 | sub edx,22 |
||
760 | mov cl,28 |
||
761 | call DrawDown |
||
762 | mov al, 'Á' |
||
763 | call DrawChar |
||
764 | |||
765 | mov al, 'Ã' |
||
766 | imul edx,[CurWidth],42 |
||
767 | sub edx,46 |
||
768 | call DrawChar |
||
769 | mov al, 'Ä' |
||
770 | mov cl,44 |
||
771 | call DrawLine |
||
772 | mov al, '¶' |
||
773 | call DrawChar |
||
774 | |||
775 | mov al, 'Ã' |
||
776 | imul edx,[CurWidth],34 |
||
777 | sub edx,46 |
||
778 | call DrawChar |
||
779 | mov al, 'Ä' |
||
780 | mov cl,44 |
||
781 | call DrawLine |
||
782 | mov al, '¶' |
||
783 | call DrawChar |
||
784 | |||
785 | mov al, 'Ã' |
||
786 | imul edx,[CurWidth],38 |
||
787 | sub edx,46 |
||
788 | call DrawChar |
||
789 | mov al, 'Ä' |
||
790 | mov cl,44 |
||
791 | call DrawLine |
||
792 | mov al, '¶' |
||
793 | call DrawChar |
||
794 | mov al, '´' |
||
795 | imul edx,[CurWidth],41 |
||
796 | sub edx,46 |
||
797 | call DrawChar |
||
798 | mov al, 'Á' |
||
799 | imul edx,[CurWidth],50 |
||
800 | sub edx,46 |
||
801 | call DrawChar |
||
802 | if 1 |
||
803 | mov al, 'Ç' |
||
804 | imul edx,[CurWidth],MinHeight-2-(MSG_HEIGHT-1)-1 |
||
805 | call DrawChar |
||
806 | mov al, 'Ä' |
||
807 | mov cl,byte [CurWidth] |
||
808 | sub cl,2 |
||
809 | call DrawLine |
||
810 | mov al, '¶' |
||
811 | call DrawChar |
||
812 | end if |
||
813 | mov [Color],3Ah |
||
814 | call ShowCPU |
||
815 | call ShowFPU |
||
816 | mov [Color],3Ah |
||
817 | mov [XPos],3 |
||
818 | mov [YPos],29 |
||
819 | lea edx,[Msg10] |
||
820 | call PrintS |
||
821 | mov [Color],30h |
||
822 | mov [XPos],1 |
||
823 | inc [YPos] |
||
824 | lea edx,[Msg11] |
||
825 | call PrintS |
||
826 | mov [XPos],1 |
||
827 | inc [YPos] |
||
828 | lea edx,[Msg12] |
||
829 | call PrintS |
||
830 | mov [XPos],1 |
||
831 | inc [YPos] |
||
832 | lea edx,[Msg13] |
||
833 | call PrintS |
||
834 | mov [XPos],1 |
||
835 | inc [YPos] |
||
836 | lea edx,[Msg14] |
||
837 | call PrintS |
||
838 | mov [XPos],1 |
||
839 | inc [YPos] |
||
840 | lea edx,[Msg15] |
||
841 | call PrintS |
||
842 | mov [XPos],1 |
||
843 | inc [YPos] |
||
844 | lea edx,[Msg16] |
||
845 | call PrintS |
||
846 | mov [XPos],1 |
||
847 | inc [YPos] |
||
848 | lea edx,[Msg17] |
||
849 | call PrintS |
||
850 | mov [XPos],1 |
||
851 | inc [YPos] |
||
852 | lea edx,[Msg18] |
||
853 | call PrintS |
||
854 | mov [XPos],1 |
||
855 | inc [YPos] |
||
856 | lea edx,[Msg19] |
||
857 | call PrintS |
||
858 | mov [XPos],1 |
||
859 | inc [YPos] |
||
860 | lea edx,[Msg20] |
||
861 | call PrintS |
||
862 | mov [XPos],3 |
||
863 | inc [YPos] |
||
864 | mov [Color],3Ah |
||
865 | lea edx,[Msg21] |
||
866 | call PrintS |
||
867 | mov eax,[CurWidth] |
||
868 | sub eax,43 |
||
869 | mov [XPos],al |
||
870 | mov [YPos],29 |
||
871 | lea edx,[MsgX2] |
||
872 | call PrintS |
||
873 | mov eax,[CurWidth] |
||
874 | sub eax,43 |
||
875 | mov [XPos],al |
||
876 | mov [YPos],33 |
||
877 | lea edx,[MsgX3] |
||
878 | call PrintS |
||
879 | mov eax,[CurWidth] |
||
880 | sub eax,43 |
||
881 | mov [XPos],al |
||
882 | mov [YPos],37 |
||
883 | lea edx,[MsgX4] |
||
884 | call PrintS |
||
885 | mov eax,[CurWidth] |
||
886 | sub eax,43 |
||
887 | mov [XPos],al |
||
888 | mov [YPos],41 |
||
889 | lea edx,[Msg22] |
||
890 | call PrintS |
||
891 | mov eax,[CurWidth] |
||
892 | sub eax,43 |
||
893 | mov [XPos],al |
||
894 | mov [YPos],45 |
||
895 | lea edx,[Msg23] |
||
896 | call PrintS |
||
897 | mov eax,[CurWidth] |
||
898 | sub eax,19 |
||
899 | mov [XPos],al |
||
900 | mov [YPos],0 |
||
901 | lea edx,[Msg30] |
||
902 | call PrintS |
||
903 | mov [XPos],3 |
||
904 | mov [YPos],MinHeight-2-(MSG_HEIGHT-1)-1 |
||
905 | lea edx,[Msg3M] |
||
906 | call PrintS |
||
907 | mov eax,[CurWidth] |
||
908 | sub eax,51-23 |
||
909 | mov [XPos],al |
||
910 | mov [YPos],MinHeight-2-(MSG_HEIGHT-1)-1 |
||
911 | lea edx,[Msg40] |
||
912 | call PrintS |
||
913 | |||
914 | cmp [DebuggeePID],0 |
||
915 | jz .Exit |
||
916 | |||
917 | call MakeText |
||
918 | btr dword [AfterKey],0 |
||
919 | jc .0 |
||
920 | |||
921 | cmp [CPUXPtr],0 |
||
922 | jnz .1 |
||
923 | mov eax,[_EIP] |
||
924 | mov [CodeAddr],rax |
||
925 | mov [CPUYPos],1 |
||
926 | .0: |
||
927 | mov ebx,28 ;dY |
||
928 | mov ecx,[CurWidth] ;\dX |
||
929 | sub ecx,23 ;/ |
||
930 | mov esi,1 ;X |
||
931 | mov edi,1 ;Y |
||
932 | mov edx,3F203F20h |
||
933 | call ClearWindow |
||
934 | call MakeText |
||
935 | jmp .2 |
||
936 | .1: mov eax,[CPUXPtr] |
||
937 | mov [CPUYPos],eax |
||
938 | mov rsi,[AddrBuffer+(rax-1)*sizeof.dq] |
||
939 | call Decode |
||
940 | call ShowAddress |
||
941 | .2: |
||
942 | call ShowRegs |
||
943 | call ShowData |
||
944 | call ShowCursor |
||
945 | .Exit: |
||
946 | mov eax,PrintCmdLine |
||
947 | cmp [CmdLineActive],0 |
||
948 | ifnz mov eax,DrawCmdLine |
||
949 | call eax |
||
950 | |||
951 | mov edx,Messages |
||
952 | push MSG_WIDTH |
||
953 | pop esi |
||
954 | xor ecx,ecx |
||
955 | @@: |
||
956 | mov eax,MinHeight-2-(MSG_HEIGHT-1) |
||
957 | add eax,ecx |
||
958 | mov [XPos],1 |
||
959 | mov [YPos],al |
||
960 | mov [Color],8Fh |
||
961 | xor ebp,ebp |
||
962 | .Loop: |
||
963 | mov al,[rdx+rbp] |
||
964 | cmp al,8 |
||
965 | jnz .NoColor |
||
966 | inc ebp |
||
967 | mov al,[rdx+rbp] |
||
968 | mov [Color],al |
||
969 | jmp .Next |
||
970 | .NoColor: |
||
971 | call PrintC |
||
972 | .Next: |
||
973 | inc ebp |
||
974 | cmp ebp,MSG_WIDTH |
||
975 | jnz .Loop |
||
976 | inc ecx |
||
977 | add edx,esi |
||
978 | cmp edx,Messages+MSG_WIDTH*MSG_HEIGHT |
||
979 | jb @B |
||
980 | |||
981 | mov esi,[PrgNamePtr] |
||
982 | mov edi,HeaderE-61 |
||
983 | mov ecx,60 |
||
984 | @@: |
||
985 | lodsb |
||
986 | stosb |
||
987 | or al,al |
||
988 | loopnz @B |
||
989 | |||
990 | mov eax,71 |
||
991 | mov ebx,2 |
||
992 | mov dl,1 ;CP866 |
||
993 | mov ecx,HeaderN |
||
994 | cmp [DebuggeePID],0 |
||
995 | jz @F |
||
996 | mov ecx,HeaderY |
||
997 | @@: int 40h |
||
998 | ret |
||
999 | ;----------------------------------------------------------------------------- |
||
1000 | ShowRegs: |
||
1001 | call ShowGRegs |
||
1002 | call ShowSRegs |
||
1003 | call ShowXRegs |
||
1004 | call ShowSlide |
||
1005 | if 0 |
||
1006 | jmp ShowMode |
||
1007 | else |
||
1008 | ret |
||
1009 | end if |
||
1010 | ;----------------------------------------------------------------------------- |
||
1011 | PrintC: push rax rdx rdi rbx |
||
1012 | mov bl,byte [CurWidth] |
||
1013 | mov bh,byte [CurHeight] |
||
1014 | cmp al,09h |
||
1015 | jz .09 |
||
1016 | cmp al,0Ah |
||
1017 | jz .0A |
||
1018 | cmp al,0Dh |
||
1019 | jz .0D |
||
1020 | ; |
||
1021 | mov edi,eax |
||
1022 | movzx eax,[YPos] |
||
1023 | mul [CurWidth] |
||
1024 | movzx edx,[XPos] |
||
1025 | add edx,eax |
||
1026 | mov eax,edi |
||
1027 | mov edi,ConsoleDataPtr |
||
1028 | ; |
||
1029 | mov ah,[Color] |
||
1030 | mov [rdi+rdx*2],ax |
||
1031 | inc [XPos] |
||
1032 | cmp [XPos],bl |
||
1033 | jb .Done |
||
1034 | mov [XPos],0 |
||
1035 | jmp .0A |
||
1036 | .0D: pop rbx rdi rdx rax |
||
1037 | mov [XPos],ah |
||
1038 | ret |
||
1039 | .09: and [XPos],$F8 |
||
1040 | add [XPos],8 |
||
1041 | cmp [XPos],bl |
||
1042 | jb .Done |
||
1043 | sub [XPos],bl |
||
1044 | .0A: inc [YPos] |
||
1045 | cmp [YPos],bh |
||
1046 | jb .Done |
||
1047 | mov [YPos],0 |
||
1048 | .Done: pop rbx rdi rdx rax |
||
1049 | ret |
||
1050 | ;----------------------------------------------------------------------------- |
||
1051 | PrintS: push rax rdx |
||
1052 | mov ah,[XPos] |
||
1053 | .Loop: mov al,[rdx] |
||
1054 | inc edx |
||
1055 | test al,al |
||
1056 | jz .Done |
||
1057 | cmp al,08h |
||
1058 | jz .1 |
||
1059 | call PrintC |
||
1060 | jmp .Loop |
||
1061 | .1: mov al,[rdx] |
||
1062 | inc edx |
||
1063 | test al,al |
||
1064 | jz .Done |
||
1065 | mov [Color],al |
||
1066 | jmp .Loop |
||
1067 | .Done: pop rdx rax |
||
1068 | ret |
||
1069 | ;----------------------------------------------------------------------------- |
||
1070 | ShowGRegs: |
||
1071 | mov dl,5 |
||
1072 | mov [YPos],30 |
||
1073 | mov [XPos],dl |
||
1074 | lea rbp,[_EAX] |
||
1075 | call DisplayIfChanged |
||
1076 | lea rbp,[_EBX] |
||
1077 | call DisplayIfChanged |
||
1078 | lea rbp,[_ECX] |
||
1079 | call DisplayIfChanged |
||
1080 | lea rbp,[_EDX] |
||
1081 | call DisplayIfChanged |
||
1082 | lea rbp,[_ESI] |
||
1083 | call DisplayIfChanged |
||
1084 | lea rbp,[_EDI] |
||
1085 | call DisplayIfChanged |
||
1086 | lea rbp,[_EBP] |
||
1087 | call DisplayIfChanged |
||
1088 | lea rbp,[_ESP] |
||
1089 | DisplayIfChanged: |
||
1090 | mov rax,[rbp] |
||
1091 | cmp rax,[rbp+Plus] |
||
1092 | mov [Color],30h |
||
1093 | jz @F |
||
1094 | mov [Color],3Fh |
||
1095 | @@: call PrintEAX |
||
1096 | inc [YPos] |
||
1097 | mov [XPos],dl |
||
1098 | ret |
||
1099 | ;----------------------------------------------------------------------------- |
||
1100 | ShowXRegs: |
||
1101 | mov dl,18 |
||
1102 | mov [YPos],30 |
||
1103 | mov [XPos],dl |
||
1104 | lea rbp,[_EFL] |
||
1105 | call DisplayIfChanged |
||
1106 | lea rbp,[_EIP] |
||
1107 | call DisplayIfChanged |
||
1108 | ret |
||
1109 | ;----------------------------------------------------------------------------- |
||
1110 | ShowSlide: |
||
1111 | mov [XPos],1 |
||
1112 | mov [YPos],39 |
||
1113 | mov esi,[_EFL] |
||
1114 | mov edi,[_EFL+Plus] |
||
1115 | shl esi,14 |
||
1116 | shl edi,14 |
||
1117 | call .Show ; VM-flag |
||
1118 | call .Show ; RF-flag |
||
1119 | shl esi,1 |
||
1120 | shl edi,1 |
||
1121 | call .Show ; NT-flag |
||
1122 | call .Show ; IOPL-flag |
||
1123 | dec [XPos] |
||
1124 | call .Show |
||
1125 | call .Show ; OF-flag |
||
1126 | call .Show ; DF-flag |
||
1127 | call .Show ; IF-flag |
||
1128 | call .Show ; TF-flag |
||
1129 | call .Show ; SF-flag |
||
1130 | inc [XPos] |
||
1131 | call .Show ; ZF-flag |
||
1132 | shl esi,1 |
||
1133 | shl edi,1 |
||
1134 | call .Show ; AF-flag |
||
1135 | shl esi,1 |
||
1136 | shl edi,1 |
||
1137 | call .Show ; PF-flag |
||
1138 | shl esi,1 |
||
1139 | shl edi,1 |
||
1140 | .Show: xor ax,ax |
||
1141 | shl esi,1 |
||
1142 | adc al,'0' |
||
1143 | shl edi,1 |
||
1144 | adc ah,'0' |
||
1145 | cmp al,ah |
||
1146 | mov [Color],30h |
||
1147 | jz .S1 |
||
1148 | mov [Color],3Fh |
||
1149 | .S1: call PrintC |
||
1150 | inc [XPos] |
||
1151 | ret |
||
1152 | ;----------------------------------------------------------------------------- |
||
1153 | ShowSRegs: |
||
1154 | mov dl,17 |
||
1155 | mov [YPos],32 |
||
1156 | mov eax,cs |
||
1157 | call .DisplaySel |
||
1158 | mov eax,ds |
||
1159 | call .DisplaySel |
||
1160 | mov eax,es |
||
1161 | call .DisplaySel |
||
1162 | mov eax,fs |
||
1163 | call .DisplaySel |
||
1164 | mov eax,gs |
||
1165 | call .DisplaySel |
||
1166 | mov eax,ss |
||
1167 | .DisplaySel: |
||
1168 | mov [Color],31h |
||
1169 | mov [XPos],dl |
||
1170 | call PrintAX |
||
1171 | add [XPos],10 |
||
1172 | lar eax,ax |
||
1173 | shr eax,8 |
||
1174 | call PrintAX |
||
1175 | inc [YPos] |
||
1176 | ret |
||
1177 | ;----------------------------------------------------------------------------- |
||
1178 | ShowData: |
||
1179 | mov bl,8 |
||
1180 | mov [YPos],41 |
||
1181 | mov [Color],30h |
||
1182 | mov rsi,[DataAddr] |
||
1183 | call ShowDataX |
||
1184 | mov bl,3 |
||
1185 | xor ebp,ebp |
||
1186 | mov edi,[_EDX] |
||
1187 | mov [YPos],30 |
||
1188 | call ShowDataRDX |
||
1189 | mov bl,3 |
||
1190 | xor ebp,ebp |
||
1191 | mov edi,[_EBX] |
||
1192 | mov [YPos],34 |
||
1193 | call ShowDataRBX |
||
1194 | mov bl,3 |
||
1195 | xor ebp,ebp |
||
1196 | mov edi,[_ESI] |
||
1197 | mov [YPos],42 |
||
1198 | call ShowDataRSI |
||
1199 | mov bl,3 |
||
1200 | xor ebp,ebp |
||
1201 | mov edi,[_EDI] |
||
1202 | mov [YPos],46 |
||
1203 | call ShowDataRDI |
||
1204 | mov bl,3 |
||
1205 | xor ebp,ebp |
||
1206 | mov edi,[_EBP] |
||
1207 | mov [YPos],38 |
||
1208 | call ShowDataRBP |
||
1209 | call ShowStack32 |
||
1210 | call ShowFPURegs |
||
1211 | cmp [MMXType],0 |
||
1212 | ifnz call ShowMMXRegs |
||
1213 | cmp [XMMType],0 |
||
1214 | ifnz call ShowXMMRegs |
||
1215 | ret |
||
1216 | ;----------------------------------------------------------------------------- |
||
1217 | ShowDataX: |
||
1218 | .1: mov [Color],30h |
||
1219 | mov [XPos],1 |
||
1220 | mov rax,rsi |
||
1221 | call PrintEAX |
||
1222 | mov al,':' |
||
1223 | call PrintC |
||
1224 | inc [XPos] |
||
1225 | mov ecx,35 by 8 |
||
1226 | .2: mov [Color],30h |
||
1227 | call GetDataByte |
||
1228 | jc .3 |
||
1229 | lea eax,[Msg2ER] |
||
1230 | xchg eax,edx |
||
1231 | call PrintS |
||
1232 | xchg eax,edx |
||
1233 | mov al,'?' |
||
1234 | jmp .5 |
||
1235 | .3: call PrintAL |
||
1236 | test al,al |
||
1237 | jz .4 |
||
1238 | cmp al,08h |
||
1239 | jz .4 |
||
1240 | cmp al,09h |
||
1241 | jz .4 |
||
1242 | cmp al,0Ah |
||
1243 | jz .4 |
||
1244 | cmp al,0Dh |
||
1245 | jnz .5 |
||
1246 | .4: mov al,'.' |
||
1247 | .5: xchg [XPos],ch |
||
1248 | call PrintC |
||
1249 | xchg [XPos],ch |
||
1250 | inc [XPos] |
||
1251 | inc rsi |
||
1252 | dec cl |
||
1253 | jnz .2 |
||
1254 | inc [YPos] |
||
1255 | dec bl |
||
1256 | jnz .1 |
||
1257 | ret |
||
1258 | ;----------------------------------------------------------------------------- |
||
1259 | ShowDataRSI: |
||
1260 | .1: mov eax,[CurWidth] |
||
1261 | sub eax,29+16 |
||
1262 | mov [XPos],al |
||
1263 | mov rax,rbp |
||
1264 | test rbp,rbp |
||
1265 | lea edx,[Msg2SIP] |
||
1266 | jns .01 |
||
1267 | lea edx,[Msg2SIM] |
||
1268 | neg rax |
||
1269 | .01: call PrintS |
||
1270 | call PrintAL |
||
1271 | mov al,']' |
||
1272 | call PrintC |
||
1273 | mov al,32 |
||
1274 | test rbp,rbp |
||
1275 | jnz .03 |
||
1276 | mov al,10h |
||
1277 | .03: call PrintC |
||
1278 | inc [XPos] |
||
1279 | .04: mov ecx,[CurWidth] |
||
1280 | sub ecx,5+5 |
||
1281 | shl ecx,8 |
||
1282 | mov cl,8 |
||
1283 | .2: lea rsi,[rdi+rbp] |
||
1284 | mov al,3 ;ds |
||
1285 | call GetDataByte |
||
1286 | jc .3 |
||
1287 | lea edx,[Msg2ER] |
||
1288 | call PrintS |
||
1289 | mov al,'?' |
||
1290 | jmp .5 |
||
1291 | .3: call PrintAL |
||
1292 | test al,al |
||
1293 | jz .4 |
||
1294 | cmp al,08h |
||
1295 | jz .4 |
||
1296 | cmp al,09h |
||
1297 | jz .4 |
||
1298 | cmp al,0Ah |
||
1299 | jz .4 |
||
1300 | cmp al,0Dh |
||
1301 | jnz .5 |
||
1302 | .4: mov al,'.' |
||
1303 | .5: xchg [XPos],ch |
||
1304 | call PrintC |
||
1305 | xchg [XPos],ch |
||
1306 | inc [XPos] |
||
1307 | inc rbp |
||
1308 | dec cl |
||
1309 | jnz .2 |
||
1310 | inc [YPos] |
||
1311 | dec bl |
||
1312 | jnz .1 |
||
1313 | ret |
||
1314 | ShowDataRDI: |
||
1315 | .1: mov eax,[CurWidth] |
||
1316 | sub eax,29+16 |
||
1317 | mov [XPos],al |
||
1318 | mov rax,rbp |
||
1319 | test rbp,rbp |
||
1320 | lea edx,[Msg2DIP] |
||
1321 | jns .01 |
||
1322 | lea edx,[Msg2DIM] |
||
1323 | neg rax |
||
1324 | .01: call PrintS |
||
1325 | call PrintAL |
||
1326 | mov al,']' |
||
1327 | call PrintC |
||
1328 | mov al,32 |
||
1329 | test rbp,rbp |
||
1330 | jnz .03 |
||
1331 | mov al,10h |
||
1332 | .03: call PrintC |
||
1333 | inc [XPos] |
||
1334 | .04: mov ecx,[CurWidth] |
||
1335 | sub ecx,5+5 |
||
1336 | shl ecx,8 |
||
1337 | mov cl,8 |
||
1338 | .2: lea rsi,[rdi+rbp] |
||
1339 | mov al,0 ;es |
||
1340 | call GetDataByte |
||
1341 | jc .3 |
||
1342 | lea edx,[Msg2ER] |
||
1343 | call PrintS |
||
1344 | mov al,'?' |
||
1345 | jmp .5 |
||
1346 | .3: call PrintAL |
||
1347 | test al,al |
||
1348 | jz .4 |
||
1349 | cmp al,08h |
||
1350 | jz .4 |
||
1351 | cmp al,09h |
||
1352 | jz .4 |
||
1353 | cmp al,0Ah |
||
1354 | jz .4 |
||
1355 | cmp al,0Dh |
||
1356 | jnz .5 |
||
1357 | .4: mov al,'.' |
||
1358 | .5: xchg [XPos],ch |
||
1359 | call PrintC |
||
1360 | xchg [XPos],ch |
||
1361 | inc [XPos] |
||
1362 | inc rbp |
||
1363 | dec cl |
||
1364 | jnz .2 |
||
1365 | inc [YPos] |
||
1366 | dec bl |
||
1367 | jnz .1 |
||
1368 | ret |
||
1369 | ShowDataRBX: |
||
1370 | .1: mov eax,[CurWidth] |
||
1371 | sub eax,29+16 |
||
1372 | mov [XPos],al |
||
1373 | mov rax,rbp |
||
1374 | test rbp,rbp |
||
1375 | lea edx,[Msg2BXP] |
||
1376 | jns .01 |
||
1377 | lea edx,[Msg2BXM] |
||
1378 | neg rax |
||
1379 | .01: call PrintS |
||
1380 | call PrintAL |
||
1381 | mov al,']' |
||
1382 | call PrintC |
||
1383 | mov al,32 |
||
1384 | test rbp,rbp |
||
1385 | jnz .03 |
||
1386 | mov al,10h |
||
1387 | .03: call PrintC |
||
1388 | inc [XPos] |
||
1389 | .04: mov ecx,[CurWidth] |
||
1390 | sub ecx,5+5 |
||
1391 | shl ecx,8 |
||
1392 | mov cl,8 |
||
1393 | .2: lea rsi,[rdi+rbp] |
||
1394 | mov al,3 ;ds |
||
1395 | call GetDataByte |
||
1396 | jc .3 |
||
1397 | lea edx,[Msg2ER] |
||
1398 | call PrintS |
||
1399 | mov al,'?' |
||
1400 | jmp .5 |
||
1401 | .3: call PrintAL |
||
1402 | test al,al |
||
1403 | jz .4 |
||
1404 | cmp al,08h |
||
1405 | jz .4 |
||
1406 | cmp al,09h |
||
1407 | jz .4 |
||
1408 | cmp al,0Ah |
||
1409 | jz .4 |
||
1410 | cmp al,0Dh |
||
1411 | jnz .5 |
||
1412 | .4: mov al,'.' |
||
1413 | .5: xchg [XPos],ch |
||
1414 | call PrintC |
||
1415 | xchg [XPos],ch |
||
1416 | inc [XPos] |
||
1417 | inc rbp |
||
1418 | dec cl |
||
1419 | jnz .2 |
||
1420 | inc [YPos] |
||
1421 | dec bl |
||
1422 | jnz .1 |
||
1423 | ret |
||
1424 | ;----------------------------------------------------------------------------- |
||
1425 | ShowDataRDX: |
||
1426 | .1: mov eax,[CurWidth] |
||
1427 | sub eax,29+16 |
||
1428 | mov [XPos],al |
||
1429 | mov rax,rbp |
||
1430 | test rbp,rbp |
||
1431 | lea edx,[Msg2DXP] |
||
1432 | jns .01 |
||
1433 | lea edx,[Msg2DXM] |
||
1434 | neg rax |
||
1435 | .01: call PrintS |
||
1436 | call PrintAL |
||
1437 | mov al,']' |
||
1438 | call PrintC |
||
1439 | mov al,32 |
||
1440 | test rbp,rbp |
||
1441 | jnz .03 |
||
1442 | mov al,10h |
||
1443 | .03: call PrintC |
||
1444 | inc [XPos] |
||
1445 | .04: mov ecx,[CurWidth] |
||
1446 | sub ecx,5+5 |
||
1447 | shl ecx,8 |
||
1448 | mov cl,8 |
||
1449 | .2: lea rsi,[rdi+rbp] |
||
1450 | mov al,3 ;ds |
||
1451 | call GetDataByte |
||
1452 | jc .3 |
||
1453 | lea edx,[Msg2ER] |
||
1454 | call PrintS |
||
1455 | mov al,'?' |
||
1456 | jmp .5 |
||
1457 | .3: call PrintAL |
||
1458 | test al,al |
||
1459 | jz .4 |
||
1460 | cmp al,08h |
||
1461 | jz .4 |
||
1462 | cmp al,09h |
||
1463 | jz .4 |
||
1464 | cmp al,0Ah |
||
1465 | jz .4 |
||
1466 | cmp al,0Dh |
||
1467 | jnz .5 |
||
1468 | .4: mov al,'.' |
||
1469 | .5: xchg [XPos],ch |
||
1470 | call PrintC |
||
1471 | xchg [XPos],ch |
||
1472 | inc [XPos] |
||
1473 | inc rbp |
||
1474 | dec cl |
||
1475 | jnz .2 |
||
1476 | inc [YPos] |
||
1477 | dec bl |
||
1478 | jnz .1 |
||
1479 | ret |
||
1480 | ;----------------------------------------------------------------------------- |
||
1481 | ShowDataRBP: |
||
1482 | .1: mov eax,[CurWidth] |
||
1483 | sub eax,29+16 |
||
1484 | mov [XPos],al |
||
1485 | mov rax,rbp |
||
1486 | test rbp,rbp |
||
1487 | lea edx,[Msg2BPP] |
||
1488 | jns .01 |
||
1489 | lea edx,[Msg2BPM] |
||
1490 | neg rax |
||
1491 | .01: call PrintS |
||
1492 | call PrintAL |
||
1493 | mov al,']' |
||
1494 | call PrintC |
||
1495 | mov al,32 |
||
1496 | test rbp,rbp |
||
1497 | jnz .03 |
||
1498 | mov al,10h |
||
1499 | .03: call PrintC |
||
1500 | inc [XPos] |
||
1501 | .04: mov ecx,[CurWidth] |
||
1502 | sub ecx,5+5 |
||
1503 | shl ecx,8 |
||
1504 | mov cl,8 |
||
1505 | .2: lea rsi,[rdi+rbp] |
||
1506 | mov al,2 ;ss |
||
1507 | call GetDataByte |
||
1508 | jc .3 |
||
1509 | lea edx,[Msg2ER] |
||
1510 | call PrintS |
||
1511 | mov al,'?' |
||
1512 | jmp .5 |
||
1513 | .3: call PrintAL |
||
1514 | test al,al |
||
1515 | jz .4 |
||
1516 | cmp al,08h |
||
1517 | jz .4 |
||
1518 | cmp al,09h |
||
1519 | jz .4 |
||
1520 | cmp al,0Ah |
||
1521 | jz .4 |
||
1522 | cmp al,0Dh |
||
1523 | jnz .5 |
||
1524 | .4: mov al,'.' |
||
1525 | .5: xchg [XPos],ch |
||
1526 | call PrintC |
||
1527 | xchg [XPos],ch |
||
1528 | inc [XPos] |
||
1529 | inc rbp |
||
1530 | dec cl |
||
1531 | jnz .2 |
||
1532 | inc [YPos] |
||
1533 | dec bl |
||
1534 | jnz .1 |
||
1535 | ret |
||
1536 | ;----------------------------------------------------------------------------- |
||
1537 | GetSeg: mov edx,TDS |
||
1538 | cmp [Inst.DefSeg],VSS |
||
1539 | ifz mov edx,TSS |
||
1540 | mov al,[Inst.CurSeg] |
||
1541 | or al,al |
||
1542 | jz .SkipSegm |
||
1543 | cmp al,[Inst.DefSeg] |
||
1544 | jz .SkipSegm |
||
1545 | mov dx,[Inst.SegmName] |
||
1546 | .SkipSegm: |
||
1547 | mov dx,[rdx+Names] |
||
1548 | ret |
||
1549 | ;----------------------------------------------------------------------------- |
||
1550 | GetSegm:mov dx,TDS |
||
1551 | cmp [Inst.DefSeg],VSS |
||
1552 | ifz mov dx,TSS |
||
1553 | mov al,[Inst.CurSeg] |
||
1554 | or al,al |
||
1555 | jz @F |
||
1556 | cmp al,[Inst.DefSeg] |
||
1557 | jz @F |
||
1558 | mov dx,[Inst.SegmName] |
||
1559 | @@: |
||
1560 | mov al,0 |
||
1561 | cmp dx,TES |
||
1562 | jz @F |
||
1563 | mov al,1 |
||
1564 | cmp dx,TCS |
||
1565 | jz @F |
||
1566 | mov al,2 |
||
1567 | cmp dx,TSS |
||
1568 | jz @F |
||
1569 | mov al,3 |
||
1570 | cmp dx,TDS |
||
1571 | jz @F |
||
1572 | mov al,4 |
||
1573 | cmp dx,TFS |
||
1574 | jz @F |
||
1575 | mov al,5 |
||
1576 | @@: |
||
1577 | ret |
||
1578 | ;----------------------------------------------------------------------------- |
||
1579 | GetMemAddress: |
||
1580 | ; |
||
1581 | xor ebx,ebx |
||
1582 | mov ecx,1 |
||
1583 | ; |
||
1584 | movzx eax,[Inst.Scale] |
||
1585 | cmp al,-1 |
||
1586 | jz @F |
||
1587 | mov cl,[eax+AnScale] |
||
1588 | @@: |
||
1589 | movzx eax,[Inst.Base] |
||
1590 | cmp al,-1 |
||
1591 | jz @F |
||
1592 | mov eax,[rax*4+RegVTab] |
||
1593 | mov rax,[rax] |
||
1594 | call Address2Reg |
||
1595 | add rbx,rax |
||
1596 | @@: |
||
1597 | movzx eax,[Inst.Indx] |
||
1598 | cmp al,-1 |
||
1599 | jz @F |
||
1600 | mov eax,[rax*4+RegVTab] |
||
1601 | mov rax,[rax] |
||
1602 | call Address2Reg |
||
1603 | mul rcx |
||
1604 | add rbx,rax |
||
1605 | @@: |
||
1606 | cmp [Inst.DispSize],0 |
||
1607 | jz @F |
||
1608 | mov rax,[Inst.Disp] |
||
1609 | call Address2Reg |
||
1610 | add rbx,rax |
||
1611 | @@: |
||
1612 | mov rax,rbx |
||
1613 | call Address2Reg |
||
1614 | mov rbx,rax |
||
1615 | ret |
||
1616 | ;----------------------------------------------------------------------------- |
||
1617 | ShowAddress: |
||
1618 | ; |
||
1619 | mov [Color],3Fh |
||
1620 | mov [XPos],15 |
||
1621 | mov [YPos],ch |
||
1622 | mov al,0xCD |
||
1623 | mov ecx,[CurWidth] |
||
1624 | sub ecx,21+16+1 |
||
1625 | .LoopX: call PrintC |
||
1626 | loop .LoopX |
||
1627 | ; |
||
1628 | mov al,[Inst.Arg1.Mem] |
||
1629 | or al,[Inst.Arg2.Mem] |
||
1630 | or al,[Inst.Arg3.Mem] |
||
1631 | or al,[Inst.Arg4.Mem] |
||
1632 | or al,[Inst.Arg5.Mem] |
||
1633 | ifz ret |
||
1634 | ; |
||
1635 | call GetSeg |
||
1636 | mov [AddressStr],dx |
||
1637 | ; |
||
1638 | call GetMemAddress |
||
1639 | if %B=64 |
||
1640 | rol rax,32 |
||
1641 | mov edi,AddressStr+3 |
||
1642 | call MakeHex |
||
1643 | rol rax,32 |
||
1644 | mov edi,AddressStr+3+8 |
||
1645 | call MakeHex |
||
1646 | else |
||
1647 | mov edi,AddressStr+3 |
||
1648 | call MakeHex |
||
1649 | end if |
||
1650 | mov edi,AddressFin |
||
1651 | |||
1652 | movzx edx,[Inst.RandSize] |
||
1653 | and dl,7Fh |
||
1654 | movzx ebp,[rdx*2+RndSize+0] |
||
1655 | movzx ecx,[rdx*2+RndSize+1] |
||
1656 | jrcxz .Exit |
||
1657 | lea rsi,[rbx+rcx] |
||
1658 | ; |
||
1659 | cmp edx,3 |
||
1660 | jnz @F |
||
1661 | cmp [Inst.Point],0 |
||
1662 | jz @F |
||
1663 | mov bp,2+1 |
||
1664 | mov cx,2+2 |
||
1665 | @@: |
||
1666 | ; |
||
1667 | .Loop: |
||
1668 | dec rsi |
||
1669 | sub ebp,1 |
||
1670 | jnz @F |
||
1671 | mov [rdi],byte ':' |
||
1672 | inc edi |
||
1673 | @@: |
||
1674 | mov [rdi],word '--' |
||
1675 | call GetSegm |
||
1676 | call GetDataByte |
||
1677 | jnc @F |
||
1678 | movzx eax,al |
||
1679 | mov ax,[rax*2+HexString] |
||
1680 | mov [rdi],ax |
||
1681 | @@: |
||
1682 | add edi,2 |
||
1683 | loop .Loop |
||
1684 | .Exit: |
||
1685 | mov [rdi],word 'h' |
||
1686 | |||
1687 | sub edi,AddressStr |
||
1688 | mov eax,[CurWidth] |
||
1689 | sub eax,24 |
||
1690 | sub eax,edi |
||
1691 | ifc ret |
||
1692 | mov [XPos],al |
||
1693 | mov [YPos],0 |
||
1694 | mov [Color],3Fh |
||
1695 | mov edx,AddressStr |
||
1696 | jmp PrintS |
||
1697 | ;----------------------------------------------------------------------------- |
||
1698 | Address2Reg: |
||
1699 | cmp [Inst.Address],2 |
||
1700 | jz @F |
||
1701 | cmp [Inst.Address],1 |
||
1702 | mov eax,eax |
||
1703 | jz @F |
||
1704 | movzx eax,ax |
||
1705 | @@: |
||
1706 | ret |
||
1707 | ;----------------------------------------------------------------------------- |
||
1708 | sglobal |
||
1709 | if %B=32 |
||
1710 | AddressStr: db '??:xxxxxxxx = ' |
||
1711 | AddressFin: db 64*2+2 dup 0 |
||
1712 | else |
||
1713 | AddressStr: db '??:xxxxxxxxxxxxxxxx = ' |
||
1714 | AddressFin db 64*2+2 dup 0 |
||
1715 | end if |
||
1716 | endg |
||
1717 | ;----------------------------------------------------------------------------- |
||
1718 | iglobal |
||
1719 | RndSize db 0,0 ;NULL |
||
1720 | db 0,1 ;TWORD |
||
1721 | db 0,2 ;SWORD |
||
1722 | db 0,4 ;DWORD |
||
1723 | db 0,8 ;QWORD |
||
1724 | db 0,16 ;XWORD |
||
1725 | db 0,32 ;YWORD |
||
1726 | db 0,52 ;ZWORD -> 64 too large |
||
1727 | db 2+1,4+2;FWORD |
||
1728 | db 2+1,8+2;TWORD |
||
1729 | AnScale db 1,2,4,8 |
||
1730 | endg |
||
1731 | ;----------------------------------------------------------------------------- |
||
1732 | ClearWindow: |
||
1733 | mov ebp,[CurWidth] |
||
1734 | mov eax,edi |
||
1735 | imul eax,ebp |
||
1736 | add eax,eax |
||
1737 | lea edi,[rax+rsi*2] |
||
1738 | add edi,ConsoleDataPtr |
||
1739 | mov eax,edx |
||
1740 | lea edx,[rcx*2] |
||
1741 | .Loop: push rcx |
||
1742 | shr ecx,1 |
||
1743 | rep stosd |
||
1744 | adc cl,cl |
||
1745 | rep stosw |
||
1746 | pop rcx |
||
1747 | sub esi,edx |
||
1748 | sub edi,edx |
||
1749 | lea esi,[rsi+rbp*2] |
||
1750 | lea edi,[rdi+rbp*2] |
||
1751 | dec ebx |
||
1752 | jnz .Loop |
||
1753 | ret |
||
1754 | ;----------------------------------------------------------------------------- |
||
1755 | ShowStack32: |
||
1756 | mov [YPos],28 |
||
1757 | mov [Color],30h |
||
1758 | mov cl,28 |
||
1759 | mov edi,[_ESP] |
||
1760 | add rdi,[StckAddr] |
||
1761 | .1: mov rax,rdi |
||
1762 | sub rax,[_ESP] |
||
1763 | mov edx,Msg3SPP |
||
1764 | jns .2 |
||
1765 | neg rax |
||
1766 | mov edx,Msg3SPM |
||
1767 | .2: mov ebx,[CurWidth] |
||
1768 | sub ebx,21 |
||
1769 | mov [XPos],bl |
||
1770 | call PrintS |
||
1771 | call PrintAX |
||
1772 | mov al,']' |
||
1773 | call PrintC |
||
1774 | .20: |
||
1775 | cmp edi,[_ESP] |
||
1776 | mov al,10h |
||
1777 | jz .3 |
||
1778 | cmp edi,[_EBP] |
||
1779 | mov al,'>' |
||
1780 | jz .3 |
||
1781 | mov al,20h |
||
1782 | .3: call PrintC |
||
1783 | lea rsi,[rdi+3] |
||
1784 | rept 3 |
||
1785 | { |
||
1786 | call GetDataByte |
||
1787 | dec rsi |
||
1788 | shl rax,8 |
||
1789 | } |
||
1790 | call GetDataByte |
||
1791 | add rdi,4 |
||
1792 | call PrintEAX |
||
1793 | ;lea edx,[Spaces32+6] |
||
1794 | ;call PrintS |
||
1795 | dec [YPos] |
||
1796 | dec cl |
||
1797 | jnz .1 |
||
1798 | cmp [CurrentWindow],3 |
||
1799 | jz ShowAddrStk |
||
1800 | ret |
||
1801 | ShowAddrStk: |
||
1802 | mov eax,[CurWidth] |
||
1803 | sub eax,51-23-9 |
||
1804 | mov [XPos],al |
||
1805 | mov [YPos],60-2-9+10 |
||
1806 | mov [Color],3Fh |
||
1807 | mov rax,[StckAddr] |
||
1808 | add eax,[_ESP] |
||
1809 | call PrintEAX |
||
1810 | add [XPos],3 |
||
1811 | mov rsi,rax |
||
1812 | call GetDataByte |
||
1813 | jc PrintAL |
||
1814 | lea edx,[Msg2ER] |
||
1815 | jmp PrintS |
||
1816 | ;----------------------------------------------------------------------------- |
||
1817 | FindCodeUp: |
||
1818 | mov rax,[AddrBuffer] |
||
1819 | sub rax,16 ; average opcode length |
||
1820 | .1: inc rax |
||
1821 | mov rbx,rax |
||
1822 | mov rsi,rax |
||
1823 | .2: mov rsi,rbx |
||
1824 | mov rdx,rbx |
||
1825 | call Decode |
||
1826 | cmp rbx,rsi |
||
1827 | ja .Done |
||
1828 | mov rbx,rsi |
||
1829 | sub rsi,[AddrBuffer] |
||
1830 | jb .2 |
||
1831 | .Done: mov rax,rdx |
||
1832 | ret |
||
1833 | ;----------------------------------------------------------------------------- |
||
1834 | CPUWindow: |
||
1835 | cmp ah,0x0F |
||
1836 | jz WindowSwitch |
||
1837 | cmp ah,0x3B ; F1 - Toggle Show |
||
1838 | jz ToggleShow |
||
1839 | cmp ah,0x3C ; F2 - Toggle BP |
||
1840 | jz ToggleBP |
||
1841 | cmp ah,0x3D ; F3 - Return To |
||
1842 | jz ReturnTo |
||
1843 | cmp ah,0x3E ; F4 - Here |
||
1844 | jz ComeHere |
||
1845 | cmp ah,0x40 ; F6 - New EIP |
||
1846 | jz NewAddress |
||
1847 | cmp ah,0x41 ; F7 - Trace |
||
1848 | jz F7 |
||
1849 | cmp ah,0x42 ; F8 - Step over |
||
1850 | jz F8 |
||
1851 | cmp ah,0x43 ; F9 - Proceed |
||
1852 | jz Proceed |
||
1853 | cmp ah,0x44 ; F10 - Jump over |
||
1854 | jz JumpOver |
||
1855 | cmp al,0xB1 |
||
1856 | jz CPUDn |
||
1857 | cmp al,0xB2 |
||
1858 | jz CPUUp |
||
1859 | cmp al,0xB4 |
||
1860 | jz CPUHome |
||
1861 | cmp al,0xB7 |
||
1862 | jz CPUPgDn |
||
1863 | cmp al,0xB8 |
||
1864 | jz CPUPgUp |
||
1865 | cmp ah,0x4B |
||
1866 | jz CPULeft |
||
1867 | cmp ah,0x4D |
||
1868 | jz CPURight |
||
1869 | cmp ah,0xE |
||
1870 | jz CPUGoToMem |
||
1871 | ; |
||
1872 | cmp al,'a' |
||
1873 | jb .Skip1 |
||
1874 | cmp al,'z' |
||
1875 | jbe DoCommandLine |
||
1876 | .Skip1: |
||
1877 | ; |
||
1878 | cmp al,'A' |
||
1879 | jb .Skip2 |
||
1880 | cmp al,'Z' |
||
1881 | jbe DoCommandLine |
||
1882 | .Skip2: |
||
1883 | ; |
||
1884 | jmp WaitEvent |
||
1885 | RegWindow: |
||
1886 | cmp ah,0x0F |
||
1887 | jz WindowSwitch |
||
1888 | cmp ah,0x01 |
||
1889 | jz SwitchCPU |
||
1890 | cmp ah,0x3B ; F1 - Toggle Show |
||
1891 | jz ToggleShow |
||
1892 | ; |
||
1893 | cmp al,0xB1 ; dn |
||
1894 | jz RegDn |
||
1895 | cmp al,0xB2 ; up |
||
1896 | jz RegUp |
||
1897 | cmp al,0xB4 ; home |
||
1898 | jz RegHome |
||
1899 | cmp al,0xB5 ; end |
||
1900 | jz RegEnd |
||
1901 | cmp ah,0x4B ; left |
||
1902 | jz RegLeft |
||
1903 | cmp ah,0x4D ; right |
||
1904 | jz RegRight |
||
1905 | cmp al,'+' ; '+' |
||
1906 | jz RegIncR |
||
1907 | cmp al,'-' ; '-' |
||
1908 | jz RegDecR |
||
1909 | cmp al,'*' ; '*' |
||
1910 | jz RegNot |
||
1911 | cmp al,'/' ; '/' |
||
1912 | jz RegRes |
||
1913 | cmp ah,0xE ; BackSpace - GoTo MemAddr |
||
1914 | jz RegGoToMem |
||
1915 | cmp ah,0x39 ; Space |
||
1916 | jz RegXor |
||
1917 | ; |
||
1918 | cmp al,'a' |
||
1919 | jb .Skip1 |
||
1920 | cmp al,'z' |
||
1921 | jbe DoCommandLine |
||
1922 | .Skip1: |
||
1923 | ; |
||
1924 | cmp al,'A' |
||
1925 | jb .Skip2 |
||
1926 | cmp al,'Z' |
||
1927 | jbe DoCommandLine |
||
1928 | .Skip2: |
||
1929 | ; |
||
1930 | jmp WaitEvent |
||
1931 | MemWindow: |
||
1932 | cmp ah,0x0F |
||
1933 | jz WindowSwitch |
||
1934 | cmp ah,0x01 |
||
1935 | jz SwitchCPU |
||
1936 | cmp ah,0x3B ; F1 - Toggle Show |
||
1937 | jz ToggleShow |
||
1938 | ; |
||
1939 | cmp al,0xB1 ; down |
||
1940 | jz MemDn |
||
1941 | cmp al,0xB2 ; up |
||
1942 | jz MemUp |
||
1943 | cmp ah,0x4B ; left |
||
1944 | jz MemLeft |
||
1945 | cmp ah,0x4D ; right |
||
1946 | jz MemRight |
||
1947 | cmp al,0xB4 ; home |
||
1948 | jz MemHome |
||
1949 | cmp al,0xB7 ; page-dn |
||
1950 | jz MemPageDn |
||
1951 | cmp al,0xB8 ; page-up |
||
1952 | jz MemPageUp |
||
1953 | ; |
||
1954 | cmp al,'+' |
||
1955 | jz MemIncB |
||
1956 | cmp al,'-' |
||
1957 | jz MemDecB |
||
1958 | cmp al,'*' |
||
1959 | jz MemNotB |
||
1960 | cmp al,'/' |
||
1961 | jz MemResB |
||
1962 | ; |
||
1963 | cmp al,'a' |
||
1964 | jb .Skip1 |
||
1965 | cmp al,'z' |
||
1966 | jbe DoCommandLine |
||
1967 | .Skip1: |
||
1968 | ; |
||
1969 | cmp al,'A' |
||
1970 | jb .Skip2 |
||
1971 | cmp al,'Z' |
||
1972 | jbe DoCommandLine |
||
1973 | .Skip2: |
||
1974 | ; |
||
1975 | jmp WaitEvent |
||
1976 | StkWindow: |
||
1977 | cmp ah,0x0F |
||
1978 | jz WindowSwitch |
||
1979 | cmp ah,0x01 |
||
1980 | jz SwitchCPU |
||
1981 | cmp ah,0x3B ; F1 - Toggle Show |
||
1982 | jz ToggleShow |
||
1983 | ; |
||
1984 | cmp al,0xB1 ; dn |
||
1985 | jz StkDn |
||
1986 | cmp al,0xB2 ; up |
||
1987 | jz StkUp |
||
1988 | cmp al,0xB4 ; home |
||
1989 | jz StkHome |
||
1990 | cmp al,0xB7 ; page-dn |
||
1991 | jz StkPgDn |
||
1992 | cmp al,0xB8 ; page-up |
||
1993 | jz StkPgUp |
||
1994 | cmp al,'+' ; '+' |
||
1995 | jz StkIncV |
||
1996 | cmp al,'-' ; '-' |
||
1997 | jz StkDecV |
||
1998 | cmp al,'*' ; '*' |
||
1999 | jz StkNotV |
||
2000 | cmp al,'/' ; '/' |
||
2001 | jz StkResV |
||
2002 | cmp al,0xE ; BackSpace - GoTo MemAddr |
||
2003 | jz StkGoToMem |
||
2004 | ; |
||
2005 | cmp al,'a' |
||
2006 | jb .Skip1 |
||
2007 | cmp al,'z' |
||
2008 | jbe DoCommandLine |
||
2009 | .Skip1: |
||
2010 | ; |
||
2011 | cmp al,'A' |
||
2012 | jb .Skip2 |
||
2013 | cmp al,'Z' |
||
2014 | jbe DoCommandLine |
||
2015 | .Skip2: |
||
2016 | ; |
||
2017 | jmp WaitEvent |
||
2018 | ;----------------------------------------------------------------------------- |
||
2019 | DoCommandLine: |
||
2020 | mov [CmdLineActive],1 |
||
2021 | jmp GetCommandLine |
||
2022 | ;----------------------------------------------------------------------------- |
||
2023 | Proceed:call GoOn |
||
2024 | jmp WaitEvent |
||
2025 | ;----------------------------------------------------------------------------- |
||
2026 | SwitchCPU: |
||
2027 | and [CurrentWindow],0 |
||
2028 | jmp WinSwitch |
||
2029 | ;----------------------------------------------------------------------------- |
||
2030 | ToggleShow: |
||
2031 | xor [ShowNames],-1 |
||
2032 | jmp CPUCommon |
||
2033 | ;----------------------------------------------------------------------------- |
||
2034 | StkUp: mov eax,2 |
||
2035 | cmp [CodeType],16 |
||
2036 | je .1 |
||
2037 | mov eax,4 |
||
2038 | cmp [CodeType],32 |
||
2039 | je .1 |
||
2040 | mov eax,8 |
||
2041 | .1: |
||
2042 | add [StckAddr],rax |
||
2043 | jmp StkCommon |
||
2044 | ;----------------------------------------------------------------------------- |
||
2045 | StkDn: mov eax,2 |
||
2046 | cmp [CodeType],16 |
||
2047 | je .1 |
||
2048 | mov eax,4 |
||
2049 | cmp [CodeType],32 |
||
2050 | je .1 |
||
2051 | mov eax,8 |
||
2052 | .1: |
||
2053 | sub [StckAddr],rax |
||
2054 | jmp StkCommon |
||
2055 | ;----------------------------------------------------------------------------- |
||
2056 | StkPgUp:mov eax,2*4 |
||
2057 | cmp [CodeType],16 |
||
2058 | je .1 |
||
2059 | mov eax,4*4 |
||
2060 | cmp [CodeType],32 |
||
2061 | je .1 |
||
2062 | mov eax,8*4 |
||
2063 | .1: |
||
2064 | add [StckAddr],rax |
||
2065 | jmp StkCommon |
||
2066 | ;----------------------------------------------------------------------------- |
||
2067 | StkPgDn:mov eax,2*4 |
||
2068 | cmp [CodeType],16 |
||
2069 | je .1 |
||
2070 | mov eax,4*4 |
||
2071 | cmp [CodeType],32 |
||
2072 | je .1 |
||
2073 | mov eax,8*4 |
||
2074 | .1: |
||
2075 | sub [StckAddr],rax |
||
2076 | jmp StkCommon |
||
2077 | ;----------------------------------------------------------------------------- |
||
2078 | StkHome: |
||
2079 | and [StckAddr],0 |
||
2080 | StkCommon: |
||
2081 | jmp CPUCommon |
||
2082 | ;----------------------------------------------------------------------------- |
||
2083 | StkGetAddress: |
||
2084 | mov rax,[StckAddr] |
||
2085 | add eax,[_ESP] |
||
2086 | ret |
||
2087 | ;----------------------------------------------------------------------------- |
||
2088 | StkIncV:call StkGetAddress |
||
2089 | mov rsi,rax |
||
2090 | mov rdi,rax |
||
2091 | call SafeLoadDD |
||
2092 | inc rax |
||
2093 | call SafeStoreDD |
||
2094 | jmp StkCommon |
||
2095 | ;----------------------------------------------------------------------------- |
||
2096 | StkDecV:call StkGetAddress |
||
2097 | mov rsi,rax |
||
2098 | mov rdi,rax |
||
2099 | call SafeLoadDD |
||
2100 | dec rax |
||
2101 | call SafeStoreDD |
||
2102 | jmp StkCommon |
||
2103 | ;----------------------------------------------------------------------------- |
||
2104 | StkNotV:call StkGetAddress |
||
2105 | mov rsi,rax |
||
2106 | mov rdi,rax |
||
2107 | call SafeLoadDD |
||
2108 | not rax |
||
2109 | call SafeStoreDD |
||
2110 | jmp StkCommon |
||
2111 | ;----------------------------------------------------------------------------- |
||
2112 | StkResV:call StkGetAddress |
||
2113 | mov rdi,rax |
||
2114 | xor eax,eax |
||
2115 | call SafeStoreDD |
||
2116 | jmp StkCommon |
||
2117 | ;----------------------------------------------------------------------------- |
||
2118 | StkGoToMem: |
||
2119 | call StkGetAddress |
||
2120 | mov [DataAddr],rax |
||
2121 | jmp StkCommon |
||
2122 | ;----------------------------------------------------------------------------- |
||
2123 | RegUp: mov ebp,[RegXPtr] |
||
2124 | dec ebp |
||
2125 | jns RegCommon |
||
2126 | jmp WaitEvent |
||
2127 | ;----------------------------------------------------------------------------- |
||
2128 | RegDn: mov ebp,[RegXPtr] |
||
2129 | inc ebp |
||
2130 | cmp ebp,17 |
||
2131 | jb RegCommon |
||
2132 | jmp WaitEvent |
||
2133 | ;----------------------------------------------------------------------------- |
||
2134 | RegLeft: |
||
2135 | mov ebp,[RegXPtr] |
||
2136 | sub ebp,8 |
||
2137 | jns RegCommon |
||
2138 | xor ebp,ebp |
||
2139 | jmp RegCommon |
||
2140 | ;----------------------------------------------------------------------------- |
||
2141 | RegRight: |
||
2142 | mov ebp,[RegXPtr] |
||
2143 | add ebp,8 |
||
2144 | cmp ebp,17 |
||
2145 | jb RegCommon |
||
2146 | jmp WaitEvent |
||
2147 | ;----------------------------------------------------------------------------- |
||
2148 | RegHome:xor ebp,ebp |
||
2149 | jmp RegCommon |
||
2150 | ;----------------------------------------------------------------------------- |
||
2151 | RegEnd: mov ebp,16 |
||
2152 | jmp RegCommon |
||
2153 | ;----------------------------------------------------------------------------- |
||
2154 | RegXor: mov ebp,[RegXPtr] |
||
2155 | cmp ebp,17-8 |
||
2156 | jae RegIncR.0 |
||
2157 | jmp WaitEvent |
||
2158 | ;----------------------------------------------------------------------------- |
||
2159 | RegIncR:mov ebp,[RegXPtr] |
||
2160 | cmp ebp,17-8 |
||
2161 | jb .1 |
||
2162 | .0: mov eax,[RegRTab+rbp*4] |
||
2163 | xor [_EFL],eax |
||
2164 | jmp RegCommon |
||
2165 | .1: mov eax,[RegRTab+rbp*4] |
||
2166 | inc dword [rax] |
||
2167 | jmp RegCommon |
||
2168 | ;----------------------------------------------------------------------------- |
||
2169 | RegDecR:mov ebp,[RegXPtr] |
||
2170 | cmp ebp,17-8 |
||
2171 | jb .1 |
||
2172 | mov eax,[RegRTab+rbp*4] |
||
2173 | xor [_EFL],eax |
||
2174 | jmp RegCommon |
||
2175 | .1: mov eax,[RegRTab+rbp*4] |
||
2176 | dec dword [rax] |
||
2177 | jmp RegCommon |
||
2178 | ;----------------------------------------------------------------------------- |
||
2179 | RegRes: mov ebp,[RegXPtr] |
||
2180 | cmp ebp,17-8 |
||
2181 | jb .1 |
||
2182 | mov eax,[RegRTab+rbp*4] |
||
2183 | not eax |
||
2184 | and [_EFL],eax |
||
2185 | jmp RegCommon |
||
2186 | .1: mov eax,[RegRTab+rbp*4] |
||
2187 | and dword [rax],0 |
||
2188 | jmp RegCommon |
||
2189 | ;----------------------------------------------------------------------------- |
||
2190 | RegNot: mov ebp,[RegXPtr] |
||
2191 | cmp ebp,17-8 |
||
2192 | jb .1 |
||
2193 | mov eax,[RegRTab+rbp*4] |
||
2194 | xor [_EFL],eax |
||
2195 | jmp RegCommon |
||
2196 | .1: mov eax,[RegRTab+rbp*4] |
||
2197 | not dword [rax] |
||
2198 | ;jmp RegCommon |
||
2199 | RegCommon: |
||
2200 | mov [RegXPtr],ebp |
||
2201 | mov eax,RegXTab |
||
2202 | movzx eax,byte [rax+rbp] |
||
2203 | mov [RegXPos],eax |
||
2204 | mov eax,RegYTab |
||
2205 | movzx eax,byte [rax+rbp] |
||
2206 | mov [RegYPos],eax |
||
2207 | mov eax,RegLTab |
||
2208 | movzx eax,byte [rax+rbp] |
||
2209 | mov [RegLDat],eax |
||
2210 | call SetContext |
||
2211 | jmp CPUCommon |
||
2212 | ;----------------------------------------------------------------------------- |
||
2213 | RegGoToMem: |
||
2214 | mov ebp,[RegXPtr] |
||
2215 | cmp ebp,9 |
||
2216 | jae GoToMemRAX.Next |
||
2217 | mov eax,[RegRTab+rbp*4] |
||
2218 | mov rax,[rax] |
||
2219 | GoToMemRAX: |
||
2220 | mov [DataAddr],rax |
||
2221 | .Next: jmp CPUCommon |
||
2222 | ;----------------------------------------------------------------------------- |
||
2223 | MemUp: dec [MemYPos] |
||
2224 | cmp [MemYPos],40 |
||
2225 | ja MemCommon |
||
2226 | inc [MemYPos] |
||
2227 | sub [DataAddr],8 |
||
2228 | jmp MemCommon |
||
2229 | ;----------------------------------------------------------------------------- |
||
2230 | MemDn: inc [MemYPos] |
||
2231 | cmp [MemYPos],49 |
||
2232 | jb MemCommon |
||
2233 | dec [MemYPos] |
||
2234 | add [DataAddr],8 |
||
2235 | jmp MemCommon |
||
2236 | ;----------------------------------------------------------------------------- |
||
2237 | MemPageUp: |
||
2238 | sub [DataAddr],8*8 |
||
2239 | jmp MemCommon |
||
2240 | ;----------------------------------------------------------------------------- |
||
2241 | MemPageDn: |
||
2242 | add [DataAddr],8*8 |
||
2243 | jmp MemCommon |
||
2244 | ;----------------------------------------------------------------------------- |
||
2245 | MemLeft:sub [MemXPos],3 |
||
2246 | cmp [MemXPos],11-3 |
||
2247 | ja MemCommon |
||
2248 | add [MemXPos],3*8 |
||
2249 | jmp MemUp |
||
2250 | ;----------------------------------------------------------------------------- |
||
2251 | MemRight: |
||
2252 | add [MemXPos],3 |
||
2253 | cmp [MemXPos],11-1+3*8 |
||
2254 | jb MemCommon |
||
2255 | sub [MemXPos],3*8 |
||
2256 | jmp MemDn |
||
2257 | ;----------------------------------------------------------------------------- |
||
2258 | MemHome:and [DataAddr],0 |
||
2259 | mov [MemXPos],11 |
||
2260 | MemCommon: |
||
2261 | jmp CPUCommon |
||
2262 | ;----------------------------------------------------------------------------- |
||
2263 | MemGetAddress: |
||
2264 | xor edx,edx |
||
2265 | mov ebx,3 |
||
2266 | mov eax,[MemXPos] |
||
2267 | sub al,11 |
||
2268 | div ebx |
||
2269 | add rax,[DataAddr] |
||
2270 | mov ecx,[MemYPos] |
||
2271 | sub cl,41 |
||
2272 | add ecx,ecx |
||
2273 | lea rax,[rax+rcx*8] |
||
2274 | ret |
||
2275 | ;----------------------------------------------------------------------------- |
||
2276 | MemIncB:call MemGetAddress |
||
2277 | mov rsi,rax |
||
2278 | mov rdi,rax |
||
2279 | call GetDataByte |
||
2280 | inc al |
||
2281 | call SafeStore |
||
2282 | jmp MemCommon |
||
2283 | ;----------------------------------------------------------------------------- |
||
2284 | MemDecB:call MemGetAddress |
||
2285 | mov rsi,rax |
||
2286 | mov rdi,rax |
||
2287 | call GetDataByte |
||
2288 | dec al |
||
2289 | call SafeStore |
||
2290 | jmp MemCommon |
||
2291 | ;----------------------------------------------------------------------------- |
||
2292 | MemNotB:call MemGetAddress |
||
2293 | mov rsi,rax |
||
2294 | mov rdi,rax |
||
2295 | call GetDataByte |
||
2296 | not al |
||
2297 | call SafeStore |
||
2298 | jmp MemCommon |
||
2299 | ;----------------------------------------------------------------------------- |
||
2300 | MemResB:call MemGetAddress |
||
2301 | mov rdi,rax |
||
2302 | mov al,0 |
||
2303 | call SafeStore |
||
2304 | jmp MemCommon |
||
2305 | ;----------------------------------------------------------------------------- |
||
2306 | ToggleBP: |
||
2307 | mov eax,[CPUYPos] |
||
2308 | mov rax,[AddrBuffer+(rax-1)*sizeof.dq] |
||
2309 | push rax |
||
2310 | call FindBreakPoint |
||
2311 | mov edx,eax |
||
2312 | inc eax |
||
2313 | pop rax |
||
2314 | jz .NotFound |
||
2315 | mov eax,edx |
||
2316 | call ClearBreakPoint |
||
2317 | jmp .Ret |
||
2318 | .NotFound: |
||
2319 | mov bl,1 |
||
2320 | call AddBreakPoint |
||
2321 | jnc .Ret |
||
2322 | mov esi,aBreakpointLimitExceeded |
||
2323 | .SayErr: |
||
2324 | call PutMessage |
||
2325 | .Ret: |
||
2326 | jmp CPUCommon |
||
2327 | ;----------------------------------------------------------------------------- |
||
2328 | ReturnTo: |
||
2329 | mov ecx,1024 ; try 1024 instructions |
||
2330 | mov esi,[_EIP] |
||
2331 | .0: mov ebp,esi |
||
2332 | call Decode |
||
2333 | mov eax,[BufferO+35+SkipAddr] |
||
2334 | mov ebx,'iret' |
||
2335 | cmp eax,ebx ; check for IRET |
||
2336 | jz .1 |
||
2337 | and eax,00FFFFFFh |
||
2338 | mov ebx,00746572h ;' ter' |
||
2339 | cmp eax,ebx ; check for RET |
||
2340 | jz .1 |
||
2341 | mov ebx,00706D6Ah ;' pmj' |
||
2342 | cmp eax,ebx ; check for JMP |
||
2343 | jz .1 |
||
2344 | loop .0 |
||
2345 | jmp WaitEvent |
||
2346 | .1: call OnResume.Jmp |
||
2347 | jmp WaitEvent |
||
2348 | ;----------------------------------------------------------------------------- |
||
2349 | JumpOver: |
||
2350 | mov esi,[_EIP] |
||
2351 | call Decode |
||
2352 | mov eax,[BufferO+35+SkipAddr] |
||
2353 | cmp eax,'call' ; check for CALL |
||
2354 | jz .DoIt |
||
2355 | cmp eax,'loop' ; check for LOOP.. |
||
2356 | jz .DoIt |
||
2357 | and eax,00FFFFFFh |
||
2358 | mov ebx,00746E69h ;' tni' |
||
2359 | cmp eax,ebx ; check for INT |
||
2360 | jz .DoIt |
||
2361 | mov ebx,00706572h ;' per' |
||
2362 | cmp eax,ebx ; check for REP |
||
2363 | jz .DoIt |
||
2364 | mov ebx,00706D6Ah ;' pmj' |
||
2365 | cmp eax,ebx ; check for JMP |
||
2366 | jz .DoIt |
||
2367 | mov ebx,006F6E6Ah ;' onj' |
||
2368 | cmp eax,ebx ; check for JNO |
||
2369 | jz .DoIt |
||
2370 | mov ebx,0065616Ah ;' eaj' |
||
2371 | cmp eax,ebx ; check for JAE |
||
2372 | jz .DoIt |
||
2373 | mov ebx,007A6E6Ah ;' znj' |
||
2374 | cmp eax,ebx ; check for JNZ |
||
2375 | jz .DoIt |
||
2376 | mov ebx,0065626Ah ;' ebj' |
||
2377 | cmp eax,ebx ; check for JBE |
||
2378 | jz .DoIt |
||
2379 | mov ebx,00736E6Ah ;' snj' |
||
2380 | mov ebx,00736E6Ah ;' snj' |
||
2381 | cmp eax,ebx ; check for JNS |
||
2382 | jz .DoIt |
||
2383 | mov ebx,0065706Ah ;' epj' |
||
2384 | cmp eax,ebx ; check for JPE |
||
2385 | jz .DoIt |
||
2386 | mov ebx,006F706Ah ;' opj' |
||
2387 | cmp eax,ebx ; check for JPO |
||
2388 | jz .DoIt |
||
2389 | mov ebx,0065676Ah ;' egj' |
||
2390 | cmp eax,ebx ; check for JGE |
||
2391 | jz .DoIt |
||
2392 | mov ebx,00656C6Ah ;' elj' |
||
2393 | cmp eax,ebx ; check for JLE |
||
2394 | jz .DoIt |
||
2395 | and eax,0000FFFFh |
||
2396 | mov ebx,00006F6Ah ;' oj' |
||
2397 | cmp eax,ebx ; check for JO |
||
2398 | jz .DoIt |
||
2399 | mov ebx,0000626Ah ;' bj' |
||
2400 | cmp eax,ebx ; check for JB |
||
2401 | jz .DoIt |
||
2402 | mov ebx,00007A6Ah ;' zj' |
||
2403 | cmp eax,ebx ; check for JZ |
||
2404 | jz .DoIt |
||
2405 | mov ebx,0000616Ah ;' aj' |
||
2406 | cmp eax,ebx ; check for JA |
||
2407 | jz .DoIt |
||
2408 | mov ebx,0000736Ah ;' sj' |
||
2409 | cmp eax,ebx ; check for JS |
||
2410 | jz .DoIt |
||
2411 | mov ebx,00006C6Ah ;' lj' |
||
2412 | cmp eax,ebx ; check for JL |
||
2413 | jz .DoIt |
||
2414 | mov ebx,0000676Ah ;' gj' |
||
2415 | cmp eax,ebx ; check for JG |
||
2416 | jz .DoIt |
||
2417 | jmp F7 |
||
2418 | .DoIt: mov ebp,esi |
||
2419 | call OnResume.Jmp |
||
2420 | jmp WaitEvent |
||
2421 | ;----------------------------------------------------------------------------- |
||
2422 | ComeHere: |
||
2423 | mov eax,[CPUYPos] |
||
2424 | mov rax,[AddrBuffer+(rax-1)*sizeof.dq] |
||
2425 | push eax |
||
2426 | call FindEnabledBreakPoint |
||
2427 | pop eax |
||
2428 | jz .GoOn |
||
2429 | mov bl,5 ; valid enabled one-shot |
||
2430 | call AddBreakPoint |
||
2431 | jnc .GoOn |
||
2432 | mov esi,aBreakpointLimitExceeded |
||
2433 | call PutMessage |
||
2434 | jmp WaitEvent |
||
2435 | .GoOn: call GoOn |
||
2436 | jmp WaitEvent |
||
2437 | ;----------------------------------------------------------------------------- |
||
2438 | NewAddress: |
||
2439 | mov eax,[CPUYPos] |
||
2440 | mov rax,[AddrBuffer+(rax-1)*sizeof.dq] |
||
2441 | mov [_EIP],eax |
||
2442 | call SetContext |
||
2443 | jmp CPUCommon |
||
2444 | ;----------------------------------------------------------------------------- |
||
2445 | CPUUp: cmp [CPUYPos],1 |
||
2446 | jbe .1 |
||
2447 | dec [CPUYPos] |
||
2448 | mov ebx,[CPUYPos] |
||
2449 | mov rsi,[AddrBuffer+(rbx-1)*sizeof.dq] |
||
2450 | call Decode |
||
2451 | jmp CPUCommon |
||
2452 | .1: call FindCodeUp |
||
2453 | mov [CodeAddr],rax |
||
2454 | jmp CPUCommon |
||
2455 | ;----------------------------------------------------------------------------- |
||
2456 | CPUDn: cmp [CPUYPos],28 |
||
2457 | jae .1 |
||
2458 | inc [CPUYPos] |
||
2459 | mov ebx,[CPUYPos] |
||
2460 | mov rsi,[AddrBuffer+(rbx-1)*sizeof.dq] |
||
2461 | call Decode |
||
2462 | jmp CPUCommon |
||
2463 | .1: mov rax,[AddrBuffer+sizeof.dq] |
||
2464 | mov [CodeAddr],rax |
||
2465 | jmp CPUCommon |
||
2466 | ;----------------------------------------------------------------------------- |
||
2467 | CPULeft:dec [CodeAddr] |
||
2468 | jmp CPUCommon |
||
2469 | ;----------------------------------------------------------------------------- |
||
2470 | CPURight: |
||
2471 | inc [CodeAddr] |
||
2472 | jmp CPUCommon |
||
2473 | ;----------------------------------------------------------------------------- |
||
2474 | CPUPgUp:mov ecx,28 |
||
2475 | .1: call FindCodeUp |
||
2476 | mov [AddrBuffer],rax |
||
2477 | loop .1 |
||
2478 | mov [CodeAddr],rax |
||
2479 | jmp CPUCommon |
||
2480 | ;----------------------------------------------------------------------------- |
||
2481 | CPUPgDn:mov rsi,[AddrBuffer+27*sizeof.dq] |
||
2482 | call Decode |
||
2483 | mov [CodeAddr],rsi |
||
2484 | jmp CPUCommon |
||
2485 | ;----------------------------------------------------------------------------- |
||
2486 | CPUHome:mov eax,[_EIP] |
||
2487 | mov [CodeAddr],rax |
||
2488 | mov [CPUYPos],1 |
||
2489 | CPUCommon: |
||
2490 | mov [AfterKey],1 |
||
2491 | call ShowImage |
||
2492 | jmp WaitEvent |
||
2493 | ;----------------------------------------------------------------------------- |
||
2494 | SafeLoadDD: |
||
2495 | push rcx rsi |
||
2496 | mov ecx,4 |
||
2497 | .Loop: call GetDataByte |
||
2498 | ror rax,8 |
||
2499 | inc rsi |
||
2500 | loop .Loop |
||
2501 | pop rsi rcx |
||
2502 | ret |
||
2503 | ;----------------------------------------------------------------------------- |
||
2504 | CPUGoToMem: |
||
2505 | mov eax,[CPUYPos] |
||
2506 | mov rsi,[(rax-1)*sizeof.dq+AddrBuffer] |
||
2507 | call Decode |
||
2508 | mov al,[Inst.Arg1.Mem] |
||
2509 | or al,[Inst.Arg2.Mem] |
||
2510 | or al,[Inst.Arg3.Mem] |
||
2511 | or al,[Inst.Arg4.Mem] |
||
2512 | or al,[Inst.Arg5.Mem] |
||
2513 | jnz .Mem |
||
2514 | ; |
||
2515 | mov rdx,[Inst.Arg1.Imm] |
||
2516 | cmp [Inst.IsAddress],0 ;relative |
||
2517 | jnz .Ofs |
||
2518 | |||
2519 | cmp [Inst.MemSeparator],0 |
||
2520 | jz .NoFar |
||
2521 | mov ax,[Inst.Point] |
||
2522 | cmp ax,TDWORD |
||
2523 | jz .DW2 |
||
2524 | cmp ax,TFWORD |
||
2525 | jz .FW2 |
||
2526 | .NoFar: |
||
2527 | jmp WaitEvent |
||
2528 | .DW2: |
||
2529 | sub rsi,4 |
||
2530 | call SafeLoadDD |
||
2531 | movzx edx,ax |
||
2532 | shr eax,16 |
||
2533 | jmp .All |
||
2534 | .FW2: |
||
2535 | sub rsi,6 |
||
2536 | call SafeLoadDD |
||
2537 | mov edx,eax |
||
2538 | add rsi,4 |
||
2539 | call SafeLoadDD |
||
2540 | movzx eax,ax |
||
2541 | jmp .All |
||
2542 | ; |
||
2543 | .Mem: |
||
2544 | ; |
||
2545 | cmp [Inst.Point],0 |
||
2546 | jz .Ptr |
||
2547 | movzx edx,[Inst.RandSize] |
||
2548 | and dl,7Fh |
||
2549 | push rdx |
||
2550 | call GetLinAddr |
||
2551 | pop rdx |
||
2552 | cmp dl,3 |
||
2553 | jz .DW |
||
2554 | cmp dl,8 |
||
2555 | jz .FW |
||
2556 | cmp dl,9 |
||
2557 | jz .TW |
||
2558 | jmp WaitEvent |
||
2559 | .DW: |
||
2560 | mov rsi,rax |
||
2561 | call SafeLoadDD |
||
2562 | movzx edx,ax |
||
2563 | shr eax,16 |
||
2564 | jmp .All |
||
2565 | .FW: |
||
2566 | mov rsi,rax |
||
2567 | call SafeLoadDD |
||
2568 | mov edx,eax |
||
2569 | add rsi,4 |
||
2570 | call SafeLoadDD |
||
2571 | movzx eax,ax |
||
2572 | jmp .All |
||
2573 | .TW: |
||
2574 | mov rsi,rax |
||
2575 | call SafeLoadDD |
||
2576 | mov rdx,rax |
||
2577 | add rsi,8 |
||
2578 | call SafeLoadDD |
||
2579 | movzx eax,ax |
||
2580 | .All: |
||
2581 | ;verr eax |
||
2582 | ;jnz .Err |
||
2583 | ;mov [Reg.CS],eax |
||
2584 | ;call SelectorInit |
||
2585 | .Ofs: |
||
2586 | mov [CodeAddr],rdx |
||
2587 | mov [CPUYPos],1 |
||
2588 | if 0 |
||
2589 | call RepaintText |
||
2590 | jmp ShowRegs |
||
2591 | else |
||
2592 | jmp CPUCommon |
||
2593 | end if |
||
2594 | .Err: |
||
2595 | jmp WaitEvent |
||
2596 | .Ptr: |
||
2597 | call GetMemAddress |
||
2598 | jmp GoToMemRAX |
||
2599 | ;----------------------------------------------------------------------------- |
||
2600 | GetLinAddr: |
||
2601 | call GetSeg |
||
2602 | mov [AddressStr],dx |
||
2603 | ; |
||
2604 | xor ebx,ebx |
||
2605 | mov ecx,1 |
||
2606 | ; |
||
2607 | movzx eax,[Inst.Scale] |
||
2608 | cmp al,-1 |
||
2609 | jz @F |
||
2610 | mov cl,[rax+AnScale] |
||
2611 | @@: |
||
2612 | movzx eax,[Inst.Base] |
||
2613 | cmp al,-1 |
||
2614 | jz @F |
||
2615 | mov eax,[rax*4+RegVTab] |
||
2616 | mov rax,[rax] |
||
2617 | call Address2Reg |
||
2618 | add rbx,rax |
||
2619 | @@: |
||
2620 | movzx eax,[Inst.Indx] |
||
2621 | cmp al,-1 |
||
2622 | jz @F |
||
2623 | mov eax,[rax*4+RegVTab] |
||
2624 | mov rax,[rax] |
||
2625 | call Address2Reg |
||
2626 | mul rcx |
||
2627 | add rbx,rax |
||
2628 | @@: |
||
2629 | cmp [Inst.DispSize],0 |
||
2630 | jz @F |
||
2631 | mov rax,[Inst.Disp] |
||
2632 | call Address2Reg |
||
2633 | add rbx,rax |
||
2634 | @@: |
||
2635 | mov rax,rbx |
||
2636 | call Address2Reg |
||
2637 | mov rbx,rax |
||
2638 | AddSeg: |
||
2639 | if 0 |
||
2640 | call GetSegm |
||
2641 | movzx eax,al |
||
2642 | mov rax,[rax*sizeof.dq+ESBase] |
||
2643 | add rax,rbx |
||
2644 | end if |
||
2645 | ret |
||
2646 | ;----------------------------------------------------------------------------- |
||
2647 | ShowFPURegs: |
||
2648 | if 1 |
||
2649 | mov ah,3Fh |
||
2650 | xor ecx,ecx |
||
2651 | mov edi,ConsoleDataPtr |
||
2652 | mov al, 'Â' |
||
2653 | imul edx,[CurWidth],49+1 |
||
2654 | sub edx,31 |
||
2655 | call DrawChar |
||
2656 | mov al, 'Ä' |
||
2657 | mov cl,28 |
||
2658 | call DrawLine |
||
2659 | imul edx,[CurWidth],50+1 |
||
2660 | sub edx,31 |
||
2661 | mov al, '³' |
||
2662 | mov cl,9 |
||
2663 | call DrawDown |
||
2664 | mov al, 'º' |
||
2665 | imul edx,[CurWidth],55 |
||
2666 | dec edx |
||
2667 | call DrawChar |
||
2668 | if 0 |
||
2669 | mov al, 'À' |
||
2670 | imul edx,[CurWidth],49+1+10 |
||
2671 | sub edx,31 |
||
2672 | call DrawChar |
||
2673 | mov al, 'Ä' |
||
2674 | mov cl,28+1 |
||
2675 | call DrawLine |
||
2676 | end if |
||
2677 | end if |
||
2678 | mov ebp,[CurWidth] |
||
2679 | lea eax,[ebp-28] |
||
2680 | mov [Color],3Ah |
||
2681 | mov [XPos],al |
||
2682 | mov [YPos],49 |
||
2683 | lea edx,[Msg10F] |
||
2684 | call PrintS |
||
2685 | mov [Color],30h |
||
2686 | lea eax,[ebp-30] |
||
2687 | mov [XPos],al |
||
2688 | mov [YPos],50 |
||
2689 | lea edx,[Msg11F] |
||
2690 | call PrintS |
||
2691 | lea eax,[ebp-30] |
||
2692 | mov [XPos],al |
||
2693 | inc [YPos] |
||
2694 | lea edx,[Msg12F] |
||
2695 | call PrintS |
||
2696 | lea eax,[ebp-30] |
||
2697 | mov [XPos],al |
||
2698 | inc [YPos] |
||
2699 | lea edx,[Msg13F] |
||
2700 | call PrintS |
||
2701 | lea eax,[ebp-30] |
||
2702 | mov [XPos],al |
||
2703 | inc [YPos] |
||
2704 | lea edx,[Msg14F] |
||
2705 | call PrintS |
||
2706 | lea eax,[ebp-30] |
||
2707 | mov [XPos],al |
||
2708 | inc [YPos] |
||
2709 | lea edx,[Msg15F] |
||
2710 | call PrintS |
||
2711 | lea eax,[ebp-30] |
||
2712 | mov [XPos],al |
||
2713 | inc [YPos] |
||
2714 | lea edx,[Msg16F] |
||
2715 | call PrintS |
||
2716 | lea eax,[ebp-30] |
||
2717 | mov [XPos],al |
||
2718 | inc [YPos] |
||
2719 | lea edx,[Msg17F] |
||
2720 | call PrintS |
||
2721 | lea eax,[ebp-30] |
||
2722 | mov [XPos],al |
||
2723 | inc [YPos] |
||
2724 | lea edx,[Msg18F] |
||
2725 | call PrintS |
||
2726 | lea eax,[ebp-30] |
||
2727 | mov [XPos],al |
||
2728 | inc [YPos] |
||
2729 | lea edx,[Msg19F] |
||
2730 | call PrintS |
||
2731 | fninit ; reinitialize FPU |
||
2732 | .1: lea eax,[ebp-26] |
||
2733 | mov [XPos],al |
||
2734 | mov [YPos],50 |
||
2735 | xor edi,edi ; displacement |
||
2736 | mov bl,8 ; counter |
||
2737 | movzx eax,word [_FTW] |
||
2738 | mov [Temp],eax |
||
2739 | movzx eax,[_FSW] |
||
2740 | shr eax,11 |
||
2741 | and eax,07h |
||
2742 | lea ecx,[rax*2] |
||
2743 | ror word [Temp],cl |
||
2744 | .Loop: ; |
||
2745 | mov [Color],30h |
||
2746 | mov eax,dword [_ST0+rdi] |
||
2747 | cmp eax,dword [_ST0+rdi+Plus] |
||
2748 | jnz .NotEQ |
||
2749 | mov eax,dword [_ST0+rdi+4] |
||
2750 | cmp eax,dword [_ST0+rdi+Plus+4] |
||
2751 | jnz .NotEQ |
||
2752 | mov ax,word [_ST0+rdi+8] |
||
2753 | cmp ax,word [_ST0+rdi+Plus+8] |
||
2754 | jz .YeaEQ |
||
2755 | .NotEQ: mov [Color],3Fh |
||
2756 | .YeaEQ: |
||
2757 | mov eax,[Temp] |
||
2758 | ror word [Temp],02h |
||
2759 | and eax,0003h |
||
2760 | cmp eax,0003h |
||
2761 | jz .__ftoa_empty |
||
2762 | fld tbyte [_ST0+rdi] |
||
2763 | fxam |
||
2764 | fstsw ax |
||
2765 | mov al,ah |
||
2766 | ; C= 3 210 |
||
2767 | and al,01000101b |
||
2768 | jz .__ftoa_err ; unsupported number |
||
2769 | cmp al,00000001b |
||
2770 | jz .__ftoa_NaN ; NaN number |
||
2771 | cmp al,00000101b |
||
2772 | jz .__ftoa_inf ; infinity |
||
2773 | cmp al,01000000b |
||
2774 | jz .__ftoa_zero ; zero |
||
2775 | cmp al,01000100b |
||
2776 | jz .__ftoa_den ; denormal |
||
2777 | cmp al,01000001b |
||
2778 | jz .__ftoa_unu ; unused |
||
2779 | cmp al,01000101b |
||
2780 | jz .__ftoa_unu ; unused |
||
2781 | mov eax,57 |
||
2782 | call _float2dec |
||
2783 | add eax,17 |
||
2784 | mov edx,eax ; save exponent in edx |
||
2785 | |||
2786 | sub esp,12 |
||
2787 | fbstp tbyte [rsp] |
||
2788 | mov cx,[rsp+8] |
||
2789 | mov esi,[rsp+4] |
||
2790 | mov ebp,[rsp+0] |
||
2791 | add esp,12 |
||
2792 | |||
2793 | mov bh,15 |
||
2794 | and ch,80h |
||
2795 | mov al,'+' |
||
2796 | jz .2 |
||
2797 | mov al,'-' |
||
2798 | .2: call PrintC |
||
2799 | call __ftoa_char |
||
2800 | call PrintC |
||
2801 | mov al,'.' |
||
2802 | call PrintC |
||
2803 | .3: call __ftoa_char |
||
2804 | call PrintC |
||
2805 | dec bh |
||
2806 | jnz .3 |
||
2807 | |||
2808 | mov al,'E' |
||
2809 | call PrintC |
||
2810 | test edx,edx |
||
2811 | mov al,'+' |
||
2812 | jns .4 |
||
2813 | mov al,'-' |
||
2814 | neg edx |
||
2815 | .4: call PrintC |
||
2816 | |||
2817 | mov bh,4 |
||
2818 | mov eax,edx |
||
2819 | xor ebp,ebp |
||
2820 | .5: mov ecx,10 |
||
2821 | xor edx,edx |
||
2822 | idiv ecx |
||
2823 | shl ebp,8 |
||
2824 | or ebp,edx |
||
2825 | dec bh |
||
2826 | jnz .5 |
||
2827 | |||
2828 | mov bh,4 |
||
2829 | .6: mov eax,ebp |
||
2830 | add al,30h |
||
2831 | shr ebp,8 |
||
2832 | call PrintC |
||
2833 | dec bh |
||
2834 | jnz .6 |
||
2835 | |||
2836 | .Next: add edi,16 |
||
2837 | mov eax,[CurWidth] |
||
2838 | sub eax,26 |
||
2839 | mov [XPos],al |
||
2840 | inc [YPos] |
||
2841 | dec bl |
||
2842 | jnz .Loop |
||
2843 | |||
2844 | mov eax,[CurWidth] |
||
2845 | sub eax,27 |
||
2846 | mov [XPos],al |
||
2847 | mov [Color],30h |
||
2848 | mov ax,[_FCW] ; CW |
||
2849 | cmp ax,[_FCW+Plus] |
||
2850 | ifnz mov [Color],3Fh |
||
2851 | call PrintAX |
||
2852 | add [XPos],5 |
||
2853 | mov [Color],30h |
||
2854 | mov ax,[_FSW] ; SW |
||
2855 | cmp ax,[_FSW+Plus] |
||
2856 | ifnz mov [Color],3Fh |
||
2857 | call PrintAX |
||
2858 | add [XPos],6 |
||
2859 | mov [Color],30h |
||
2860 | mov ax,word [_FTW] ; Tag |
||
2861 | cmp ax,word [_FTW+Plus] |
||
2862 | ifnz mov [Color],3Fh |
||
2863 | call PrintAX |
||
2864 | fwait |
||
2865 | ret |
||
2866 | |||
2867 | .__ftoa_err: |
||
2868 | lea edx,[Msg1EF1] |
||
2869 | jmp .__ftoa_ |
||
2870 | .__ftoa_NaN: |
||
2871 | and ah,00000010h |
||
2872 | mov al,'+' |
||
2873 | jz .__ftoa_NaN_ |
||
2874 | mov al,'-' |
||
2875 | .__ftoa_NaN_: |
||
2876 | lea edx,[Msg1EF2] |
||
2877 | mov [rdx],al |
||
2878 | jmp .__ftoa_ |
||
2879 | .__ftoa_inf: |
||
2880 | and ah,00000010h |
||
2881 | mov al,'+' |
||
2882 | jz .__ftoa_inf_ |
||
2883 | mov al,'-' |
||
2884 | .__ftoa_inf_: |
||
2885 | lea edx,[Msg1EF3] |
||
2886 | mov [rdx],al |
||
2887 | jmp .__ftoa_ |
||
2888 | .__ftoa_zero: |
||
2889 | and ah,00000010h |
||
2890 | mov al,'+' |
||
2891 | jz .__ftoa_zero_ |
||
2892 | mov al,'-' |
||
2893 | .__ftoa_zero_: |
||
2894 | lea edx,[Msg1EF4] |
||
2895 | mov [rdx],al |
||
2896 | jmp .__ftoa_ |
||
2897 | .__ftoa_den: |
||
2898 | and ah,00000010h |
||
2899 | mov al,'+' |
||
2900 | jz .__ftoa_den_ |
||
2901 | mov al,'-' |
||
2902 | .__ftoa_den_: |
||
2903 | lea edx,[Msg1EF5] |
||
2904 | mov [rdx],al |
||
2905 | jmp .__ftoa_ |
||
2906 | .__ftoa_unu: |
||
2907 | lea edx,[Msg1EF6] |
||
2908 | jmp .__ftoa_ |
||
2909 | .__ftoa_empty: |
||
2910 | lea edx,[Msg1EF7] |
||
2911 | .__ftoa_: |
||
2912 | call PrintS |
||
2913 | jmp .Next |
||
2914 | |||
2915 | __ftoa_char: |
||
2916 | mov al,cl |
||
2917 | shl ebp,1 |
||
2918 | rcl esi,1 |
||
2919 | rcl cl,1 |
||
2920 | shl ebp,1 |
||
2921 | rcl esi,1 |
||
2922 | rcl cl,1 |
||
2923 | shl ebp,1 |
||
2924 | rcl esi,1 |
||
2925 | rcl cl,1 |
||
2926 | shl ebp,1 |
||
2927 | rcl esi,1 |
||
2928 | rcl cl,1 |
||
2929 | shr al,4 |
||
2930 | add al,30h |
||
2931 | ret |
||
2932 | |||
2933 | _float2dec: |
||
2934 | sub esp,3*4 |
||
2935 | fstcw word [rsp] |
||
2936 | mov word [rsp+2],03BFh |
||
2937 | fldcw word [rsp+2] |
||
2938 | mov [rsp+4],eax |
||
2939 | fld st0 |
||
2940 | fxtract |
||
2941 | fstp st0 |
||
2942 | fisubr dword [rsp+4] |
||
2943 | fldl2t |
||
2944 | fdivp st1,st0 |
||
2945 | frndint |
||
2946 | fist dword [rsp+8] |
||
2947 | call _exp10 |
||
2948 | fmulp st1,st0 |
||
2949 | fldcw word [rsp] |
||
2950 | mov eax,[rsp+2*4] |
||
2951 | add esp,3*4 |
||
2952 | neg eax |
||
2953 | ret |
||
2954 | |||
2955 | _exp10: fldl2t |
||
2956 | fmulp st1,st0 |
||
2957 | _exp2: sub esp,2*4 |
||
2958 | fstcw word [rsp] |
||
2959 | mov word [rsp+2],03BFh |
||
2960 | fldcw word [rsp+2] |
||
2961 | fld st0 |
||
2962 | frndint |
||
2963 | fxch |
||
2964 | fsub st0,st1 |
||
2965 | ftst |
||
2966 | fstsw word [rsp+4] |
||
2967 | and byte [rsp+5],45h |
||
2968 | cmp byte [rsp+5],01h |
||
2969 | ja .Err |
||
2970 | je .Neg |
||
2971 | f2xm1 |
||
2972 | fld1 |
||
2973 | faddp st1,st0 |
||
2974 | fxch |
||
2975 | fld1 |
||
2976 | fscale |
||
2977 | fmulp st2,st0 |
||
2978 | fstp st0 |
||
2979 | jmp .Done |
||
2980 | .Neg: fabs |
||
2981 | f2xm1 |
||
2982 | fld1 |
||
2983 | faddp st1,st0 |
||
2984 | fxch |
||
2985 | fld1 |
||
2986 | fscale |
||
2987 | fdivrp st2,st0 |
||
2988 | fstp st0 |
||
2989 | .Done: fldcw word [rsp] |
||
2990 | add esp,2*4 |
||
2991 | ret |
||
2992 | .Err: fstp st0 |
||
2993 | fstp st0 |
||
2994 | fld1 |
||
2995 | jmp .Done |
||
2996 | ;----------------------------------------------------------------------------- |
||
2997 | ShowMMXRegs: |
||
2998 | if 1 |
||
2999 | mov ah,3Fh |
||
3000 | xor ecx,ecx |
||
3001 | mov edi,ConsoleDataPtr |
||
3002 | mov al, 'Â' |
||
3003 | imul edx,[CurWidth],49+1 |
||
3004 | sub edx,52 |
||
3005 | call DrawChar |
||
3006 | imul edx,[CurWidth],50+1 |
||
3007 | sub edx,52 |
||
3008 | mov al, '³' |
||
3009 | mov cl,9 |
||
3010 | call DrawDown |
||
3011 | mov al, 'º' |
||
3012 | imul edx,[CurWidth],54 |
||
3013 | dec edx |
||
3014 | call DrawChar |
||
3015 | end if |
||
3016 | mov ebx,[CurWidth] |
||
3017 | mov bh,bl |
||
3018 | sub bh,47 |
||
3019 | sub bl,51 |
||
3020 | |||
3021 | mov [Color],3Ah |
||
3022 | mov [XPos],bl |
||
3023 | add [XPos],2 |
||
3024 | mov [YPos],49 |
||
3025 | lea edx,[MsgMMX] |
||
3026 | call PrintS |
||
3027 | mov [Color],30h |
||
3028 | mov [XPos],bl |
||
3029 | mov [YPos],50 |
||
3030 | lea edx,[MsgMM0] |
||
3031 | call PrintS |
||
3032 | mov [XPos],bl |
||
3033 | inc [YPos] |
||
3034 | lea edx,[MsgMM1] |
||
3035 | call PrintS |
||
3036 | mov [XPos],bl |
||
3037 | inc [YPos] |
||
3038 | lea edx,[MsgMM2] |
||
3039 | call PrintS |
||
3040 | mov [XPos],bl |
||
3041 | inc [YPos] |
||
3042 | lea edx,[MsgMM3] |
||
3043 | call PrintS |
||
3044 | mov [XPos],bl |
||
3045 | inc [YPos] |
||
3046 | lea edx,[MsgMM4] |
||
3047 | call PrintS |
||
3048 | mov [XPos],bl |
||
3049 | inc [YPos] |
||
3050 | lea edx,[MsgMM5] |
||
3051 | call PrintS |
||
3052 | mov [XPos],bl |
||
3053 | inc [YPos] |
||
3054 | lea edx,[MsgMM6] |
||
3055 | call PrintS |
||
3056 | mov [XPos],bl |
||
3057 | inc [YPos] |
||
3058 | lea edx,[MsgMM7] |
||
3059 | call PrintS |
||
3060 | mov [XPos],bl |
||
3061 | inc [YPos] |
||
3062 | lea edx,[MsgXMMX] |
||
3063 | call PrintS |
||
3064 | inc [XPos] |
||
3065 | add edx,4 |
||
3066 | mov [Color],3Eh |
||
3067 | call PrintS |
||
3068 | mov [YPos],50 |
||
3069 | mov bl,8 ; counter |
||
3070 | lea esi,[_MM0] |
||
3071 | .Skip: lea ecx,[_MM0+Plus] |
||
3072 | .Loop: mov [XPos],bh |
||
3073 | mov [Color],30h |
||
3074 | mov eax,[rsi+0] |
||
3075 | cmp eax,[rcx+0] |
||
3076 | jne @F |
||
3077 | mov eax,[rsi+4] |
||
3078 | cmp eax,[rcx+4] |
||
3079 | je .@ |
||
3080 | @@: mov [Color],3Fh |
||
3081 | .@: mov eax,[rsi+4] |
||
3082 | call PrintEAX |
||
3083 | mov eax,[rsi+0] |
||
3084 | call PrintEAX |
||
3085 | inc [YPos] |
||
3086 | add esi,16 |
||
3087 | add ecx,16 |
||
3088 | dec bl |
||
3089 | jnz .Loop |
||
3090 | ret |
||
3091 | ;----------------------------------------------------------------------------- |
||
3092 | ShowXMMRegs: |
||
3093 | mov [Color],3Ah |
||
3094 | mov [XPos],3 |
||
3095 | mov [YPos],49 |
||
3096 | lea edx,[MsgXMM] |
||
3097 | call PrintS |
||
3098 | mov [Color],30h |
||
3099 | mov [XPos],1 |
||
3100 | mov [YPos],50 |
||
3101 | lea edx,[MsgXM0] |
||
3102 | call PrintS |
||
3103 | mov [XPos],1 |
||
3104 | inc [YPos] |
||
3105 | lea edx,[MsgXM1] |
||
3106 | call PrintS |
||
3107 | mov [XPos],1 |
||
3108 | inc [YPos] |
||
3109 | lea edx,[MsgXM2] |
||
3110 | call PrintS |
||
3111 | mov [XPos],1 |
||
3112 | inc [YPos] |
||
3113 | lea edx,[MsgXM3] |
||
3114 | call PrintS |
||
3115 | mov [XPos],1 |
||
3116 | inc [YPos] |
||
3117 | lea edx,[MsgXM4] |
||
3118 | call PrintS |
||
3119 | mov [XPos],1 |
||
3120 | inc [YPos] |
||
3121 | lea edx,[MsgXM5] |
||
3122 | call PrintS |
||
3123 | mov [XPos],1 |
||
3124 | inc [YPos] |
||
3125 | lea edx,[MsgXM6] |
||
3126 | call PrintS |
||
3127 | mov [XPos],1 |
||
3128 | inc [YPos] |
||
3129 | lea edx,[MsgXM7] |
||
3130 | call PrintS |
||
3131 | mov [YPos],50 |
||
3132 | mov bl,8 ; counter |
||
3133 | lea esi,[_XMM0] |
||
3134 | .Skip: lea ecx,[_XMM0+Plus] |
||
3135 | .Loop: mov [XPos],6 |
||
3136 | mov [Color],30h |
||
3137 | mov eax,[rsi+4*0] |
||
3138 | cmp eax,[rcx+4*0] |
||
3139 | jne @F |
||
3140 | mov eax,[rsi+4*1] |
||
3141 | cmp eax,[rcx+4*1] |
||
3142 | jne @F |
||
3143 | mov eax,[rsi+4*2] |
||
3144 | cmp eax,[rcx+4*2] |
||
3145 | jne @F |
||
3146 | mov eax,[rsi+4*3] |
||
3147 | cmp eax,[rcx+4*3] |
||
3148 | je .@ |
||
3149 | @@: mov [Color],3Fh |
||
3150 | .@: mov eax,[rsi+4*3] |
||
3151 | call PrintEAX |
||
3152 | mov eax,[rsi+4*2] |
||
3153 | call PrintEAX |
||
3154 | mov eax,[rsi+4*1] |
||
3155 | call PrintEAX |
||
3156 | mov eax,[rsi+4*0] |
||
3157 | call PrintEAX |
||
3158 | inc [YPos] |
||
3159 | add esi,16 |
||
3160 | add ecx,16 |
||
3161 | dec bl |
||
3162 | jnz .Loop |
||
3163 | mov [XPos],1 |
||
3164 | lea edx,[MsgXCSR] |
||
3165 | call PrintS |
||
3166 | mov [XPos],1+6+9 |
||
3167 | lea edx,[MsgMCSR] |
||
3168 | call PrintS |
||
3169 | mov [XPos],7 |
||
3170 | mov eax,[_MXCSR] |
||
3171 | cmp eax,[_MXCSR+Plus] |
||
3172 | mov [Color],30h |
||
3173 | ifnz mov [Color],3Fh |
||
3174 | call PrintEAX |
||
3175 | mov [XPos],7+9+11 |
||
3176 | mov eax,[_MXCSRM] |
||
3177 | cmp eax,[_MXCSRM+Plus] |
||
3178 | mov [Color],30h |
||
3179 | ifnz mov [Color],3Fh |
||
3180 | call PrintEAX |
||
3181 | ret |
||
3182 | ;----------------------------------------------------------------------------- |
||
3183 | Msg10 db 'CPU Registers',0 |
||
3184 | ;----------------------------------------------------------------------------- |
||
3185 | Msg11 db 'EAX 00000000 EFL 00000000 ',0 |
||
3186 | Msg12 db 'EBX 00000000 EIP 00000000 ',0 |
||
3187 | Msg13 db 'ECX 00000000 CS 0000/00000000/0000 ',0 |
||
3188 | Msg14 db 'EDX 00000000 DS 0000/00000000/0000 ',0 |
||
3189 | Msg15 db 'ESI 00000000 ES 0000/00000000/0000 ',0 |
||
3190 | Msg16 db 'EDI 00000000 FS 0000/00000000/0000 ',0 |
||
3191 | Msg17 db 'EBP 00000000 GS 0000/00000000/0000 ',0 |
||
3192 | Msg18 db 'ESP 00000000 SS 0000/00000000/0000 ',0 |
||
3193 | Msg19 db 'V R N IO O D I T S Z A P C ',0 |
||
3194 | Msg20 db '0 0 0 00 0 0 0 0 0 0 0 0 0 ',0 |
||
3195 | ;----------------------------------------------------------------------------- |
||
3196 | Msg22 db '[ds:esi]',0 |
||
3197 | Msg23 db '[es:edi]',0 |
||
3198 | MsgX2 db '[ds:edx]',0 |
||
3199 | MsgX3 db '[ds:ebx]',0 |
||
3200 | MsgX4 db '[ss:ebp]',0 |
||
3201 | MsgX5 db '[ds:ecx]',0 |
||
3202 | ;----------------------------------------------------------------------------- |
||
3203 | Msg2SIP db '[esi+',0 |
||
3204 | Msg2SIM db '[esi-',0 |
||
3205 | Msg2DIP db '[edi+',0 |
||
3206 | Msg2DIM db '[edi-',0 |
||
3207 | Msg2BXP db '[ebx+',0 |
||
3208 | Msg2BXM db '[ebx-',0 |
||
3209 | Msg2DXP db '[edx+',0 |
||
3210 | Msg2DXM db '[edx-',0 |
||
3211 | Msg2BPP db '[ebp+',0 |
||
3212 | Msg2BPM db '[ebp-',0 |
||
3213 | Msg3SPP db '[esp+',0 |
||
3214 | Msg3SPM db '[esp-',0 |
||
3215 | Msg2ER db '--',0 |
||
3216 | ;----------------------------------------------------------------------------- |
||
3217 | Msg00 db 'CPU ',0 |
||
3218 | CPUTable \ |
||
3219 | dd '8086' |
||
3220 | dd '186' |
||
3221 | dd '286' |
||
3222 | dd '386' |
||
3223 | dd '486' |
||
3224 | dd '586' |
||
3225 | dd '686' |
||
3226 | FPUTable \ |
||
3227 | db '/None',0,0,0 |
||
3228 | db '/8087',0,0,0 |
||
3229 | dd '/287',0 |
||
3230 | dd '/387',0 |
||
3231 | dd '/487',0 |
||
3232 | dd '/587',0 |
||
3233 | dd '/687',0 |
||
3234 | ;----------------------------------------------------------------------------- |
||
3235 | Msg21 db 'Memory',0 |
||
3236 | ;----------------------------------------------------------------------------- |
||
3237 | Msg30 db 'Stack',0 |
||
3238 | ;----------------------------------------------------------------------------- |
||
3239 | Msg3M db 'Messages',0 |
||
3240 | ;----------------------------------------------------------------------------- |
||
3241 | Msg40 db 'Address: ',8,3Fh,'00000000 ',8,3Ah,'=',8,3Fh,' 00h',0 |
||
3242 | ;----------------------------------------------------------------------------- |
||
3243 | Msg10F db 'FPU Registers',0 |
||
3244 | Msg11F db 'ST0',0 |
||
3245 | Msg12F db 'ST1',0 |
||
3246 | Msg13F db 'ST2',0 |
||
3247 | Msg14F db 'ST3',0 |
||
3248 | Msg15F db 'ST4',0 |
||
3249 | Msg16F db 'ST5',0 |
||
3250 | Msg17F db 'ST6',0 |
||
3251 | Msg18F db 'ST7',0 |
||
3252 | Msg19F db 'CW=0000 SW=0000 TAG=0000',0 |
||
3253 | ;----------------------------------------------------------------------------- |
||
3254 | MsgMMX db 'MMX Registers',0 |
||
3255 | MsgMM0 db 'MM0',0 |
||
3256 | MsgMM1 db 'MM1',0 |
||
3257 | MsgMM2 db 'MM2',0 |
||
3258 | MsgMM3 db 'MM3',0 |
||
3259 | MsgMM4 db 'MM4',0 |
||
3260 | MsgMM5 db 'MM5',0 |
||
3261 | MsgMM6 db 'MM6',0 |
||
3262 | MsgMM7 db 'MM7',0 |
||
3263 | ;----------------------------------------------------------------------------- |
||
3264 | MsgXMM db 'XMM Registers',0 |
||
3265 | MsgXM0 db 'XMM0',0 |
||
3266 | MsgXM1 db 'XMM1',0 |
||
3267 | MsgXM2 db 'XMM2',0 |
||
3268 | MsgXM3 db 'XMM3',0 |
||
3269 | MsgXM4 db 'XMM4',0 |
||
3270 | MsgXM5 db 'XMM5',0 |
||
3271 | MsgXM6 db 'XMM6',0 |
||
3272 | MsgXM7 db 'XMM7',0 |
||
3273 | ;----------------------------------------------------------------------------- |
||
3274 | Msg1EF1 db 'Unsupported ',0 |
||
3275 | Msg1EF2 db '+NaN ',0 |
||
3276 | Msg1EF3 db '+Infinity ',0 |
||
3277 | Msg1EF4 db '+0.0 ',0 |
||
3278 | Msg1EF5 db '+Denormal ',0 |
||
3279 | Msg1EF6 db 'Unused ',0 |
||
3280 | Msg1EF7 db 'Empty ',0 |
||
3281 | ;----------------------------------------------------------------------------- |
||
3282 | MsgXMMX db 'CPU',0,'GenuineIntel',0 |
||
3283 | ;----------------------------------------------------------------------------- |
||
3284 | MsgXCSR db 'MXCSR=',0 |
||
3285 | MsgMCSR db 'MXCSR_MASK=',0 |
||
3286 | ;----------------------------------------------------------------------------- |
||
3287 | Msg50 db 8,74h,'F1',8,70h,'-Show ' |
||
3288 | db 8,74h,'F2',8,70h,'-BreakPnt ' |
||
3289 | db 8,74h,'F3',8,70h,'-Return ' |
||
3290 | db 8,74h,'F4',8,70h,'-Here ' |
||
3291 | db 8,74h,'F5',8,70h,'-Screen ' |
||
3292 | db 8,74h,'F6',8,70h,'-New ' |
||
3293 | db 8,74h,'F7',8,70h,'-Trace ' |
||
3294 | db 8,74h,'F8',8,70h,'-Step ' |
||
3295 | db 8,74h,'F9',8,70h,'-Run ' |
||
3296 | db 8,74h,'F10',8,70h,'-Over ' |
||
3297 | db 0 |
||
3298 | ;----------------------------------------------------------------------------- |
||
3299 | even 4 |
||
3300 | RegVTab dd _EAX,_ECX,_EDX,_EBX,_ESP,_EBP,_ESI,_EDI,_EIP |
||
3301 | RegRTab dd _EAX,_EBX,_ECX,_EDX,_ESI,_EDI,_EBP,_ESP,_EIP |
||
3302 | dd 0800h,0400h,0200h,0080h,0040h,0010h,0004h,0001h |
||
3303 | ;----------------------------------------------------------------------------- |
||
3304 | RegXTab db 1, 1, 1, 1, 1, 1, 1, 1, 14, 10,12,14,18, 21,23,25,27 |
||
3305 | RegYTab db 30,31,32,33,34,35,36,37, 31, 39,39,39,39, 39,39,39,39 |
||
3306 | RegLTab db 12,12,12,12,12,12,12,12, 12, 1, 1, 1, 1, 1, 1, 1, 1 |
||
3307 | ;----------------------------------------------------------------------------- |
||
3308 | CursorTab dd CPUCursor,RegCursor,MemCursor,StkCursor |
||
3309 | WindowTab dd CPUWindow,RegWindow,MemWindow,StkWindow |
||
3310 | ;----------------------------------------------------------------------------- |
||
3311 | HexBuf: db 8 dup 20h,0 |
||
3312 | ;----------------------------------------------------------------------------- |
||
3313 | XPos db 0 |
||
3314 | YPos db 0 |
||
3315 | Color db 7 |
||
3316 | ;----------------------------------------------------------------------------- |