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

Last change on this file since 3673 was 454, checked in by sacerdot, 9 years ago

CSC + Nicolas + Dominic:

1) back-porting of changes by Nicolas from the compiler
2) new file ASMCosts to compute the cost of labels
3) several changes here and there to implement 2)

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