-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathkeyboard_interrupt.lc3
More file actions
45 lines (41 loc) · 1.13 KB
/
keyboard_interrupt.lc3
File metadata and controls
45 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
;***************************************************
;Sample program to install our own keyboard handler.
;Simulate the program, and while the code is
;spinning on the Halt, you can enter characters
;and strings into the Console I/O Window and
;the handler will get invoked once for each
;character entered.
;***************************************************
INCLUDE "../AshOS/AshOS_LC3.ah"
ORIGIN
SEGMENT
Code: SEGMENT
;Load the address of the IVT into R2
lea r6, Data
ldr r6, r6, IVT
;Store the address of our handler function
;into the Keyboard vector of the IVT
lea r5, KeyboardHandler
str r5, r6, Keyboard
Halt:
br Halt
Data: SEGMENT
IVT: DATA2 InterruptVectorTable
;byte-strings for PUTSP must end in full word of "0"
KBmessage: DATA2[] "Keyboard received: \0\0\0"
ALIGN 2
KBEnd: DATA2[] "\n\0"
;*************************************************
;Keyboard interrupt handler
;Simply gets the character from the keyboard
;and outputs a message to show what it got.
;***************************************************
Handlers: SEGMENT
KeyboardHandler:
lea r0, KBmessage
trap PUTS
trap GETC
trap OUT
lea r0, KBEnd
trap PUTS
rti