Page 1 of 1

again keyboard problems :((((

Posted: Sun Aug 13, 2006 8:08 am
by joke
Hi all,
i managed to solve the problem where nothing appears on the screen , but now i have a bigger problem.
My computer prints
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

Thank you for your time

Posted: Sun Aug 13, 2006 9:30 am
by JAAman
well, the first thing i see is trying to execute string data usually doesnt work well...

the first thing you do after printing your opening message, is setup for your int10 call (id put this in your print sub instead, but thats personal preference), then you immediatly call 'callpromt': (even though you dont have anything to print yet -- but that doesnt matter because you will still have the same problem later)

Code: Select all

callpromt:
   mov si,unixpromt
   call print

...

print:
  lodsb
  cmp al,0
  je printend
  mov ah,0Eh
  mov bh, 0Fh
  mov bl, 0
  int 10h
  jmp print

printend:
  ret 

...   returning to the call...

call print
                              < ret returns here

;some data
commandbuffer: times 40 db 0
welcome db 'Welcome to my Os!',0,13,10
pay special note to the last 1/3 of the code i quoted here, and you should see your problem

Posted: Sun Aug 13, 2006 12:43 pm
by joke
HOLY CRAP IT WORKS !!!!!! There where to problems
1) the first which Jaaman pointed, my callpromt function wasn't returning control back to main
2) My scanf was really stupid , i re-wrote it to a MUCH more simple form and it works as planned.(simple is always good 8)) Hell, THANK YOU.


Best Regards,
Joke