forked from bloominstituteoftechnology/Computer-Architecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyboard.asm
More file actions
23 lines (20 loc) · 745 Bytes
/
keyboard.asm
File metadata and controls
23 lines (20 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
; Keyboard.asm
;
; A simple program to test the keyboard and echo to console.
;
; Does not interpret anything; CR just moves the cursor to the start of the
; line, BS doesn't work, etc.
; Hook the keyboard interrupt
LDI R0,0xF9 ; R0 holds the interrupt vector for I1 (keyboard)
LDI R1,IntHandler ; R1 holds the address of the handler
ST R0,R1 ; Store handler addr in int vector
LDI R5,2 ; Enable keyboard interrupts
LDI R0,Loop
Loop:
JMP R0 ; Infinite spin loop
; Interrupt handler
IntHandler:
LDI R0,0xF4 ; Memory location of most recent key pressed
LD R1,R0 ; load R1 from that memory address
PRA R1 ; Print it
IRET