2 (** This module defines the abstract syntax tree of [LIN]. *)
4 (** Compared to LTL where functions were graphs, the functions of a LIN program
5 are sequential instructions. *)
9 (* Unconditional branch. *)
12 (* Label a statement. *)
16 | St_comment of string
18 (* Emit a cost label. *)
19 | St_cost of CostLabel.t
21 (* Assign an integer constant to a register. Parameters are the destination
22 register, and the integer. *)
23 | St_int of I8051.register * int
25 (* Pop a value from the IRAM to the accumulator. *)
28 (* Push a value from the accumulator to the IRAM. *)
31 (* Assign the address of a symbol to DPTR. Parameter is the symbol. *)
32 | St_addr of AST.ident
34 (* Move the content of the accumulator to a register. Parameters is the
35 destination register. *)
36 | St_from_acc of I8051.register
38 (* Move the content of a register to the accumulator. Parameters is the source
40 | St_to_acc of I8051.register
42 (* Apply an operation on the accumulators. Parameter is the operation. *)
43 | St_opaccs of I8051.opaccs
45 (* Apply an unary operation on the A accumulator. Parameter is the
49 (* Apply a binary operation on the A accumulator. Parameters are the
50 operation, and the other source register. *)
51 | St_op2 of I8051.op2 * I8051.register
53 (* Set the carry flag to zero. *)
56 (* Set the carry flag to 1. *)
59 (* Load from external memory (address in DPTR) to the accumulator. *)
62 (* Store to external memory (address in DPTR) from the accumulator. *)
65 (* Call to a function given its name. Parameter is the name of the
67 | St_call_id of AST.ident
69 (* Call to a function given its address in DPTR. *)
72 (* Branch on A accumulator. Parameter is the label to go to when the A
73 accumulator is not 0. *)
74 | St_condacc of Label.t
76 (* Transfer control to the address stored in the return address registers. *)
79 type internal_function = statement list
82 | F_int of internal_function
83 | F_ext of AST.external_function
85 (* A program is a list of global variables and their reserved space, a list of
86 function names and their definition, and the name of the main function. *)
89 { vars : (AST.ident * int (* size *)) list ;
90 functs : (AST.ident * function_def) list ;
91 main : AST.ident option }