Page 1 of 1

get char from port 60h

Posted: Thu May 26, 2011 9:04 am
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?

Re: get char from port 60h

Posted: Thu May 26, 2011 11:19 am
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?

Re: get char from port 60h

Posted: Thu May 26, 2011 11:23 am
by nicola
i found out why already :)
JGE for signed value
JAE for unsigned value
what a mistake :D