source: liacs/coco/assignment4/debug.s@ 386

Last change on this file since 386 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

File size: 2.9 KB
RevLine 
[2]1## Output generated by ./comp @ ubuntu8041
2## Wed Nov 19 17:50:55 2008
3
4## Compiler Construction Course - Leiden University - LIACS
5## Johan IJsveld - Rick van der Zwet
6## BSD Licenced
7
8 .data # Global data section
9 .align 4
10__x:
11 .word 0
12__y:
13 .word 0
14
15 .text # Code section
16 .align 4
17 .globl main
18
19 .ent main
20main:
21 addi $sp, $sp, -4
22 jal __example # Jump to program body
23 addi $v0, $0, 10 # Exit system call
24 syscall
25 .end main
26
27 .ent __example
28__example:
29 sw $ra, 0($sp) # Set up stack frame
30 sw $fp, -4($sp)
31 move $fp, $sp
32 addi $sp, $sp, -12
33 jal __readinteger
34 lw $t0, 0($fp) # Load integer Register
35 move $t0, $v0
36 lw $t1, __x # Load integer Register
37 move $t1, $t0
38 sw $t0, 0($fp) # Write back integer register
39 sw $t1, __x # Write back integer register
40 jal __readinteger
41 lw $t0, 0($fp) # Load integer Register
42 move $t0, $v0
43 lw $t1, __y # Load integer Register
44 move $t1, $t0
45 move $v1, $t1
46 sw $v1, 0($sp)
47 addi $sp, $sp, -4
48 lw $t2, __x # Load integer Register
49 move $v1, $t2
50 sw $v1, 0($sp)
51 addi $sp, $sp, -4
52 sw $t0, 0($fp) # Write back integer register
53 sw $t1, __y # Write back integer register
54 sw $t2, __x # Write back integer register
55 jal __gcd
56 lw $t0, 0($fp) # Load integer Register
57 move $t0, $v0
58 move $v1, $t0
59 sw $v1, 0($sp)
60 addi $sp, $sp, -4
61 sw $t0, 0($fp) # Write back integer register
62 jal __writeinteger
63 lw $ra, 0($fp) # Return from call
64 lw $fp, -4($fp)
65 addi $sp, $sp, 12
66 jr $ra
67 .end __example
68
69 .ent __gcd
70__gcd:
71 sw $ra, 0($sp) # Set up stack frame
72 sw $fp, -4($sp)
73 move $fp, $sp
74 addi $sp, $sp, -36
75 lw $t0, -4($fp) # Load integer Register
76 addi $a0, $0, 0
77 bne $a0, $t0, _L1 # Branch Instruction Int
78 lw $t1, -8($fp) # Load integer Register
79 lw $t2, 0($fp) # Load integer Register
80 move $t1, $t2
81 j _L0
82_L1:
83 lw $t3, -16($fp) # Load integer Register
84 mul $t3, $t2, $t0 # Binary Arithmetic
85 move $v1, $t3
86 sw $v1, 0($sp)
87 addi $sp, $sp, -4
88 move $v1, $t0
89 sw $v1, 0($sp)
90 addi $sp, $sp, -4
91 sw $t0, -4($fp) # Write back integer register
92 sw $t1, -8($fp) # Write back integer register
93 sw $t2, 0($fp) # Write back integer register
94 sw $t3, -16($fp) # Write back integer register
95 jal __gcd
96 lw $t0, -20($fp) # Load integer Register
97 move $t0, $v0
98 lw $t1, -8($fp) # Load integer Register
99 move $t1, $t0
100_L0:
101 sw $t0, -20($fp) # Write back integer register
102 sw $t1, -8($fp) # Write back integer register
103 lw $t0, -8($fp) # Load integer Register
104 move $v0, $t0 # Store integer return value
105 lw $ra, 0($fp) # Return from call
106 lw $fp, -4($fp)
107 addi $sp, $sp, 44
108 jr $ra
109 .end __gcd
110
111 .ent __readinteger # Start of builtin functions and procedures
112__readinteger:
113 addi $v0, $0, 5
114 syscall
115 addi $sp, $sp, 4
116 jr $ra
117 .end __readinteger
118
119 .ent __writeinteger
120__writeinteger:
121 lw $a0, 4($sp)
122 addi $v0, $0, 1
123 syscall
124 addi $sp, $sp, 4
125 jr $ra
126 .end __writeinteger
127
Note: See TracBrowser for help on using the repository browser.