get char from port 60h

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
User avatar
nicola
Member
Member
Posts: 32
Joined: Mon May 16, 2011 2:05 pm
Location: hanoi

get char from port 60h

Post by nicola »

hi guys,
coz my kernel is running in long mode, i have to access the keyboard through port 60h,
however, it doesn't seem to run:

Code: Select all

;=============================================================================
; Get a character from keyboard below 128 (meaning 0..7Fh)
; @return CL The character ASCII code mapped from scancode
;=============================================================================
get_char:       pushfq
                push rax
                push rbp

                ;get scancode, if >128, wait
.read_port:     in al,60h
                cmp al,128
                jge .read_port
               
                ;convert scancode in AL to ASCII code 
                ;and store this ASCII code into CL
.to_ascii:      lea rbp,[scancode]
                and rax,0ffh
                add rbp,rax
                mov cl,[rbp]                
                
.finish:        pop rbp
                pop rax
                popfq
                ret

it loops forever at the ".read_port".
any body knows what's happening?
I'm using AMD Sempron 140 Single core 2.7GHz
User avatar
nicola
Member
Member
Posts: 32
Joined: Mon May 16, 2011 2:05 pm
Location: hanoi

Re: get char from port 60h

Post by nicola »

i can't figure out why it works
when i change "jge .read_port" to "jae .read_port"

but
JGE = jump if "greater or equal"
JAE = jump if "above or equal"

ain't they the same?
I'm using AMD Sempron 140 Single core 2.7GHz
User avatar
nicola
Member
Member
Posts: 32
Joined: Mon May 16, 2011 2:05 pm
Location: hanoi

Re: get char from port 60h

Post by nicola »

i found out why already :)
JGE for signed value
JAE for unsigned value
what a mistake :D
I'm using AMD Sempron 140 Single core 2.7GHz
Post Reply