/
prooftest.dasm16
116 lines (93 loc) · 1.51 KB
/
prooftest.dasm16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
; Written for dcpu16-emulator project (https://github.com/tobbebia/dcpu16-emulator)
; Program used to make sure changes to the emulator don't break anything.
; Assemble using: https://github.com/AgentME/DCPU-16-Assembler
;
; Expected result:
;
; RAM STARTING AT ADDRESS 0x100
; 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
;
; REG A: 1
; REG B: 2
; REG C: 3
; REG X: 4
; REG Y: 5
; REG Z: 6
; Set to high number (2-word instruction)
SET [0x100], 255
; Set to small number (1-word instruction)
SET [0x101], 1
; Set to register
SET A, 2
SET [0x102], A
; Set to [0x..]
:const3
DAT 3
SET [0x103], [const3]
; Set to [0x.. + REG]
:unused
DAT 0
:const4
DAT 4
SET A, unused
SET [0x104], [1 + A]
; Set to PEEK
SET PUSH, 5
SET [0x105], PEEK
; Set to POP
SET PUSH, 6
SET [0x106], POP
; Test ADD
SET [0x107], 0
ADD [0x107], 7
; Test SUB
SET [0x108], 9
SUB [0x108], 1
; Test MUL
SET [0x109], 3
MUL [0x109], 3
; Test DIV
SET [0x10a], 30
DIV [0x10a], 3
; Test SHR
SET [0x10b], 22
SHR [0x10b], 1
; Test SHL
SET [0x10c], 6
SHL [0x10c], 1
; Test AND
SET [0x10d], 47
AND [0x10d], 13
; Test BOR
SET [0x10e], 2
BOR [0x10e], 12
; Test XOR
SET [0x10f], 31
XOR [0x10f], 16
; Test IFE
IFE 1, 1
SET [0x110], 16
; Test IFN
IFN 1, 2
SET [0x111], 17
; Test IFG
IFG 2, 1
SET [0x112], 18
; Test IFB
IFB 3, 1
SET [0x113], 19
; Test JSR
JSR func20
SET PC, setregs
:func20
SET [0x114], 20
SET PC, POP
:setregs
SET A, [0x101]
SET B, [0x102]
SET C, [0x103]
SET X, [0x104]
SET Y, [0x105]
SET Z, [0x106]
:end
SET PC, end