-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtruthMachine.asm
More file actions
executable file
·37 lines (32 loc) · 906 Bytes
/
Copy pathtruthMachine.asm
File metadata and controls
executable file
·37 lines (32 loc) · 906 Bytes
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
[bits 16]
[org 0x800]
INPUT_PORT equ 0x10
OUTPUT_PORT equ 0x11
EXIT_PORT equ 0x12
CURRENT_KEY equ 0x1080
start: ; Setup input interrupt
mov WORD [0x20 * 0x4], keyInputInterrupt
mov WORD [0x20 * 0x4 + 0x2], 0
mov bp, 0x1000
mov sp, bp
sti ; Enable interrupt requests
jmp keyLoop ; jump to keyLoop
keyInputInterrupt:
push ax
in al, INPUT_PORT ; Get the character that has been typed
mov [CURRENT_KEY], al ; Store it in CURRENT_KEY
pop ax
iret ; Return from the interrupt
exit:
out EXIT_PORT, al
hlt
keyLoop:
hlt ; Wait for an interrupt
mov al, [CURRENT_KEY]
cmp al, 0 ; Is CURRENT_KEY equal to 0?
je keyLoop ; Goto back up to keyLoop
printLoop:
out OUTPUT_PORT, al ; Print out the character
cmp al, '1' ; Is the character a 1
je printLoop ; Goto printLoop
call exit ; Otherwise exit+