-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mprov64.s
58 lines (57 loc) · 832 Bytes
/
Mprov64.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
.data
headMsg: .asciz "Start av testprogram. Skriv in 5 tal!"
endMsg: .asciz "Slut pa testprogram"
buf: .space 64
sum: .quad 0
count: .quad 0
temp: .quad 0
.text
.global main
main:
pushq $0
movq $headMsg,%rdi
call putText
call outImage
call inImage
movq $5,count
l1:
call getInt
movq %rax,temp
cmpq $0,%rax
jge l2
call getOutPos
decq %rax
movq %rax,%rdi
call setOutPos
l2:
movq temp,%rdx
add %rdx,sum
movq %rdx,%rdi
call putInt
movq $'+',%rdi
call putChar
decq count
cmpq $0,count
jne l1
call getOutPos
decq %rax
movq %rax,%rdi
call setOutPos
movq $'=',%rdi
call putChar
movq sum, %rdi
call putInt
call outImage
movq $12,%rsi
movq $buf,%rdi
call getText
movq $buf,%rdi
call putText
movq $125,%rdi
call putInt
call outImage
movq $endMsg,%rdi
call putText
call outImage
popq %rax
ret