/* Global strings. */ .countString: .string "Current loop counter: %u\n" .errorString: .string "ioperm()" /* Entry point. */ main: .globl main /* Call ioperm() and check if an error has occurred */ pushl $0xff pushl $5 pushl $0x60 call ioperm addl $12, %esp cmpl $-1, %eax je error pushl $0 jmp .testCounter .loop: /* Print current loop count */ pushl (%esp) pushl $.countString call printf addl $8, %esp /* Activate Scroll Lock LED and sleep for a second */ pushl $0x01 call output addl $4, %esp pushl $1 call sleep addl $4, %esp /* Activate Caps Lock LED and sleep for a second */ pushl $0x04 call output addl $4, %esp pushl $1 call sleep addl $4, %esp /* Activate Num Lock LED and sleep for a second */ pushl $0x02 call output addl $4, %esp pushl $1 call sleep addl $4, %esp /* Increment loop counter */ movl (%esp), %ecx incl %ecx movl %ecx, (%esp) .testCounter: cmpl $10, %ecx jl .loop addl $4, %esp .cleanUp: /* Reset keyboard LEDs and exit */ pushl $0x00 call output addl $4, %esp .theEnd: ret /* The output function. */ output: /* Send command to keyboard */ movb $0xed, %al outb %al, $0x60 .wait: /* Wait until the keyboard says "OK" */ inb $0x64, %al testb $0x02, %al jnz .wait /* Send LED bitmask to keyboard */ movl 4(%esp), %eax outb %al, $0x60 .wait2: /* Wait again until the keyboard says "OK" */ inb $0x64, %al testb $0x02, %al jnz .wait2 ret /* Displays an error message if ioperm() has failed. */ error: pushl $.errorString call perror addl $4, %esp jmp .theEnd