Does my kernel start multitasking by accident
Posted: Mon Oct 13, 2014 12:40 am
I was coding a function to read keys for gaming programs, but then, surprisingly, my test program ends it continues to execute my shell. Then, I start typing. Shell seems to work normally. But when I press arrow key (one of my gaming keys), it prints the keycode out. So does my kernel "multitask" or something, because it looks like it runs two programs same time.
Test function:
Game keys:
Test function:
Code: Select all
Test:
.loop:
call GameKeys
cmp al, 0x1 ; esc pressed?
je .done ; yes, we're done
mov dx, ax
call PrintHex
call BR
jmp .loop
.done:
ret
Code: Select all
GameKeys:
mov ah, 1 ; non-blocking
int 0x16 ; read key
; ah = bios scancode
mov al, 0
cmp ah, 0x48 ; UP
je .up
cmp ah, 0x50 ; DOWN
je .down
cmp ah, 0x4B ; LEFT
je .left
cmp ah, 0x4D ; RIGHT
je .right
cmp ah, 0x1 ; ESC
je .escape
cmp ah, 0x39 ; SPACE
je .space
ret
.escape:
mov al, 0x1
ret
.space:
mov al, 0x2
ret
.up:
mov al, 0x3
ret
.down:
mov al, 0x4
ret
.left:
mov al, 0x5
ret
.right:
mov al, 0x6
ret