-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmips6.asm
56 lines (44 loc) · 763 Bytes
/
mips6.asm
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
# prompts user for two integers and computes sum, uses exception handling for not valid integers and too big sum
.data
s: .space 256
etext: .asciiz "Try again!"
str1ask: .asciiz "Enter first int: "
str2ask: .asciiz "Enter second int: "
sum: .asciiz "The sum is: "
address: .word 0x00400000
nl: .asciiz "\n"
.text
main:
la $a0, str1ask
li $v0, 4
syscall
li $v0, 5
syscall
move $t0, $v0
la $a0, str2ask
li $v0, 4
syscall
li $v0, 5
syscall
move $t1, $v0
add $t2, $t0, $t1
la $a0, sum
li $v0, 4
syscall
li $v0, 1
move $a0, $t2
syscall
li $v0, 10
syscall
.ktext 0x80000180
mfc0 $k0, $14
addi $k0, $k0, 4
la $a0, etext
li $v0, 4
syscall
la $a0, nl
li $v0, 4
syscall
lw $k0, address
mtc0 $k0, $14
eret