📄 trace.inc
字号:
ret
;=============================================================================
; set_01_vector
;-----------------------------------------------------------------------------
set_01_vector:
mov si,1*4
mov di,save_int_01
call set_vector
mov byte [int_01_set],1
ret
;=============================================================================
; restore_01_vector
;-----------------------------------------------------------------------------
restore_01_vector:
cmp byte [int_01_set],0
je @@quit
mov si,save_int_01
mov di,1*4
call restore_vector
mov byte [int_01_set],0
@@quit:
ret
;=============================================================================
; set_03_vector
;-----------------------------------------------------------------------------
set_03_vector:
mov si,3*4
mov di,save_int_03
call set_vector
mov byte [int_03_set],1
ret
;=============================================================================
; restore_03_vector
;-----------------------------------------------------------------------------
restore_03_vector:
cmp byte [int_03_set],0
je @@quit
mov si,save_int_03
mov di,3*4
call restore_vector
mov byte [int_03_set],0
@@quit:
ret
;=============================================================================
; set_09_vector
;-----------------------------------------------------------------------------
set_09_vector:
mov si,9*4
mov di,save_int_09
mov dx,int_09_handler
call set_vector
mov byte [int_09_set],1
ret
;=============================================================================
; restore_09_vector
;-----------------------------------------------------------------------------
restore_09_vector:
cmp byte [int_09_set],0
je @@quit
mov si,save_int_09
mov di,9*4
call restore_vector
mov byte [int_09_set],0
@@quit:
ret
;=============================================================================
; run_program
;-----------------------------------------------------------------------------
run_program:
mov ax,[cpu_regs+REG_CS]
mov [unasm_seg],ax
mov si,[cpu_regs+REG_IP]
call check_bp
jc @@a
call single_step
@@a:
cmp byte [swap_mode],0
je @@n
call restore_screen
@@n:
cli
; call RestoreUserInts
call set_breakpoints
call set_09_vector
mov dx,bp_entry
call set_03_vector
mov al,[user_port_21]
and al,11111110b
out 21h,al
save_act_regs
restore_user_regs
push word [cs:cpu_regs+REG_FL]
push word [cs:cpu_regs+REG_CS]
push word [cs:cpu_regs+REG_IP]
iret
;=============================================================================
; go_to_cursor
;-----------------------------------------------------------------------------
go_to_cursor:
mov bx,bp0
mov ax,[unasm_seg]
mov [bx+BP_SEG],ax
mov ax,[cur_line_ip]
mov [bx+BP_OFFS],ax
call test_breakpoint
jnc @@ok
mov si,code_not_in_ram
jmp error_message
@@ok:
push word [unasm_seg]
push word [cur_line_ip]
mov ax,[cpu_regs+REG_CS]
cmp ax,[unasm_seg]
jne @@a
mov ax,[cur_line_ip]
cmp ax,[cpu_regs+REG_IP]
jne @@a
call single_step
jmp @@b
@@a:
mov ax,[cpu_regs+REG_CS]
mov [unasm_seg],ax
mov si,[cpu_regs+REG_IP]
call check_bp
jc @@b
call single_step
@@b:
cmp byte [swap_mode],0
je @@n1
call restore_screen
@@n1:
cli
; call RestoreUserInts
call set_09_vector
mov dx,@@int_03_entry
call set_03_vector
pop si
pop es
call set_breakpoints
mov es,[bp0+BP_SEG]
mov si,[bp0+BP_OFFS]
mov bx,bp0
call set_breakpoint
mov al,[user_port_21]
and al,11111110b
out 21h,al
save_act_regs
restore_user_regs
push word [cs:cpu_regs+REG_FL]
push word [cs:cpu_regs+REG_CS]
push word [cs:cpu_regs+REG_IP]
iret
@@int_03_entry:
bp_entry:
pop word [cs:cpu_regs+REG_IP]
pop word [cs:cpu_regs+REG_CS]
pop word [cs:cpu_regs+REG_FL]
save_user_regs
; restore_act_regs
dec word [cpu_regs+REG_IP]
act_popup:
call clear_breakpoints
in al,21h
mov [user_port_21],al
mov al,[my_port_21]
out 21h,al
sti
cmp byte [user_screen_mode],0
je @@n2
call save_screen
call draw_cpu_window
@@n2:
call update_screen
mov ax,[cur_ip_line]
cmp ax,-1
jne @@1
jmp go_to_origin
@@1:
cmp ax,[cur_line]
je @@quit
mov [cur_line],ax
call update_commands
@@quit:
ret
;=============================================================================
; int_09_handler
;-----------------------------------------------------------------------------
int_09_handler:
push ax
in al,60h
cmp al,SCAN_CODE
jne @@quit
push ds
xor ax,ax
mov ds,ax
mov al,[417h]
test al,SHIFT_CODE
jnz int_09_execute
pop ds
@@quit:
pop ax
jmp far [cs:save_int_09]
int_09_execute:
in al,61h
or al,80h
out 61h,al
and al,7Fh
out 61h,al
mov al,20h
out 20h,al
pop ds
pop ax
pop word [cs:cpu_regs+REG_IP]
pop word [cs:cpu_regs+REG_CS]
pop word [cs:cpu_regs+REG_FL]
save_user_regs
; restore_act_regs
jmp act_popup
;=============================================================================
; set_breakpoint
;-----------------------------------------------------------------------------
set_breakpoint:
mov [bx+BP_SEG],es
mov [bx+BP_OFFS],si
mov byte [bx+BP_SET],1
mov al,[es:si]
mov [bx+BP_BYTE],al
mov byte [es:si],0cch
cmp byte [es:si],0cch
je @@quit
stc
@@quit:
ret
;=============================================================================
; clear_breakpoint
;-----------------------------------------------------------------------------
clear_breakpoint:
cmp byte [bx+BP_SET],0
je @@quit
push ax
push si
push es
mov es,[bx+BP_SEG]
mov si,[bx+BP_OFFS]
mov al,[bx+BP_BYTE]
mov [es:si],al
mov byte [bx+BP_SET],0
pop es
pop si
pop ax
@@quit:
ret
;=============================================================================
; clear_breakpoints
;-----------------------------------------------------------------------------
clear_breakpoints:
call restore_03_vector
call restore_09_vector
mov bx,bp0
mov cx,MAX_BREAKPOINTS+1
@@next_bp:
call clear_breakpoint
add bx,SIZEOF_BREAKPOINT
loop @@next_bp
ret
;=============================================================================
; set_breakpoints
;-----------------------------------------------------------------------------
set_breakpoints:
push bx
push cx
push si
push es
mov bx,bp1
mov cx,MAX_BREAKPOINTS
@@next_bp:
cmp byte [bx+BP_ACTIVE],BP_UNUSED
je @@skip
cmp byte [bx+BP_ACTIVE],BP_DISABLED
je @@skip
mov es,[bx+BP_SEG]
mov si,[bx+BP_OFFS]
call set_breakpoint
@@skip:
add bx,SIZEOF_BREAKPOINT
loop @@next_bp
pop es
pop si
pop cx
pop bx
ret
;=============================================================================
; emulate
;-----------------------------------------------------------------------------
emulate:
cld
push ds
push es
mov si,[cpu_regs+REG_IP]
mov es,[cpu_regs+REG_CS]
mov bx,inst_desc
@@next_byte:
es lodsb
xlat
test al,S_PREFIX
jnz @@next_byte
test al,S_EM
jnz @@emulate
@@quit:
pop es
pop ds
ret
@@emulate:
mov al,[es:si-1]
cmp al,0cdh
je @@int
cmp al,0ceh
je @@into
cmp al,9ch
je @@pushf
cmp al,9dh
je @@popf
cmp al,0cfh
je @@iret
clc
jmp @@quit
@@pushf:
mov ax,[cpu_regs+REG_FL]
and ax,~100h
call user_push
jmp @@skip
@@popf:
call user_pop
and ax,~100h
mov [cpu_regs+REG_FL],ax
jmp @@skip
@@iret:
call user_pop
mov [cpu_regs+REG_IP],ax
call user_pop
mov [cpu_regs+REG_CS],ax
call user_pop
mov [cpu_regs+REG_FL],ax
stc
jmp @@quit
@@into:
test byte [cpu_regs+REG_FL+1],00001000b
jz @@skip
mov al,4
jmp @@int_n
@@int:
es lodsb
@@int_n:
push ax
mov ax,[cpu_regs+REG_FL]
and ax,~100h
call user_push
and ax,~200h
mov [cpu_regs+REG_FL],ax
mov ax,es
call user_push
mov ax,si
call user_push
pop ax
mov ah,0
shl ax,1
shl ax,1
mov si,ax
xor ax,ax
mov ds,ax
lodsw
mov [cs:cpu_regs+REG_IP],ax
lodsw
mov [cs:cpu_regs+REG_CS],ax
stc
jmp @@quit
@@skip:
mov [cpu_regs+REG_IP],si
stc
jmp @@quit
;=============================================================================
; user_push
;-----------------------------------------------------------------------------
user_push:
push bx
push ds
sub word [cpu_regs+REG_SP],2
mov bx,[cpu_regs+REG_SP]
mov ds,[cpu_regs+REG_SS]
mov [bx],ax
pop ds
pop bx
ret
;=============================================================================
; user_pop
;-----------------------------------------------------------------------------
user_pop:
push bx
push ds
mov bx,[cpu_regs+REG_SP]
add word [cpu_regs+REG_SP],2
mov ds,[cpu_regs+REG_SS]
mov ax,[bx]
pop ds
pop bx
ret
;------------------------------------------------------------------------------
;=============================================================================
; E0F
;=============================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -