rdos/kernel/debug.asm

126 lines
2.0 KiB
NASM
Raw Normal View History

; Names for words in debug frame
; Two characters per word, 14 words total
debug_frame_names:
; general-purpose registers
db "AXCXDXBXSPBPSIDI"
; extra registers
db "DSESSSIPCSFL"
; Names for bits in debug_frame+26 (FL/Flags register)
; One character per bit, 16 bits total
debug_frame_flags:
db "++++ODIT"
db "SZ+A+P+C"
; Print a single register from the frame
; in SI frame offset for register
debug_frame_register_print:
mov bx, debug_frame_names
mov al, [cs:bx+si] ; first name char load
call putc
mov al, [cs:bx+si+1] ; second name char load
call putc
mov al, '='
call putc
mov ax, [ss:bp+si] ; value load
; prepare call to print_number
push bx
push cx
mov bx, 0x0010
mov cx, 3
call print_number_padded
pop cx
pop bx
mov al, ' '
call putc
ret
debug_frame_print:
mov si, 0
mov cx, 8
.reg1loop:
call debug_frame_register_print
add si, 2
loop .reg1loop
mov dx, [ss:bp+26]
mov di, debug_frame_flags
mov cx, 0x0010
.flag_loop:
mov al, [cs:di]
inc di
cmp al, '+'
je .next
test dx, 0x8000
jnz .write
mov al, '-'
.write:
call putc
.next:
sal dx, 1
loop .flag_loop
call printf
db 0x0A, 0x0D, 0
mov si, 16
mov cx, 3
.reg2loop:
call debug_frame_register_print
add si, 2
loop .reg2loop
mov ax, [bp+24]
mov bx, 0x0010
mov cx, 3
call print_number_padded
mov al, ':'
call putc
mov ax, [bp+22]
mov bx, 0x0010
mov cx, 3
call print_number_padded
call printf
db 0x0A, 0x0D, 0
ret
2019-05-02 22:12:45 +02:00
; this prints registers
; expect to be called as interrupt routine
2019-05-02 22:12:45 +02:00
isr_debug:
2019-03-13 22:10:41 +01:00
push ss
push es
push ds
push di
push si
push bp
push sp
push bx
2019-03-13 22:10:41 +01:00
push dx
push cx
push ax
2019-05-02 23:06:02 +02:00
mov bp, sp
mov [bp+08], bp
add WORD [bp+08], 28
2019-05-02 23:06:02 +02:00
call printf
db 0x0A, 0x0D, 0
2019-03-13 22:10:41 +01:00
call debug_frame_print
2019-03-13 22:10:41 +01:00
pop ax
pop cx
pop dx
pop bx
pop bp ; sp to be ignored
2019-03-13 22:10:41 +01:00
pop bp
pop si
pop di
pop ds
pop es
pop ss
iret