-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHello.asm
More file actions
66 lines (47 loc) · 1.2 KB
/
Hello.asm
File metadata and controls
66 lines (47 loc) · 1.2 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Maskinnara programmering, program template
.data
hw: .asciiz "Enter Input: "
space: .asciiz " " # a space to use between numbers
.text
main:
# input = a1
# multiplier = a2
la $a2, 0 # address 0 in a2
la $a0, hw # address hw to a0
li $v0, 4 # preparing to print the string
syscall # does what v0 says.
li $v0, 5 # change to read_integer
syscall # does what v0 says.
move $a1, $v0 # moves the input to a1
loop:
beq $a2, 13, exit # If a2 == 12
mul $a0, $a1, $a2 # multiplies a2 with a1 (a0 == a1 * a2)
add $a2, $a2, 1 # adds 1 to a2 (a2++)
li $v0, 1 # Time to print the shit
syscall # does what v0 says.
la $a0, space # sets adress to the space variable
li $v0, 4 # preparing to print the string
syscall # does what v0 says.
j loop # goto the loop
nop # yolo
exit:
ori $v0, $zero, 10 # Prepare syscall to exit program cleanly
syscall # Bye!
#
# OLD CODE BELLOW
#
# :::ADDITION:::
# li $v0, 1 #put 1 in v0 to print integer
# add $a0, $a1, $a2 #adds the addresses a1, a2 to a0
# syscall
#
#
#
#
# :::HELLO WORLD:::
#
# li $v0, 4 #put in 4 to v0 (print string)
# la $a0, hw #adds the string to a0
# syscall
#
#