OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [fp/] [implementation/] [mmix/] [silly.mms] - Blame information for rev 54

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 hellwig
* A program that exercises all MMIX operations (more or less)
2
small       GREG   #abc
3
neg_zero    GREG   #8000000000000000
4
half        GREG   #3fe0000000000000
5
inf         GREG   #7ff0000000000000
6
sig_nan     GREG   #7ff1000000000000
7
round_off   GREG   ROUND_OFF<<16
8
round_up    GREG   ROUND_UP<<16
9
round_down  GREG   ROUND_DOWN<<16
10
addy        GREG   #7f6001b4c67bc809
11
addz        GREG   #ff5ffb6a4534a3f7
12
flip        GREG   #0102040810204080
13
ry          GREG
14
rz          GREG
15
            LOC    Data_Segment
16
            GREG   @
17
Start_Inst  SUB    $4,half,$1
18
Final_Inst  SRU    $4,half,1
19
Load_Test   OCTA   #8081828384858687
20
            OCTA   #88898a8b8c8d8e8f
21
Jmp_Pop     JMP    @+8
22
            POP
23
Load_Begin  TETRA  #5f030405
24
Load_End    LDUNC  $3,$4,5
25
Big_Begin   GO     $40,ry,5
26
Big_End     ANDNL  $40,(ry-$0)<<8+5
27
 
28
            LOC    #100
29
Main        FCMP   $0,neg_zero,$5
30
            FCMP   $1,neg_zero,inf
31
            FCMP   $2,inf,sig_nan
32
            FUN    $3,sig_nan,sig_nan
33
            FEQL   $4,$4,neg_zero
34
            FADD   $5,half,inf
35
            FADD   $6,half,neg_zero
36
            FADD   $7,half,half
37
            FADD   $8,half,sig_nan
38
            FSUB   $9,half,small
39
            PUT    rA,round_off
40
            FSUB   $9,half,small
41
            FSUB   $9,small,half
42
            FSQRT  $10,$9
43
            FSUB   $11,sig_nan,$10
44
            PUT    rA,round_down
45
            FSUB   $12,half,half
46
            FSUB   $12,$20,$21
47
            FSUB   $12,$20,neg_zero
48
            PUT    rA,round_up
49
            SUB    $0,inf,1           % $0 = largest normal number
50
            FADD   $12,$0,small
51
            FIX    $12,half
52
            FIXU   $14,ROUND_DOWN,$9
53
            FLOT   $15,ROUND_DOWN,addy
54
            FLOT   $16,ROUND_UP,addy
55
            NEG    $1,1               % $1 = -1
56
            FLOT   $17,1
57
            FLOT   $17,$1
58
            FLOTU  $18,255
59
            FLOTU  $18,neg_zero
60
            FIX    $13,ROUND_NEAR,$18
61
            SFLOT  $18,ROUND_DOWN,addy
62
            SFLOT  $19,ROUND_UP,addy
63
            FSUB   $20,$18,$19
64
            FSUB   $20,$16,$15
65
            SFLOT  $20,1
66
            SFLOT  $20,$1
67
            SFLOTU $21,$1
68
            SFLOTU $21,255
69
            FMUL   $22,neg_zero,inf
70
            FMUL   $22,half,half
71
            FMUL   $23,small,$0
72
            PUT    rE,half
73
            FCMPE  $24,half,$21
74
            FCMPE  $24,neg_zero,small
75
            FCMPE  $24,neg_zero,half
76
            FCMPE  $24,half,inf
77
            FEQLE  $24,$15,$16
78
            PUT    rE,neg_zero
79
            FEQLE  $24,half,half
80
            FUNE   $24,half,half
81
            FSQRT  $25,ROUND_UP,$0
82
            FDIV   $26,$0,$25
83
            PUT    rA,$50
84
            FDIV   $26,$0,$25
85
            FMUL   $27,$25,$25
86
            FREM   $28,$9,half
87
            FREM   $29,$9,small
88
            FINT   $30,$9
89
            FINT   $30,ROUND_UP,small
90
            MUL    $31,flip,flip
91
            MUL    $32,flip,$1
92
            MUL    $33,flip,2
93
            DIV    $32,$32,$1
94
            DIV    $32,neg_zero,$1
95
            MULU   $32,flip,$1
96
            MULU   $31,flip,flip
97
            GET    $33,rH
98
            PUT    rD,$33
99
            DIV    $33,$1,3
100
            DIVU   $34,$31,flip
101
            ADD    $35,addy,addz
102
            FADD   $36,addy,addz
103
            CMP    $37,$36,$35
104
            GETA   $3,1F
105
            PUT    rW,$3
106
            LDT    $6,Start_Inst
107
            LDTU   $7,Final_Inst
108
1H          CMP    $5,$6,$7
109
            BNN    $5,1F
110
            INCML  $6,#100           % increase the opcode
111
            PUT    rX,$6             % ropcode 0
112
            RESUME                   % return to 1B
113
1H          BN     $0,@+4*6
114
            PBN    $0,@-4*1
115
            BNN    $0,@+4*6
116
            PBN    $0,@+4*5
117
            PBNN   $0,@+4*5
118
            BN     $0,@-4*3
119
            BNN    $0,@-4*3
120
            PBN    $0,@-4*3
121
            PBNN   $0,@-4*3
122
            BZ     $0,@+4*6
123
            PBZ    $0,@-4*1
124
            BNZ    $0,@+4*6
125
            PBZ    $0,@+4*5
126
            PBNZ   $0,@+4*5
127
            BZ     $0,@-4*3
128
            BNZ    $0,@-4*3
129
            PBZ    $0,@-4*3
130
            PBNZ   $0,@-4*3
131
            BP     $0,@+4*6
132
            PBP    $0,@-4*1
133
            BNP    $0,@+4*6
134
            PBP    $0,@+4*5
135
            PBNP   $0,@+4*5
136
            BP     $0,@-4*3
137
            BNP    $0,@-4*3
138
            PBP    $0,@-4*3
139
            PBNP   $0,@-4*3
140
            BOD    $0,@+4*6
141
            PBOD   $0,@-4*1
142
            BEV    $0,@+4*6
143
            PBOD   $0,@+4*5
144
            PBEV   $0,@+4*5
145
            BOD    $0,@-4*3
146
            BEV    $0,@-4*3
147
            PBOD   $0,@-4*3
148
            PBEV   $0,@-4*3
149
            LDA    $4,Load_Test+4
150
            GETA   $3,1F
151
            PUT    rW,$3
152
            LDTU   $7,Load_End
153
            LDTU   $6,Load_Begin
154
1H          CMPU   $8,$6,$7
155
            BNN    $8,1F
156
            INCML  $6,#100           % increase the opcode
157
            PUT    rX,$6
158
            RESUME                   % return to 1B
159
2H          OCTA   #fedcba9876543210 % becomes Jmp_Pop
160
            OCTA   #ffeeddccbbaa9988 % becomes Jmp_Pop
161
            NEG    ry,addy
162
            SET    rz,flip
163
            PUT    rM,addz
164
            POP
165
1H          GETA   $4,2B
166
            SETL   $7,4*11
167
            GO     $7,$7,$4
168
            GO     $7,$4,4*12
169
            PRELD  70,$4,$4
170
            PRELD  70,$4,0
171
            PREGO  70,$4,$4
172
            PREGO  70,$4,0
173
            CSWAP  $3,Load_Test+13
174
            GETA   $3,1F
175
            PUT    rW,$3
176
            SETL   rz,1
177
            ADD    ry,$4,4
178
            LDOU   $40,Jmp_Pop
179
            LDTU   $7,Big_End
180
            LDTU   $6,Big_Begin
181
1H          CMPU   $8,$6,$7
182
            BNN    $8,1F
183
            INCML  $6,#100           % increase the opcode
184
            PUT    rX,$6
185
            SET    $5,rz
186
            RESUME                   % return to 1B
187
1H          SL     $40,small,51
188
            SL     $40,small,52
189
            SAVE   $255,0
190
            PUT    rG,small-$0
191
            INCL   small-1,U_BIT<<8
192
            FADD   $100,small,$200
193
            PUT    rA,small-1        % enable underflow trip
194
            TRIP   1,$100,small
195
            FSUB   $100,small,$200   % cause underflow trip
196
            PUT    rL,10
197
            PUT    rL,small
198
            PUSHJ  11,@+4
199
            UNSAVE $255
200
            TRAP   0,Halt,0          % normal exit
201
 
202
            LOC    U_Handler
203
            PUSHJ  $255,Handler
204
3H          TRAP   0,$1
205
            SUB    $0,$1,1
206
            POP    2,0
207
4H          GET    $50,rX
208
            INCH   $50,#8100         % ropcode 1
209
            FLOT   $60,1
210
            PUT    rZ,$60
211
            JMP    2F
212
 
213
            LOC    0
214
            GET    $50,rX
215
            INCH   $50,#8200         % ropcode 2
216
            INCMH  $50,#ff00-(U_BIT<<8)
217
            TRAP   1
218
2H          PUT    rX,$50
219
            GET    $255,rB
220
            RESUME
221
Handler     SETL   $5,#abcd
222
            GET    $1,rJ
223
            PUSHJ  3,3B
224
            SUB    $10,$3,$4
225
            PUT    rJ,$1
226
            POP    11,(4B-3B)>>2
227
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.