debug rom: implement cmd loop
This commit is contained in:
parent
064b6ff6af
commit
47037ad708
@ -1,8 +1,6 @@
|
||||
cpu 8086
|
||||
org 0x0000
|
||||
|
||||
stacksize: equ 0x20
|
||||
|
||||
db 0x55, 0xAA
|
||||
db 0x00
|
||||
jmp init
|
||||
@ -43,11 +41,8 @@ init: push ds
|
||||
; load DS for
|
||||
mov ds, ax
|
||||
|
||||
mov al, [cs:2]
|
||||
inc ax
|
||||
shr ax, 1
|
||||
; move down int 0x12 ptr to make space for us
|
||||
sub [0x413], ax
|
||||
sub word [0x413], ((end - $$) >> 10)
|
||||
; calculate segment from kilobytes
|
||||
mov ax, [0x413]
|
||||
mov cl, 6
|
||||
@ -141,7 +136,6 @@ printregs:
|
||||
.fskip: shl dx, 1
|
||||
loop .floop
|
||||
call space
|
||||
call crlf
|
||||
ret
|
||||
|
||||
int3entry:
|
||||
@ -170,13 +164,35 @@ int3entry:
|
||||
mov [reg_ss], ss
|
||||
mov [reg_es], es
|
||||
; initialize other segments and setup stack
|
||||
mov ax, cs
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
mov sp, (stack+stacksize)
|
||||
mov sp, end
|
||||
call crlf
|
||||
|
||||
call printregs
|
||||
|
||||
loop: ; new line & show prompt
|
||||
call crlf
|
||||
mov al, '-'
|
||||
int 0x10
|
||||
; read data
|
||||
call read
|
||||
jc loop
|
||||
; execute
|
||||
call crlf
|
||||
mov al, [cmdbuf]
|
||||
call runcmd
|
||||
jmp loop
|
||||
|
||||
runcmd: cmp al, 'r'
|
||||
je printregs
|
||||
; print a question mark
|
||||
xor bx, bx
|
||||
mov ax, 0x0e3F
|
||||
int 0x10
|
||||
ret
|
||||
|
||||
return: ; restore stack pointer
|
||||
mov ss, [reg_ss]
|
||||
mov sp, [reg_sp]
|
||||
@ -202,11 +218,47 @@ return: ; restore stack pointer
|
||||
iret
|
||||
|
||||
names: db "AXCXDXBXSPBPSIDI"
|
||||
db "DSESSSCSIPFL"
|
||||
db "ESCSSSDSIPFL"
|
||||
|
||||
fnames: db "++++ODIT"
|
||||
db "SZ+A+P+C"
|
||||
|
||||
getc: xor ax, ax
|
||||
int 0x16
|
||||
test al, al
|
||||
jz getc
|
||||
ret
|
||||
|
||||
read: mov di, cmdbuf
|
||||
.loop: call getc
|
||||
cmp al, 0x03
|
||||
je .can
|
||||
cmp al, 0x0D
|
||||
je .enter
|
||||
cmp al, 0x08
|
||||
je .bs
|
||||
cmp di, cmdbuf+cmdlen
|
||||
jnc .loop
|
||||
stosb
|
||||
mov ah, 0x0e
|
||||
xor bx, bx
|
||||
int 0x10
|
||||
jmp .loop
|
||||
ret
|
||||
.bs: cmp di, cmdbuf
|
||||
jbe .loop
|
||||
xor bx, bx
|
||||
mov ax, 0x0e08
|
||||
int 0x10
|
||||
mov al, 0x20
|
||||
int 0x10
|
||||
mov al, 0x08
|
||||
int 0x10
|
||||
dec di
|
||||
jmp .loop
|
||||
.can: stc
|
||||
.enter: ret
|
||||
|
||||
codeend:
|
||||
|
||||
reg_ax: dw 0
|
||||
@ -226,6 +278,10 @@ reg_ds: dw 0
|
||||
reg_ip: dw 0
|
||||
reg_fl: dw 0
|
||||
|
||||
stack: times stacksize dw 0
|
||||
cmdlen: equ 16
|
||||
cmdbuf: times cmdlen dw 0
|
||||
|
||||
align 512
|
||||
stack: times 0x80 dw 0
|
||||
|
||||
align 1024
|
||||
end:
|
||||
|
Loading…
Reference in New Issue
Block a user