Hi, Find enclosed three files, seperate them and then compile leds.asm. It is an example of how to write to the keyboard LEDs. I'm unsure if you will have trouble because of the way the bios updates the leds from the BIOS flags, I've included code to update those flags. Uncomment it if you think not having it causes you trouble. This code is also supposed to support the A20 line, which is also done through the keyboard port. I haven't tested that since I added the LED support so i can't guarantee anything. David ---------------------------------iodelay.asi----------------------- IODELAY MACRO REPT 2 JMP $+2 ENDM ENDM ------------------------------leds.asi------------------------------- KBReadOutputPort = 0d0h KBWriteOutputPort = 0d1h A20ENABLE = 2 KBOutputBufferReady = 1 KBInputBufferReady = 2 KBDataPort = 60h KBCommandPort = 64h KBLEDS = 0edh CAPS = 4 NUM = 2 SCROLL = 1 -------------------------------leds.asm----------------------------- .model small ; ; LEDS.asm ; ; write to leds. Aslso has a20 support PUBLIC a20on,a20off, writeleds include leds.asi include iodelay.asi biosdata segment at 40h org 17h kbflags db ? biosdata ends .data oldstate db 0 ; Original state of a20 line and other outputs .stack .code ; ; Enable the a20 line ; writeleds proc pushf ; We're going to restore IF cli ; Clear ints push ax mov al,KBLEDs; Command to write leds call keyboard_write; Send command pop ax ; Restore flags to set push ax call keyboard_write; Send LED data pop ax ; push ax ; push bx ; push es ; mov bx,biosdata ; Write the flags to the BIOS data seg ; mov es,bx ; so the BIOS won't override them ; and es:[kbflags],08fh; ; and al,7 ; ; shl al,4 ; ; or es:[kbflags],al ; ; pop es ; pop bx ; pop ax popf ; Restore IF ret writeleds endp a20on proc pushf ; We're going to restore IF cli ; Clear ints mov bl,KBReadOutputPort; Command to read the keyboard I/O port call keyboard_command; Send command call keyboard_read ; Read kb mov [oldstate],al ; Save state push ax ; Save state on stack mov bl,KBWriteOutputPort ; Command to write the keyboard I/O port call keyboard_command; Send command pop ax ; Set A/20 line enable or al,A20ENABLE ; call keyboard_write ; Write new A20 line popf ; Restore IF ret a20on endp ; ; Reset the a20 line the way it was ; a20off proc pushf ; We're going to restore IF cli ; Interrupts off mov bl,KBWriteOutputPort ; Command to write keyboard I/O port call keyboard_command; Send command mov al,[oldstate] ; Get original state of port call keyboard_write ; Write it popf ; Restore IF ret a20off endp ; ; Read from keyboard ; keyboard_read proc push cx ; We're going to wait a while then fail sub cx,cx ; if kb never becomes ready krl: in al,KBCommandPort ; Get KB status port IODELAY test al,KBOutputBufferReady; See if output buffer has any data jnz krr ; Yes, go get it loop krl ; Else wait some more mov ah,1 ; Failure pop cx ret krr: mov cx,32 ; We have to wait in case of slow controller krd: IODELAY loop krd in al,KBDataPort ; Get the input data xor ah,ah ; Succeeded pop cx ret keyboard_read endp ; ; Write to keyboard ; keyboard_write proc push cx mov ah,al ; AH = value to write sub cx,cx ; Wait a while then fail if KB never becomes ; ready kwl: in al,KBCommandPort ; See if input buffer still full IODELAY test al,KBInputBufferReady; Bit for input buffer full jz kwr ; Not full, continue loop kwl ; Else wait some more mov ah,1 ; Failure pop cx ret kwr: mov al,ah ; Write data to keyboard buffer out KBDataPort,al ; xor ah,ah ; Succeeded pop cx ret keyboard_write endp ; ; Send a command to keyboard controller ; keyboard_command proc push cx sub cx,cx ; Wait a while then fail if controller ; doesn't respond cw: in al,KBCommandPort ; Get KB status IODELAY test al,KBInputBufferReady ; See if input buffer full jz cs1 ; No, go send data loop cw ; Else wait some more mov ah,1 ; Failure pop cx ret cs1: mov al,bl ; Command is in BL out KBCommandPort,al ; Output it IODELAY sub cx,cx ; Wait a while for command to be accepted cw2: in al,KBCommandPort ; KB status IODELAY test al,KBInputBufferReady ; Get out if input buffer empty jz cs2 ; loop cw2 ; Else wait a while mov ah,1 ; Failure pop cx ret cs2: xor ah,ah ; Success pop cx ret keyboard_command endp start: mov al,CAPS OR SCROLL OR NUM call writeleds mov ah,4ch int 21h end start