again keyboard problems :((((

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
joke
Member
Member
Posts: 56
Joined: Sat Jul 22, 2006 6:20 am

again keyboard problems :((((

Post 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
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post 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
joke
Member
Member
Posts: 56
Joined: Sat Jul 22, 2006 6:20 am

Post 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
I need someone to show me the things in life that I cant find
I cant see the things that make true happiness, I must be blind
Post Reply