source: Deliverables/D4.1/ASM.mli @ 97

Last change on this file since 97 was 97, checked in by mulligan, 9 years ago

Move to polymorphic variants everywhere (scary...)

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