forked from timtadh/jist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmappedio.s
25 lines (23 loc) · 1.03 KB
/
mappedio.s
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
# Daniel DeCovnick & Steve Johnson
# mappedio.s
# Global macros for reading and writing using mmio
# _read_char dest
# Waits for keyboard input and stores one character in dest. Blocking.
#define _read_char global
li $t0 0xffff0000 #init t0 to base address for mmio registers
blocking_read_loop:
lw $t1 0($t0) #load address of status reg
andi $t1 $t1 1 #check status
beq $t1 $zero blocking_read_loop #loop if not ready
lw %1 4($t0) #save return value
#end
# _write_char char
# char : the character to print. Blocks until a character is written.
#define _write_char global
li $t0 0xffff0008 #init t0 to base address for mmio registers
blocking_write_loop:
lw $t1 0($t0) #get contents of status reg
andi $t1 $t1 1 #get ready bit
beq $t1 $zero blocking_write_loop #loop if not ready
sw %1 4($t0) #store output into the tx register
#end