debug.rom: re-implement displaying flags and returning to code

This commit is contained in:
Nero 2020-05-12 21:27:48 +00:00
parent c8adeb35d2
commit 064b6ff6af
1 changed files with 56 additions and 5 deletions

View File

@ -72,6 +72,18 @@ init: push ds
pop ds
retf
crlf: xor bx, bx
mov ax, 0x0e0a
int 0x10
mov al, 0x0d
int 0x10
ret
space: xor bx, bx
mov ax, 0x0e20
int 0x10
ret
print16:
; setup bx and ah for int 10h call
xor bx, bx
@ -97,7 +109,7 @@ print16:
ret
printregs:
mov cx, 14
mov cx, 13
xor bx, bx
mov ah, 0x0e
mov si, reg_ax
@ -112,10 +124,24 @@ printregs:
lodsw
mov dx, ax
call print16
mov al, ' '
int 0x10
call space
pop cx
loop .loop
mov dx, [reg_fl]
mov si, fnames
mov cx, 16
.floop: lodsb
cmp al, '+'
je .fskip
test dx, 0x8000
jnz .fprnt
mov al, '-'
.fprnt: int 0x10
.fskip: shl dx, 1
loop .floop
call space
call crlf
ret
int3entry:
@ -147,15 +173,40 @@ int3entry:
mov es, ax
mov ss, ax
mov sp, (stack+stacksize)
call crlf
call printregs
hlt: hlt
jmp hlt
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
mov es, [reg_es]
mov ds, [reg_ds]
; final jump back
iret
names: db "AXCXDXBXSPBPSIDI"
db "DSESSSCSIPFL"
fnames: db "++++ODIT"
db "SZ+A+P+C"
codeend:
reg_ax: dw 0