-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsyscalls.s
79 lines (68 loc) · 1.39 KB
/
syscalls.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
###
# A collection of syscalls in mips-assembly
###
# Prints integer given in $a0
print_int:
li $v0, 1
syscall
jr $ra
# Prints float given in $f12
# Use "mov.s $f12, $???" to move float to reg
print_float:
li $v0, 2
syscall
jr $ra
# Prints double given in $f12
# Use "mov.d $f12, $???" to move double to reg
# Remember that double uses 2 registers (pair of even-odd)
print_double:
li $v0, 3
syscall
jr $ra
# Prints string given in $a0
# Use "la $a0, label" to specify string address
print_string:
li $v0, 4
syscall
jr $ra
# Read integer from input
# Integer will be in $v0
read_int:
li $v0, 5
syscall
jr $ra
# Read float from input
# Float will be in $f0
read_float:
li $v0, 6
syscall
jr $ra
# Read double from input
# Double will be in $f0 (and $f1)
# Remember that double uses 2 registers (pair of even-odd)
read_double:
li $v0, 7
syscall
jr $ra
# Read string from input
# $a0 will be buffer address and $a1 the length (including the space made for \0)
# Remember that u can allocate space for a buffer in .data with .space (len)
read_string:
li $v0, 8
syscall
jr $ra
# Exits the program
exit:
li $v0, 10
syscall
# Prints char given in $a0
print_char:
li $v0, 11
syscall
jr $ra
# Read char from input
# Char will be in $v0
read_char:
li $v0, 12
syscall
jr $ra