Last change
on this file since 275 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
|
---|
9 | space: .asciiz " "
|
---|
10 | .align 4
|
---|
11 | # array A reservation 80/4 means a 20 in size
|
---|
12 | A: .space 80
|
---|
13 | .align i
|
---|
14 | # array B, same size as array A
|
---|
15 | B: .space 80
|
---|
16 | .align 4
|
---|
17 | # declaration of integer C
|
---|
18 | C: .word C
|
---|
19 | .align 4
|
---|
20 | # declaration of integer i
|
---|
21 | i: .word i
|
---|
22 | .text
|
---|
23 | .align 4
|
---|
24 | .ent main
|
---|
25 | main:
|
---|
26 | # init of C
|
---|
27 | li $4,0x0000002a # 42
|
---|
28 | sw $4,C
|
---|
29 |
|
---|
30 |
|
---|
31 | #Define B[1] - B[19]
|
---|
32 | la $2,B
|
---|
33 | li $3,0x00000001 # 1
|
---|
34 | sw $3,4($2)
|
---|
35 | li $3,0x00000002
|
---|
36 | sw $3,8($2)
|
---|
37 | li $3,0x00000003
|
---|
38 | sw $3,12($2)
|
---|
39 | li $3,0x00000004
|
---|
40 | sw $3,16($2)
|
---|
41 | li $3,0x00000005
|
---|
42 | sw $3,20($2)
|
---|
43 | li $3,0x00000006
|
---|
44 | sw $3,24($2)
|
---|
45 | li $3,0x00000007
|
---|
46 | sw $3,28($2)
|
---|
47 | li $3,0x00000008
|
---|
48 | sw $3,32($2)
|
---|
49 | li $3,0x00000009
|
---|
50 | sw $3,36($2)
|
---|
51 | li $3,0x0000000a #10
|
---|
52 | sw $3,40($2)
|
---|
53 | li $3,0x0000000b
|
---|
54 | sw $3,44($2)
|
---|
55 | li $3,0x0000000c
|
---|
56 | sw $3,48($2)
|
---|
57 | li $3,0x0000000d
|
---|
58 | sw $3,52($2)
|
---|
59 | li $3,0x0000000e
|
---|
60 | sw $3,56($2)
|
---|
61 | li $3,0x0000000f
|
---|
62 | sw $3,60($2)
|
---|
63 | li $3,0x00000010
|
---|
64 | sw $3,64($2)
|
---|
65 | li $3,0x00000011
|
---|
66 | sw $3,68($2)
|
---|
67 | li $3,0x00000012
|
---|
68 | sw $3,72($2)
|
---|
69 | li $3,0x00000013
|
---|
70 | sw $3,76($2)
|
---|
71 |
|
---|
72 | #Special hack for A[1], cause B[0] is not defined
|
---|
73 | lw $3,0($2)
|
---|
74 | addu $3,$3,$4
|
---|
75 | la $2,A
|
---|
76 | sw $3,4($2)
|
---|
77 |
|
---|
78 | #Define A[2] - A[19]
|
---|
79 | li $3,0x0000002b # 42 + 1 = 43
|
---|
80 | sw $3,8($2)
|
---|
81 | li $3,0x0000002c # 44
|
---|
82 | sw $3,12($2)
|
---|
83 | li $3,0x0000002d # 45
|
---|
84 | sw $3,16($2)
|
---|
85 | li $3,0x0000002e # 46
|
---|
86 | sw $3,20($2)
|
---|
87 | li $3,0x0000002f # 47
|
---|
88 | sw $3,24($2)
|
---|
89 | li $3,0x00000030 # 48
|
---|
90 | sw $3,28($2)
|
---|
91 | li $3,0x00000031 # 49
|
---|
92 | sw $3,32($2)
|
---|
93 | li $3,0x00000032 # 50
|
---|
94 | sw $3,36($2)
|
---|
95 | li $3,0x00000033 # 51
|
---|
96 | sw $3,40($2)
|
---|
97 | li $3,0x00000034 # 52
|
---|
98 | sw $3,44($2)
|
---|
99 | li $3,0x00000035 # 53
|
---|
100 | sw $3,48($2)
|
---|
101 | li $3,0x00000036 # 54
|
---|
102 | sw $3,52($2)
|
---|
103 | li $3,0x00000037 # 55
|
---|
104 | sw $3,56($2)
|
---|
105 | li $3,0x00000038 # 56
|
---|
106 | sw $3,60($2)
|
---|
107 | li $3,0x00000039 # 57
|
---|
108 | sw $3,64($2)
|
---|
109 | li $3,0x0000003a # 58
|
---|
110 | sw $3,68($2)
|
---|
111 | li $3,0x0000003b # 59
|
---|
112 | sw $3,72($2)
|
---|
113 | li $3,0x0000003c # 60
|
---|
114 | sw $3,76($2)
|
---|
115 |
|
---|
116 | # set the end registers to the end values
|
---|
117 | #(last value of i, last loop compare)
|
---|
118 | li $2,0x00000014 # 20
|
---|
119 | sw $2, i
|
---|
120 | # (last loop compare)
|
---|
121 | li $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.