The Place to Start for Operating System Developers
http://forum.osdev.org/
You could use something like:Poseidon wrote: How can I switch on/off the keyboard LEDs?
Code: Select all
%define LEDSCROLL 1
%define LEDNUMLOCK 2
%define LEDCAPS 4
;Set keyboard LED's
;________________________________________________
;
;Input
; al LED's
;________________________________________________
setLeds:
push ecx
mov cl,0xed ;Set status indicators
call writeToDataPort
call readFromDataPort ;Wait until input buffer empty
mov cl,al
mov [LEDstates],cl
call writeToDataPort
pop ecx
ret
For exceptions and software interrupts there isn't (for IRQ's there is, sort of).Poseidon wrote: Now I'm asking, is there in some register or something like that saved which exception/interrupt has occured? It would be faster to program my exception handler then.
Code: Select all
int00:
push eax
mov eax,0
jmp handler
int01:
push eax
mov eax,1
jmp handler
int02:
push eax
mov eax,2
jmp handler
...
intFF:
push eax
mov eax,255
jmp handler
handler: ;eax = interrupt number on entry
???
pop eax
iretd
Code: Select all
void kbd_setled (BYTE status) {
kbd_wait();
p_outb(0x60, 0xED);
kbd_wait();
p_outb(0x60, status);
kbd_wait();
}
void kbd_wait(void) {
__asm__ ("1: inb 0ドルx64,%al\n" \
"testb 0ドルx02,%al\n"\
"jne 1b");
}
Code: Select all
void kbd_setled (BYTE status) {
???kbd_wait();
???p_outb(0x60, 0xED);
kbd_read();
???kbd_wait();
???p_outb(0x60, status);
???kbd_wait();
}
void kbd_wait(void) {
__asm__ ("1:???inb???0ドルx64,%al\n" \
???"testb???0ドルx02,%al\n"\
???"jne???1b");
}
char kbd_read(void) {
__NASM??__("
push eax
.l1:
in al,statusPort
test al,1 ;Is data ready?
je .l1 ; no, wait
in al,dataPort
mov dl,al
pop eax
ret
");
}