1 | open ASM;; |
---|
2 | |
---|
3 | let pretty_bit = |
---|
4 | function true -> "1" |
---|
5 | | false -> "0" |
---|
6 | |
---|
7 | let pretty_nibble = |
---|
8 | function (b1,b2,b3,b4) -> |
---|
9 | pretty_bit b1 ^ pretty_bit b2 ^ pretty_bit b3 ^ pretty_bit b4 |
---|
10 | |
---|
11 | let pretty_byte = |
---|
12 | function (n1, n2) -> pretty_nibble n1 ^ " " ^ pretty_nibble n2 |
---|
13 | |
---|
14 | let pretty_word = |
---|
15 | function (b1,b2) -> pretty_byte b1 ^ " " ^ pretty_byte b2 |
---|
16 | |
---|
17 | let pretty_word11 = |
---|
18 | function (b1,b2,b3,b) -> |
---|
19 | "word11: " ^ pretty_word (((false,false,false,false),(false,b1,b2,b3)),b) |
---|
20 | |
---|
21 | let pretty_instruction_debug = |
---|
22 | function |
---|
23 | ACALL (`ADDR11 (a10,a9,a8,b1)) -> |
---|
24 | "ACALL addr11 (" ^ pretty_word11 (a10,a9,a8,b1) ^ ")" |
---|
25 | | ADD (`A,`REG (r1,r2,r3)) -> |
---|
26 | "ADD A Rn (" ^ pretty_bit r1 ^ pretty_bit r2 ^ pretty_bit r3 ^ ")" |
---|
27 | | ADD (`A, `DIRECT b1) -> |
---|
28 | "ADD A direct (" ^ pretty_byte b1 ^ ")" |
---|
29 | | ADD (`A, `INDIRECT i1) -> |
---|
30 | "ADD A @Ri (" ^ pretty_bit i1 ^ ")" |
---|
31 | | ADD (`A, `DATA b1) -> |
---|
32 | "ADD A #data (" ^ pretty_byte b1 ^ ")" |
---|
33 | | ADDC (`A, `REG(r1,r2,r3)) -> |
---|
34 | "ADDC A Rn (" ^ pretty_bit r1 ^ pretty_bit r2 ^ pretty_bit r3 ^ ")" |
---|
35 | | ADDC (`A, `DIRECT b1) -> |
---|
36 | "ADDC A direct (" ^ pretty_byte b1 ^ ")" |
---|
37 | | ADDC (`A,`INDIRECT i1) -> |
---|
38 | "ADDC A @Ri (" ^ pretty_bit i1 ^ ")" |
---|
39 | | ADDC (`A,`DATA b1) -> |
---|
40 | "ADDC A #data (" ^ pretty_byte b1 ^ ")" |
---|
41 | | AJMP (`ADDR11 (a10,a9,a8,b1)) -> |
---|
42 | "AJMP addr11 (" ^ pretty_word11 (a10,a9,a8,b1) ^ ")" |
---|
43 | | ANL (`U1 (`A, `REG (r1,r2,r3))) -> |
---|
44 | "ANL A Rn (" ^ pretty_bit r1 ^ pretty_bit r2 ^ pretty_bit r3 ^ ")" |
---|
45 | | ANL (`U1 (`A, `DIRECT b1)) -> |
---|
46 | "ANL A direct (" ^ pretty_byte b1 ^ ")" |
---|
47 | | ANL (`U1 (`A, `INDIRECT i1)) -> |
---|
48 | "ANL A @Ri (" ^ pretty_bit i1 ^ ")" |
---|
49 | | ANL (`U1 (`A, `DATA b1)) -> |
---|
50 | "ANL A #data (" ^ pretty_byte b1 ^ ")" |
---|
51 | | ANL (`U2 (`DIRECT b1,`A)) -> |
---|
52 | "ANL direct A (" ^ pretty_byte b1 ^ ")" |
---|
53 | | ANL (`U2 (`DIRECT b1,`DATA b2)) -> |
---|
54 | "ANL direct #data (" ^ pretty_byte b1 ^ pretty_byte b2 ^ ")" |
---|
55 | | ANL (`U3 (`C,`BIT b1)) -> |
---|
56 | "ANL C bit (" ^ pretty_byte b1 ^ ")" |
---|
57 | | ANL (`U3 (`C,`NBIT b1)) -> |
---|
58 | "ANL C /bit (" ^ pretty_byte b1 ^ ")" |
---|
59 | | CJNE (`U1 (`A, `DIRECT b1), `REL b2) -> |
---|
60 | "CJNE A direct rel (" ^ pretty_byte b1 ^ pretty_byte b2 ^ ")" |
---|
61 | | CJNE (`U1 (`A, `DATA b1), `REL b2) -> |
---|
62 | "CJNE A #data rel (" ^ pretty_byte b1 ^ pretty_byte b2 ^ ")" |
---|
63 | | CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2) -> |
---|
64 | "CJNE Ri #data rel (" ^ pretty_byte b1 ^ pretty_byte b2 ^ ")" |
---|
65 | | CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2) -> |
---|
66 | "CJNE @Ri #data rel (" ^ pretty_bit i1 ^ pretty_byte b1 ^ pretty_byte b2 ^ ")" |
---|
67 | | CLR `A -> |
---|
68 | "CLR A" |
---|
69 | | CLR `C -> |
---|
70 | "CLR C" |
---|
71 | | CLR (`BIT b1) -> |
---|
72 | "CLR bit (" ^ pretty_byte b1 ^ ")" |
---|
73 | (* |
---|
74 | | DA `A -> |
---|
75 | [(true,true,false,true),(false,true,false,false)] |
---|
76 | | DEC `A -> |
---|
77 | [(false,false,false,true),(false,true,false,false)] |
---|
78 | | DEC (`REG(r1,r2,r3)) -> |
---|
79 | [(false,false,false,true),(true,r1,r2,r3)] |
---|
80 | | DEC (`DIRECT b1) -> |
---|
81 | [(false,false,false,true),(false,true,false,true); b1] |
---|
82 | | DEC (`INDIRECT i1) -> |
---|
83 | [(false,false,false,true),(false,true,true,i1)] |
---|
84 | | DIV (`A, `B) -> |
---|
85 | [(true,false,false,false),(false,true,false,false)] |
---|
86 | | DJNZ (`REG(r1,r2,r3), `REL b1) -> |
---|
87 | [(true,true,false,true),(true,r1,r2,r3); b1] |
---|
88 | | DJNZ (`DIRECT b1, `REL b2) -> |
---|
89 | [(true,true,false,true),(false,true,false,true); b1; b2] |
---|
90 | | INC `A -> |
---|
91 | [(false,false,false,false),(false,true,false,false)] |
---|
92 | | INC (`REG(r1,r2,r3)) -> |
---|
93 | [(false,false,false,false),(true,r1,r2,r3)] |
---|
94 | | INC (`DIRECT b1) -> |
---|
95 | [(false,false,false,false),(false,true,false,true); b1] |
---|
96 | | INC (`INDIRECT i1) -> |
---|
97 | [(false,false,false,false),(false,true,true,i1)] |
---|
98 | | INC `DPTR -> |
---|
99 | [(true,false,true,false),(false,false,true,true)] |
---|
100 | | JB (`BIT b1, `REL b2) -> |
---|
101 | [(false,false,true,false),(false,false,false,false); byte_of_byte7 b1; b2] |
---|
102 | | JBC (`BIT b1, `REL b2) -> |
---|
103 | [(false,false,false,true),(false,false,false,false); byte_of_byte7 b1; b2] |
---|
104 | | JC (`REL b1) -> |
---|
105 | [(false,true,false,false),(false,false,false,false); b1] |
---|
106 | | JMP `IND_DPTR -> |
---|
107 | [(false,true,true,true),(false,false,true,true)] |
---|
108 | | JNB (`BIT b1, `REL b2) -> |
---|
109 | [(false,false,true,true),(false,false,false,false); byte_of_byte7 b1; b2] |
---|
110 | | JNC (`REL b1) -> |
---|
111 | [(false,true,false,true),(false,false,false,false); b1] |
---|
112 | | JNZ (`REL b1) -> |
---|
113 | [(false,true,true,true),(false,false,false,false); b1] |
---|
114 | | JZ (`REL b1) -> |
---|
115 | [(false,true,true,false),(false,false,false,false); b1] |
---|
116 | | LCALL (`ADDR16 (b1,b2)) -> |
---|
117 | [(false,false,false,true),(false,false,true,false); b1; b2] |
---|
118 | | LJMP (`ADDR16 (b1,b2)) -> |
---|
119 | [(false,false,false,false),(false,false,true,false); b1; b2] |
---|
120 | | MOV (`U1 (`A, `REG(r1,r2,r3))) -> |
---|
121 | [(true,true,true,false),(true,r1,r2,r3)] |
---|
122 | | MOV (`U1 (`A, `DIRECT b1)) -> |
---|
123 | [(true,true,true,false),(false,true,false,true); b1] |
---|
124 | | MOV (`U1 (`A, `INDIRECT i1)) -> |
---|
125 | [(true,true,true,false),(false,true,true,i1)] |
---|
126 | | MOV (`U1 (`A, `DATA b1)) -> |
---|
127 | [(false,true,true,true),(false,true,false,false); b1] |
---|
128 | | MOV (`U2 (`REG(r1,r2,r3), `A)) -> |
---|
129 | [(true,true,true,true),(true,r1,r2,r3)] |
---|
130 | | MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))) -> |
---|
131 | [(true,false,true,false),(true,r1,r2,r3); b1] |
---|
132 | | MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))) -> |
---|
133 | [(false,true,true,true),(true,r1,r2,r3); b1] |
---|
134 | | MOV (`U3 (`DIRECT b1, `A)) -> |
---|
135 | [(true,true,true,true),(false,true,false,true); b1] |
---|
136 | | MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))) -> |
---|
137 | [(true,false,false,false),(true,r1,r2,r3); b1] |
---|
138 | | MOV (`U3 (`DIRECT b1, `DIRECT b2)) -> |
---|
139 | [(true,false,false,false),(false,true,false,true); b1; b2] |
---|
140 | | MOV (`U3 (`DIRECT b1, `INDIRECT i1)) -> |
---|
141 | [(true,false,false,false),(false,true,true,i1); b1] |
---|
142 | | MOV (`U3 (`DIRECT b1, `DATA b2)) -> |
---|
143 | [(false,true,true,true),(false,true,false,true); b1; b2] |
---|
144 | | MOV (`U2 (`INDIRECT i1, `A)) -> |
---|
145 | [(true,true,true,true),(false,true,true,i1)] |
---|
146 | | MOV (`U2 (`INDIRECT i1, `DIRECT b1)) -> |
---|
147 | [(true,false,true,false),(false,true,true,i1); b1] |
---|
148 | | MOV (`U2 (`INDIRECT i1, `DATA b1)) -> |
---|
149 | [(false,true,true,true),(false,true,true,i1); b1] |
---|
150 | | MOV (`U5 (`C, `BIT b1)) -> |
---|
151 | [(true,false,true,false),(false,false,true,false); byte_of_byte7 b1] |
---|
152 | | MOV (`U6 (`BIT b1, `C)) -> |
---|
153 | [(true,false,false,true),(false,false,true,false); byte_of_byte7 b1] |
---|
154 | | MOV (`U4 (`DPTR, `DATA16(b1,b2))) -> |
---|
155 | [(true,false,false,true),(false,false,false,false); b1; b2] |
---|
156 | | MOVC (`A, `A_DPTR) -> |
---|
157 | [(true,false,false,true),(false,false,true,true)] |
---|
158 | | MOVC (`A, `A_PC) -> |
---|
159 | [(true,false,false,false),(false,false,true,true)] |
---|
160 | | MOVX (`U1 (`A, `INDIRECT i1)) -> |
---|
161 | [(true,true,true,false),(false,false,true,i1)] |
---|
162 | | MOVX (`U1 (`A, `IND_DPTR)) -> |
---|
163 | [(true,true,true,false),(false,false,false,false)] |
---|
164 | | MOVX (`U2 (`INDIRECT i1, `A)) -> |
---|
165 | [(true,true,true,true),(false,false,true,i1)] |
---|
166 | | MOVX (`U2 (`IND_DPTR, `A)) -> |
---|
167 | [(true,true,true,true),(false,false,false,false)] |
---|
168 | | MUL(`A, `B) -> |
---|
169 | [(true,false,true,false),(false,true,false,false)] |
---|
170 | | NOP -> |
---|
171 | [(false,false,false,false),(false,false,false,false)] |
---|
172 | | ORL (`U1(`A, `REG(r1,r2,r3))) -> |
---|
173 | [(false,true,false,false),(true,r1,r2,r3)] |
---|
174 | | ORL (`U1(`A, `DIRECT b1)) -> |
---|
175 | [(false,true,false,false),(false,true,false,true); b1] |
---|
176 | | ORL (`U1(`A, `INDIRECT i1)) -> |
---|
177 | [(false,true,false,false),(false,true,true,i1)] |
---|
178 | | ORL (`U1(`A, `DATA b1)) -> |
---|
179 | [(false,true,false,false),(false,true,false,false); b1] |
---|
180 | | ORL (`U2(`DIRECT b1, `A)) -> |
---|
181 | [(false,true,false,false),(false,false,true,false); b1] |
---|
182 | | ORL (`U2 (`DIRECT b1, `DATA b2)) -> |
---|
183 | [(false,true,false,false),(false,false,true,true); b1; b2] |
---|
184 | | ORL (`U3 (`C, `BIT b1)) -> |
---|
185 | [(false,true,true,true),(false,false,true,false); byte_of_byte7 b1] |
---|
186 | | ORL (`U3 (`C, `NBIT b1)) -> |
---|
187 | [(true,false,true,false),(false,false,false,false); byte_of_byte7 b1] |
---|
188 | | POP (`DIRECT b1) -> |
---|
189 | [(true,true,false,true),(false,false,false,false); b1] |
---|
190 | | PUSH (`DIRECT b1) -> |
---|
191 | [(true,true,false,false),(false,false,false,false); b1] |
---|
192 | | RET -> |
---|
193 | [(false,false,true,false),(false,false,true,false)] |
---|
194 | | RETI -> |
---|
195 | [(false,false,true,true),(false,false,true,false)] |
---|
196 | | RL `A -> |
---|
197 | [(false,false,true,false),(false,false,true,true)] |
---|
198 | | RLC `A -> |
---|
199 | [(false,false,true,true),(false,false,true,true)] |
---|
200 | | RR `A -> |
---|
201 | [(false,false,false,false),(false,false,true,true)] |
---|
202 | | RRC `A -> |
---|
203 | [(false,false,false,true),(false,false,true,true)] |
---|
204 | | SETB `C -> |
---|
205 | [(true,true,false,true),(false,false,true,true)] |
---|
206 | | SETB (`BIT b1) -> |
---|
207 | [(true,true,false,true),(false,false,true,false); byte_of_byte7 b1] |
---|
208 | | SJMP (`REL b1) -> |
---|
209 | [(true,false,false,false),(false,false,false,false); b1] |
---|
210 | | SUBB (`A, `DIRECT b1) -> |
---|
211 | [(true,false,false,true),(false,true,false,true); b1] |
---|
212 | | SUBB (`A, `INDIRECT i1) -> |
---|
213 | [(true,false,false,true),(false,true,true,i1)] |
---|
214 | | SUBB (`A, `DATA b1) -> |
---|
215 | [(true,false,false,true),(false,true,false,false); b1] |
---|
216 | | SWAP `A -> |
---|
217 | [(true,true,false,false),(false,true,false,false)] |
---|
218 | | XCH (`A, `REG(r1,r2,r3)) -> |
---|
219 | [(true,true,false,false),(true,r1,r2,r3)] |
---|
220 | | XCH (`A, `DIRECT b1) -> |
---|
221 | [(true,true,false,false),(false,true,false,true); b1] |
---|
222 | | XCH (`A, `INDIRECT i1) -> |
---|
223 | [(true,true,false,false),(false,true,true,i1)] |
---|
224 | | XCHD(`A, `INDIRECT i1) -> |
---|
225 | [(true,true,false,true),(false,true,true,i1)] |
---|
226 | | XRL(`U1(`A, `REG(r1,r2,r3))) -> |
---|
227 | [(false,true,true,false),(true,r1,r2,r3)] |
---|
228 | | XRL(`U1(`A, `DIRECT b1)) -> |
---|
229 | [(false,true,true,false),(false,true,false,true); b1] |
---|
230 | | XRL(`U1(`A, `INDIRECT i1)) -> |
---|
231 | [(false,true,true,false),(false,true,true,i1)] |
---|
232 | | XRL(`U1(`A, `DATA b1)) -> |
---|
233 | [(false,true,true,false),(false,true,false,false); b1] |
---|
234 | | XRL(`U2(`DIRECT b1, `A)) -> |
---|
235 | [(false,true,true,false),(false,false,true,false); b1] |
---|
236 | | XRL(`U2(`DIRECT b1, `DATA b2)) -> |
---|
237 | [(false,true,true,false),(false,false,true,true); b1; b2] *) |
---|
238 | ;; |
---|