rdos/debug/run.asm

89 lines
1.5 KiB
NASM
Raw Normal View History

; Commands related to executing debugged code
cmd_g: and word [reg_fl+1], 0xfe
jmp return
cmd_t: or word [reg_fl+1], 0x03
jmp return
int3entry:
; save DS and load bss segment from IVT
push ds
mov ds, [cs:zero]
mov ds, [bssvec*4]
; save AX so we can work with it
mov [reg_ax], ax
; pop DS, IP, CS and flags from stack
pop ax
mov [reg_ds], ax
pop ax
mov [reg_ip], ax
pop ax
mov [reg_cs], ax
pop ax
mov [reg_fl], ax
; save the other registers
mov [reg_cx], cx
mov [reg_dx], dx
mov [reg_bx], bx
mov [reg_sp], sp
mov [reg_bp], bp
mov [reg_si], si
mov [reg_di], di
; save other segment registers we can access
mov [reg_ss], ss
mov [reg_es], es
; initialize other segments and setup stack
mov ax, ds
mov es, ax
mov ss, ax
mov sp, stack
call crlf
call printregs
push es
mov es, [reg_cs]
mov bx, [reg_ip]
call disasm
pop es
loop: ; show prompt
mov al, '-'
call putc
; read data
mov byte [inmin], 1
mov byte [inmax], 16
mov word [ingetc], getcu
call gets
pushf
call crlf
popf
jc loop
; execute
call runcmd
jmp loop
return: ; restore stack pointer
mov ss, [reg_ss]
mov sp, [reg_sp]
; push flags, CS and IP
mov ax, [reg_fl]
push ax
mov ax, [reg_cs]
push ax
mov ax, [reg_ip]
push ax
; restore GPR
mov ax, [reg_ax]
mov cx, [reg_cx]
mov dx, [reg_dx]
mov bx, [reg_bx]
mov bp, [reg_bp]
mov si, [reg_si]
mov di, [reg_di]
; restore segment registers
; DS must be last
mov es, [reg_es]
mov ds, [reg_ds]
; final jump back
iret