1 | open Physical;; |
---|
2 | |
---|
3 | type ('a,'b) union2 = [ `U1 of 'a | `U2 of 'b ] |
---|
4 | type ('a,'b,'c) union3 = [ `U1 of 'a | `U2 of 'b | `U3 of 'c ] |
---|
5 | type ('a,'b,'c,'d,'e,'f) union6 = [ `U1 of 'a | `U2 of 'b | `U3 of 'c | `U4 of 'd | `U5 of 'e | `U6 of 'f ] |
---|
6 | |
---|
7 | type direct = [ `DIRECT of byte ] |
---|
8 | type indirect = [ `INDIRECT of bool ] |
---|
9 | type reg = [ `REG of bit * bit * bit ] |
---|
10 | type acc = [ `A ] |
---|
11 | type b = [ `B ] |
---|
12 | type dptr = [ `DPTR ] |
---|
13 | type data = [ `DATA of byte ] |
---|
14 | type data16 = [ `DATA16 of word ] |
---|
15 | type acc_dptr = [ `A_DPTR ] |
---|
16 | type acc_pc = [ `A_PC ] |
---|
17 | type indirect_dptr = [ `IND_DPTR ] |
---|
18 | type carry = [ `C ] |
---|
19 | type bit = [ `BIT of byte7 ] |
---|
20 | type nbit = [ `NBIT of byte7 ] |
---|
21 | type rel = [ `REL of byte ] |
---|
22 | type addr11 = [ `ADDR11 of word11 ] |
---|
23 | type addr16 = [ `ADDR16 of word ] |
---|
24 | |
---|
25 | type instruction = |
---|
26 | (* arithmetic operations *) |
---|
27 | ADD of acc * [ reg | direct | indirect | data ] |
---|
28 | | ADDC of acc * [ reg | direct | indirect | data ] |
---|
29 | | SUBB of acc * [ reg | direct | indirect | data ] |
---|
30 | | INC of [ acc | reg | direct | indirect | dptr ] |
---|
31 | | DEC of [ acc | reg | direct | indirect ] |
---|
32 | | MUL of acc * b |
---|
33 | | DIV of acc * b |
---|
34 | | DA of acc |
---|
35 | |
---|
36 | (* logical operations *) |
---|
37 | | ANL of |
---|
38 | (acc * [ reg | direct | indirect | data ], |
---|
39 | direct * [ acc | data ], |
---|
40 | carry * [ bit | nbit]) union3 |
---|
41 | | ORL of |
---|
42 | (acc * [ reg | direct | indirect ], |
---|
43 | direct * [ acc | data ], |
---|
44 | carry * [ bit | nbit]) union3 |
---|
45 | | XRL of |
---|
46 | (acc * [ reg | direct | indirect ], |
---|
47 | direct * [ acc | data ]) union2 |
---|
48 | | CLR of [ acc | carry | bit ] |
---|
49 | | CPL of [ acc | carry | bit ] |
---|
50 | | RL of acc |
---|
51 | | RLC of acc |
---|
52 | | RR of acc |
---|
53 | | RRC of acc |
---|
54 | | SWAP of acc |
---|
55 | |
---|
56 | (* data transfer *) |
---|
57 | | MOV of |
---|
58 | (acc * [ reg | direct | indirect | data ], |
---|
59 | [ reg | indirect ] * [ acc | direct | data ], |
---|
60 | direct * [ acc | reg | direct | indirect | data ], |
---|
61 | dptr * data16, |
---|
62 | carry * bit, |
---|
63 | bit * carry |
---|
64 | ) union6 |
---|
65 | | MOVC of acc * [ acc_dptr | acc_pc ] |
---|
66 | | MOVX of (acc * [ indirect | indirect_dptr ], |
---|
67 | [ indirect | indirect_dptr ] * acc) union2 |
---|
68 | | SETB of [ carry | bit ] |
---|
69 | | PUSH of direct |
---|
70 | | POP of direct |
---|
71 | | XCH of acc * [ reg | direct | indirect ] |
---|
72 | | XCHD of acc * indirect |
---|
73 | |
---|
74 | (* program branching *) |
---|
75 | | JC of rel |
---|
76 | | JNC of rel |
---|
77 | | JB of rel |
---|
78 | | JNB of rel |
---|
79 | | JBC of bit * rel |
---|
80 | | ACALL of addr11 |
---|
81 | | LCALL of addr16 |
---|
82 | | RET |
---|
83 | | RETI |
---|
84 | | AJMP of addr11 |
---|
85 | | LJMP of addr16 |
---|
86 | | SJMP of rel |
---|
87 | | JMP of indirect_dptr |
---|
88 | | JZ of rel |
---|
89 | | JNZ of rel |
---|
90 | | CJNE of (acc * [ direct | data ], [ reg | indirect ] * data) union2 * rel |
---|
91 | | DJNZ of [ reg | direct ] * rel |
---|
92 | | NOP |
---|