Skip to content

Commit 29ab283

Browse files
committed
Added math-mulu test
1 parent af01d5d commit 29ab283

File tree

3 files changed

+184
-1
lines changed

3 files changed

+184
-1
lines changed

Ea-Modes/ea_test_1_main.asm

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
; ASM Testcase
33
; flype, 2015-09-28
44
; ea_test_1_main.asm
5-
; WORK IN PROGRESS
65
;==============================================================================
76

87
;==============================================================================

Ea-Modes/ea_test_2_gen.pb

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
;==========================================================
2+
;== Generate ea_test_2_yyyymmddhhiiss.s
3+
;==========================================================
4+
5+
EnableExplicit
6+
7+
#DIS1 = 7
8+
#DIS2 = 617
9+
#NBTEST = 10
10+
#COUNT = 256 * 4
11+
12+
;==============================================================================
13+
14+
Macro W(s)
15+
WriteStringN(0, s)
16+
EndMacro
17+
18+
Macro EA(dis, an, dn, size)
19+
PeekL( dis + ( an + dn * size ) )
20+
EndMacro
21+
22+
Macro H1(x)
23+
RSet(Hex(x, #PB_Byte), 2, "0")
24+
EndMacro
25+
26+
Macro H4(x)
27+
RSet(Hex(x, #PB_Word), 4, "0")
28+
EndMacro
29+
30+
Macro H8(x)
31+
RSet(Hex(x, #PB_Long), 8, "0")
32+
EndMacro
33+
34+
Macro BE(a)
35+
"$"+Mid(a,7,2)+",$"+Mid(a,5,2)+",$"+Mid(a,3,2)+",$"+Mid(a,1,2)
36+
EndMacro
37+
38+
;==============================================================================
39+
40+
Define mem, i, eamul, size, index, precalc, oldprecalc, line$
41+
42+
;==============================================================================
43+
44+
If CreateFile(0, "ea_test_2_" + FormatDate("%yyyy%mm%dd%hh%ii", Date()) + ".asm")
45+
46+
;==========================================================
47+
; Merge main file
48+
;==========================================================
49+
50+
If ReadFile(1, "ea_test_2_main.asm")
51+
While Not Eof(1)
52+
line$ = ReadString(1)
53+
If Left(line$, 15) = "ASSERT_ZERO EQU"
54+
W("DIS1 EQU " + #DIS1)
55+
W("DIS2 EQU " + #DIS2)
56+
W("")
57+
EndIf
58+
W(line$)
59+
Wend
60+
CloseFile(1)
61+
EndIf
62+
63+
;==========================================================
64+
; Merge Data Section
65+
;==========================================================
66+
67+
W(";==========================================================")
68+
W("; Data Section")
69+
W(";==========================================================")
70+
W("")
71+
72+
mem = AllocateMemory(#COUNT)
73+
74+
If mem
75+
76+
; Generate random values
77+
78+
OpenCryptRandom()
79+
CryptRandomData(mem, #COUNT)
80+
81+
; Output runner section
82+
83+
W("RUNNER:")
84+
W(" DS.B DIS2")
85+
For i = 0 To #NBTEST - 1
86+
eamul = Random(3, 0)
87+
size = Int(Pow(2, eamul))
88+
index = Random( ( ( #COUNT / 4 ) >> eamul ) - 4, 0)
89+
precalc = EA(#DIS1, mem, index, size)
90+
W(" DC.B $" + RSet(Hex(index), 2, "0") + "," + size + "," + BE(H8(oldprecalc + precalc)))
91+
oldprecalc = precalc
92+
Next
93+
W(" DC.B -1")
94+
W("")
95+
96+
; Output values section
97+
98+
W("VALUES:")
99+
W(" DS.B DIS1")
100+
For i = 0 To #COUNT - 1 Step 4
101+
W(" DC.B " +
102+
"$" + H1(PeekB(#DIS1+mem+i+0)) + "," +
103+
"$" + H1(PeekB(#DIS1+mem+i+1)) + "," +
104+
"$" + H1(PeekB(#DIS1+mem+i+2)) + "," +
105+
"$" + H1(PeekB(#DIS1+mem+i+3)))
106+
Next
107+
W("")
108+
109+
EndIf
110+
111+
;==========================================================
112+
; Close file
113+
;==========================================================
114+
115+
CloseFile(0)
116+
117+
EndIf
118+
119+
End
120+
121+
;==============================================================================
122+
123+
; IDE Options = PureBasic 5.40 LTS Beta 3 (Linux - x64)
124+
; CursorPosition = 6
125+
; Folding = --
126+
; EnableXP

Ea-Modes/ea_test_2_main.asm

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
;==============================================================================
2+
; ASM Testcase
3+
; flype, 2015-09-28
4+
; ea_test_1_main.asm
5+
; WORK IN PROGRESS
6+
;==============================================================================
7+
8+
;==============================================================================
9+
; Constants
10+
;==============================================================================
11+
12+
ASSERT_ZERO EQU $00D0000C
13+
14+
;==============================================================================
15+
16+
; DC.L 0
17+
; DC.L START
18+
; SECTION .FASTRAM
19+
20+
START:
21+
LEA VALUES,A0 ; Load colors
22+
LEA RUNNER,A1 ; Load runner
23+
LOOP:
24+
CMPI.B #-1,DIS2(A1) ; If current byte = -1
25+
BEQ EXIT ; Then exit
26+
CLR.L D0 ; D0 = 0
27+
CLR.L D1 ; D1 = 0
28+
MOVE.B DIS2(A1),D1 ; Value = Memory Index
29+
ADDQ #1,A1 ; Value = Multiply Size
30+
EAMUL1:
31+
CMPI.B #1,DIS2(A1) ; If MUL = 1 ?
32+
BNE EAMUL2 ;
33+
MOVE.L DIS1(A0,D1.L*1),D0 ; Then D8(An,Dn.L*1)
34+
BRA NEXT
35+
EAMUL2:
36+
CMPI.B #2,DIS2(A1) ; MUL = 2 ?
37+
BNE EAMUL4 ;
38+
MOVE.L DIS1(A0,D1.L*2),D0 ; Then D8(An,Dn.L*2)
39+
BRA NEXT
40+
EAMUL4:
41+
CMPI.B #4,DIS2(A1) ; MUL = 4 ?
42+
BNE EAMUL8 ;
43+
MOVE.L DIS1(A0,D1.L*4),D0 ; Then D8(An,Dn.L*4)
44+
BRA NEXT
45+
EAMUL8:
46+
CMPI.B #8,DIS2(A1) ; MUL = 8 ?
47+
BNE NEXT ;
48+
MOVE.L DIS1(A0,D1.L*8),D0 ; Then D8(An,Dn.L*8)
49+
NEXT:
50+
ADDA.W #1,A1 ; Value = Precalc
51+
SUB.L DIS2(A1),D0 ; Compare Result with Precalc
52+
ADD #4,A1 ; Value = Next Memory Index
53+
MOVE.L D0,ASSERT_ZERO ; Assert D0 = 0
54+
BRA LOOP
55+
EXIT:
56+
;TST $0 ; FLUSH
57+
;STOP #-1 ; STOP SIM
58+
RTS

0 commit comments

Comments
 (0)