When I call my OS' interrupt for getting a string from the keyboard, it works fine - until I type in a control character that I handle (enter or backspace - things like tab that I ignore work fine). Half the time I get junk characters printed to the screen, and half the time Bochs bombs out with a "LOCK prefix unallowed" issue. When I traced the execution, it appears that my jmp isn't pointing to the right address, but I can't figure out why that's happening.
Here's the code for my interrupt:
Code: Select all
Int32h:
cli
pusha
cmp ah,0x0
je .0
jmp .done
.0:
xor cx,cx ; cx = Buffer count
.cmd_loop:
mov ah,0x1
int 16h
jz .cmd_loop
mov ah,0
int 16h
cmp al,0x8 ; 0x8 = Backspace
je .backspace
cmp al,0xD ; 0xD = CR
je .end
.store_buf:
cmp cx,256
je .cmd_loop
mov ah,0x1
int 31h
stosb
inc cx
jmp .cmd_loop
.backspace:
cmp cx,0 ; Beginning of string
je .cmd_loop
dec di
mov BYTE [di],0
dec cx
mov ah,0x1
int 31h
mov al,' '
mov ah,0x1
int 31h
mov al,0x08
mov ah,0x1
int 31h
jmp .cmd_loop
.end:
mov al,0 ; Null terminator
stosb
jmp .done
.done:
popa
sti
iret
Edit: Ints 30 and 31 are also handled by my OS. If the code for those would help, please let me know and I'll add it to this post. Thanks!