Real mode string input problems
Posted: Sun Aug 13, 2006 8:15 am
Hi all,
i managed make my computer print
Welcome to my Os!
root@default:
but when i hit a key nothing happens and my keystroke doesn't appear on the screen. Remember i just want to write something like
root@default:foo
and the hit enter and just print another promt like
root@default:foo <carriage>
root@default:
But as i said it does not display my keystrokes. I've simplified my code and made it a bootsector (avoiding the bootloader) for simplicity. Here's my code
Thank you for your time
i managed make my computer print
Welcome to my Os!
root@default:
but when i hit a key nothing happens and my keystroke doesn't appear on the screen. Remember i just want to write something like
root@default:foo
and the hit enter and just print another promt like
root@default:foo <carriage>
root@default:
But as i said it does not display my keystrokes. I've simplified my code and made it a bootsector (avoiding the bootloader) for simplicity. Here's my code
Code: Select all
[BITS 16]
[ORG 0]
start:
mov ax,0x7C0
mov ds,ax
mov ax,0x0000
mov ss,ax
mov sp,0xFFFF
Main:
mov si,welcome
call print
mainloop:
mov ax,0E0Ah
int 10h
call callpromt
mov di,commandbuffer
mov dx,40
xor cx,cx
call scanf
print:
lodsb
cmp al,0
je printend
mov ah,0Eh
mov bh, 0Fh
mov bl, 0
int 10h
jmp print
printend:
ret
callpromt:
mov si,unixpromt
call print
;some data
commandbuffer: times 40 db 0
welcome db 'Welcome to my Os!',0,13,10
unixpromt db 13,'root@default#:',0
scanf:
xor bx,bx
.start
xor ax,ax
int 16h
cmp al,0x0D
je .return
mov [es:di+bx],al
inc bx
cmp bx,dx
je .return ; if reached the buffer limit just act like return
push bx
xor bx,bx
cmp bx,cx
je .put
.putreturn
pop bx
jmp .start
.put
pop bx
push ax
push bx
xor ah,ah
mov ah,0Eh
mov bh,0Fh
mov bl,0
int 10h
pop bx
pop ax
je .putreturn
.return
xor al,al
mov [es:di+bx],al
jmp mainloop
times 510-($-$$) db 0
dw 0AA55h