OSDev.org https://forum.osdev.org/ |
|
Babystep5 doesn't explain how keyboard interrupts work https://forum.osdev.org/viewtopic.php?f=1&t=32491 |
Page 1 of 1 |
Author: | Xorda [ Sat Oct 14, 2017 9:14 am ] |
Post subject: | Babystep5 doesn't explain how keyboard interrupts work |
Hello, I want to learn low-level programming, to program bootloaders and OS'es. I go through the wiki's tutorials and I'm now at Babystep 5 The problem is that it wasn't completely explained how that works. I don't want to copy I want to understand. Could anyone please explain that to me? The following is the code snippet from Babysteb 5 Code: ;========================================== ; nasmw boot.asm -f bin -o boot.bin ; partcopy boot.bin 0 200 -f0 [ORG 0x7c00] ; add to offsets jmp start %include "print.inc" start: xor ax, ax ; make it zero mov ds, ax ; DS=0 mov ss, ax ; stack starts at 0 mov sp, 0x9c00 ; 200h past code start mov ax, 0xb800 ; text video memory mov es, ax cli ;no interruptions mov bx, 0x09 ;hardware interrupt # shl bx, 2 ;multiply by 4 xor ax, ax mov gs, ax ;start of memory mov [gs:bx], word keyhandler mov [gs:bx+2], ds ; segment sti jmp $ ; loop forever keyhandler: in al, 0x60 ; get key data mov bl, al ; save it mov byte [port60], al in al, 0x61 ; keybrd control mov ah, al or al, 0x80 ; disable bit 7 out 0x61, al ; send it back xchg ah, al ; get original out 0x61, al ; send that back mov al, 0x20 ; End of Interrupt out 0x20, al ; and bl, 0x80 ; key released jnz done ; don't repeat mov ax, [port60] mov word [reg16], ax call printreg16 done: iret port60 dw 0 times 510-($-$$) db 0 ; fill sector w/ 0's dw 0xAA55 ; req'd by some BIOSes ;========================================== Thanks for any help |
Author: | Octocontrabass [ Sun Oct 15, 2017 9:29 am ] |
Post subject: | Re: Babystep5 doesn't explain how keyboard interrupts work |
Wow, I didn't realize we had such a bad tutorial on the wiki. Port 0x61 doesn't have anything to do with the keyboard in any PC less than 30 years old. You should delete the six lines that involve reading and writing port 0x61 from the code before running it. If you want to learn more, I'd suggest starting with the wiki article for the keyboard controller. From that, you should be able to figure out what the tutorial code is doing. |
Author: | Xorda [ Sun Oct 15, 2017 1:19 pm ] |
Post subject: | Re: Babystep5 doesn't explain how keyboard interrupts work |
Thank you for notifying me about the mistakes in this tutorial. I was wondering about these 6 lines of code |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |