source: liacs/ca/opdr1/myprog-optimized.s@ 144

Last change on this file since 144 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.5 KB
Line 
1#/* Author : Rick van der Zwet
2# * S-number : 0433373
3# * Version : $Id: myprog-optimized.s 237 2007-09-19 13:19:08Z rick $
4# * Copyright : FreeBSD Licence
5# */
6# space declaration to be used for the printf statement
7 .data
8 .align 4
9space: .asciiz " "
10 .align 4
11# array A reservation 80/4 means a 20 in size
12A: .space 80
13 .align i
14# array B, same size as array A
15B: .space 80
16 .align 4
17# declaration of integer C
18C: .word C
19 .align 4
20# declaration of integer i
21i: .word i
22 .text
23 .align 4
24 .ent main
25main:
26# init of C
27 li $4,0x0000002a # 42
28 sw $4,C
29
30
31#Define B[1] - B[19]
32la $2,B
33li $3,0x00000001 # 1
34sw $3,4($2)
35li $3,0x00000002
36sw $3,8($2)
37li $3,0x00000003
38sw $3,12($2)
39li $3,0x00000004
40sw $3,16($2)
41li $3,0x00000005
42sw $3,20($2)
43li $3,0x00000006
44sw $3,24($2)
45li $3,0x00000007
46sw $3,28($2)
47li $3,0x00000008
48sw $3,32($2)
49li $3,0x00000009
50sw $3,36($2)
51li $3,0x0000000a #10
52sw $3,40($2)
53li $3,0x0000000b
54sw $3,44($2)
55li $3,0x0000000c
56sw $3,48($2)
57li $3,0x0000000d
58sw $3,52($2)
59li $3,0x0000000e
60sw $3,56($2)
61li $3,0x0000000f
62sw $3,60($2)
63li $3,0x00000010
64sw $3,64($2)
65li $3,0x00000011
66sw $3,68($2)
67li $3,0x00000012
68sw $3,72($2)
69li $3,0x00000013
70sw $3,76($2)
71
72#Special hack for A[1], cause B[0] is not defined
73lw $3,0($2)
74addu $3,$3,$4
75la $2,A
76sw $3,4($2)
77
78#Define A[2] - A[19]
79li $3,0x0000002b # 42 + 1 = 43
80sw $3,8($2)
81li $3,0x0000002c # 44
82sw $3,12($2)
83li $3,0x0000002d # 45
84sw $3,16($2)
85li $3,0x0000002e # 46
86sw $3,20($2)
87li $3,0x0000002f # 47
88sw $3,24($2)
89li $3,0x00000030 # 48
90sw $3,28($2)
91li $3,0x00000031 # 49
92sw $3,32($2)
93li $3,0x00000032 # 50
94sw $3,36($2)
95li $3,0x00000033 # 51
96sw $3,40($2)
97li $3,0x00000034 # 52
98sw $3,44($2)
99li $3,0x00000035 # 53
100sw $3,48($2)
101li $3,0x00000036 # 54
102sw $3,52($2)
103li $3,0x00000037 # 55
104sw $3,56($2)
105li $3,0x00000038 # 56
106sw $3,60($2)
107li $3,0x00000039 # 57
108sw $3,64($2)
109li $3,0x0000003a # 58
110sw $3,68($2)
111li $3,0x0000003b # 59
112sw $3,72($2)
113li $3,0x0000003c # 60
114sw $3,76($2)
115
116# set the end registers to the end values
117#(last value of i, last loop compare)
118li $2,0x00000014 # 20
119sw $2, i
120# (last loop compare)
121li $3,0x00000000 # 0
122
123# Required output "60 19 20"
124# the print statements
125 li $v0,1
126 la $3,A
127 lw $a0,76($3)
128 syscall #print A[19]
129
130 li $v0, 4 # system call code for print_str
131 la $a0, space # address of string to print
132 syscall # print the string " "
133
134 li $v0, 1
135 la $3,B
136 lw $a0,76($3)
137 syscall #print B[19]
138
139 li $v0, 4 #
140 la $a0, space #
141 syscall # print the string " "
142
143 li $v0,1
144 la $3,i
145 lw $a0,0($3)
146 syscall #print i
147$L1:
148 .end main
Note: See TracBrowser for help on using the repository browser.