I want to write x86 assembler code that can be used to boot your computer from and dims NumLock. This means

  • you cannot rely on glibc or any other of these "comfi" libraries
  • you cannot rely on the Linux kernel
  • we will test your code by dumping it onto a virtual floppy and boot a VM from it
  • goal is to switch on and off NumLock so quickly that it appears dimmed
  • it's okay if everything fits into the bootloader and loops endlessly

Solution with most votes wins.

  • 2
    \$\begingroup\$ I know you think "dim numlock - that's easy" but it is not. So much has to happen to get that far, like scanning for devices and drivers for them. A PS2 keyboard might be easier but I digress. I could make a z80 output "Hello world!" via a UART easily though :P \$\endgroup\$
    – Alec Teal
    Commented Jan 2, 2014 at 8:11
  • \$\begingroup\$ wow good comment... I did dim NumLock once and thought I knew it was easy. But that was maybe specific to my DIN keyboard (DIN was the predecessor for PS/2 at least in Germany). \$\endgroup\$ Commented Jan 2, 2014 at 9:58
  • \$\begingroup\$ doesn't the BIOS give you an address where to write the NumLock? If not, how would you do it e.g. in the boot loader? Now I am curious to solve my own excercise :) \$\endgroup\$ Commented Jan 2, 2014 at 9:59
  • \$\begingroup\$ use port 60: stackoverflow.com/questions/3434827/assembly-keyboard-io-port \$\endgroup\$ Commented Jan 2, 2014 at 10:02

1 Answer 1


I haven't tested this (VirtualBox doesn't pass through its virtual keyboard LEDs onto the physical keyboard, and I'm not on a PC I can reboot currently). But I think it should probably work and is probably quite minimal.

There may be some additional setup that needs to be done on the keyboard controller for these commands to work. If so it would be essentially trivial to add to the code below...

[bits 16]
[org 0x7c00]
mov al, 0xed
out 0x60, al
mov al, 0x07
out 0x60, al
mov al, 0xed
out 0x60, al
mov al, 0x00
out 0x60, al
jmp $$
times 510 - ($ - $$) db 0
dw 0xaa55

Compile with nasm -f bin -o floppy.img numlock.asm.

Will give this a real test and tweak accordingly later (if someone else wants to try and/or tweak it feel free).

  • 1
    \$\begingroup\$ works on my laptop. My laptop's numlock goes on an off. No external keyboard needed. Also scroll lock and caps lock. Good trick with times 510 - ... \$\endgroup\$ Commented Jan 3, 2014 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.