Hello, I have three questions:
1- Do you have some tutorials (theory and practice) about interruptions, exeption handling and the IDT?
2- What do I have to do to convert a scan code to an ASCII character? I saw in many places that they pick up characters from a character table. How is that done?
3- I made a routine that endlessly reads hours, minutes and seconds from the CMOS, then print them all directly to VGA memory and restart from the beginning. How do you think it can be enhanced (reading the port once then increment the value by setting up a delay, maybe)?
Thanks in advance for any help.
Interruptions, keyboard handling and time routines.
Re:Interruptions, keyboard handling and time routines.
This is how mine are done.
Also not include is my remapping the pic's function.
The scan code is just mapped into a aray eg:
keyboard map + scan code = ASCII
But then my keyboards just for put in top score
ASHLEY4.
Code: Select all
;*****This is in the main start up before pmode*****
add ebx,idt - gdt
mov [idtr + 2],ebx
;****This at the end of start up in pmode***********
idtr: dw idt_end - idt - 1
dd idt
include 'idt.asm'
************This is in the include******************
idt:
;0 interrupt 0h
dw div_error ; div error
dw sys_code
db 0
db sys_interrupt
dw 0
;1 interrupt 1h
dw debug_exception ; debug exception
dw sys_code
db 0
db sys_interrupt
dw 0
;2 interrupt 2h
dw nmi_interrupt ; non maskable interrupt
dw sys_code
db 0
db sys_interrupt
dw 0
; There is lots more of these 256
idt_end:
;*****This is where the point to********************
unhandled_int:
pushad
mov ax,8h
mov es,ax
mov byte [es:0xB809E], "U"
popad
iret
nmi_interrupt:
pushad
mov ax,8h
mov es,ax
mov byte [es:0xB809E], "N"
jmp reboot
popad
iret
clock_tick:
pushad
mov ax,8h
mov es,ax
mov byte [es:0xB809E], "C"
call irq_clear
popad
iret
keyboard_irq:
pushad
;mov ax,8h
;mov es,ax
;mov byte [es:0xB809C], "K"
call key_board
popad
iret
page_fault:
pushad
mov ax,8h
mov es,ax
mov byte [es:0xB809C], "P"
popad
iret
;*************Lots more go here********************
irq_clear:
push eax
mov al, 0x20
out 0x20, al ; quiet screaming irq chip.
pop eax
ret
;***************************************************
The scan code is just mapped into a aray eg:
keyboard map + scan code = ASCII
But then my keyboards just for put in top score
ASHLEY4.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Interruptions, keyboard handling and time routines.
There should be plenty of them on Bona Fide ... Follow the White Rabit (err. i mean the QuickLinkzManOfSteel wrote: Hello, I have three questions:
1- Do you have some tutorials (theory and practice) about interruptions, exeption handling and the IDT?
Basically, a lookup table is one of the easiest possible approach. Each scancode (or sequence of scancode) is associated with a single key which, depending on the active 'modifier' keys like Shift and ALT+GR will lead to one character (be it ascii, unicode or whatever).2- What do I have to do to convert a scan code to an ASCII character? I saw in many places that they pick up characters from a character table. How is that done?
Most implementations have a "character[]", a "shift_character[]" and an "alt_character[]" table and do [tt]ascii = character[modifier][scancode];[/tt] when time is right to convert the scancode ...
Re:Interruptions, keyboard handling and time routines.
Use a timer interrupt, see timer interruptManOfSteel wrote: 3- I made a routine that endlessly reads hours, minutes and seconds from the CMOS, then print them all directly to VGA memory and restart from the beginning. How do you think it can be enhanced (reading the port once then increment the value by setting up a delay, maybe)?
Thanks in advance for any help.
Re:Interruptions, keyboard handling and time routines.
Try reprogramming the PIT to 100hz (round the hzes down!) or some sort of near-perfect multiple of 1hz, then use that timer to update the clock. Sync them every N seconds (and, for bonus points, write a UDP/IP stack and sync the cmos clock to an internet NTP server).
That gives you a reliable clock.
PS: round down to avoid duplication problems (ie: seconds happening twice because you have to set the clock back). That screws up timestamping.
That gives you a reliable clock.
PS: round down to avoid duplication problems (ie: seconds happening twice because you have to set the clock back). That screws up timestamping.