Changeset 1491 for Deliverables/D2.2
- Timestamp:
- Nov 4, 2011, 1:39:01 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D2.2/8051/src/LIN/LINToASM.ml
r1488 r1491 56 56 let data16_of_int i = `DATA16 (vect_of_int i `Sixteen) 57 57 let acc_addr = I8051.reg_addr I8051.a 58 let dpl_addr = I8051.reg_addr I8051.dpl 59 let dph_addr = I8051.reg_addr I8051.dph 60 let st0_addr = I8051.reg_addr I8051.st0 61 let st1_addr = I8051.reg_addr I8051.st1 58 62 59 63 60 let rectranslate_statement env = function64 let translate_statement env = function 61 65 | LIN.St_goto lbl -> [`Jmp lbl] 62 66 | LIN.St_label lbl -> [`Label lbl] … … 72 76 | LIN.St_push -> 73 77 [`PUSH acc_addr] 74 (*75 | LIN.St_addr x when List.mem_assoc x env.globals_addr ->76 [`MOV (`U4 (`DPTR, data16_of_int (List.assoc x env.globals_addr)))]77 | LIN.St_addr x when List.mem x env.fun_names ->78 [`Mov (`DPTR, x)]79 | LIN.St_addr x ->80 error81 ("unknown symbol " ^ x ^ ". Primitives and externals are not supported")82 *)83 78 | LIN.St_addr x when List.mem x env.externals -> 84 79 error ("Primitive or external " ^ x ^ " is not supported.") … … 117 112 | LIN.St_store -> 118 113 [`MOVX (`U2 (`EXT_IND_DPTR, `A))] 114 | LIN.St_call_id x when List.mem x env.externals -> 115 error ("Primitive or external " ^ x ^ " is not supported.") 119 116 | LIN.St_call_id f -> 120 117 [`Call f] 121 (*122 | LIN.St_call_ptr ->123 (`Call env.set_ra_lbl) :: (call_ptr_instrs env)124 *)125 118 | LIN.St_call_ptr -> 126 119 let lbl = env.fresh () in 127 translate_code env 128 [LIN.St_to_acc I8051.dpl ; 129 LIN.St_from_acc I8051.st0 ; 130 LIN.St_to_acc I8051.dph ; 131 LIN.St_from_acc I8051.st1 ; 132 LIN.St_addr lbl ; 133 LIN.St_to_acc I8051.dpl ; 134 LIN.St_push ; 135 LIN.St_to_acc I8051.dph ; 136 LIN.St_push ; 137 LIN.St_to_acc I8051.st0 ; 138 LIN.St_push ; 139 LIN.St_to_acc I8051.st1 ; 140 LIN.St_push ; 141 LIN.St_return ; 142 LIN.St_label lbl] 120 [`MOV (`U3 (st0_addr, dpl_addr)) ; 121 `MOV (`U3 (st1_addr, dph_addr)) ; 122 `Mov (`DPTR, lbl) ; 123 `PUSH dpl_addr ; 124 `PUSH dph_addr ; 125 `PUSH st0_addr ; 126 `PUSH st1_addr ; 127 `RET ; 128 `Label lbl] 143 129 | LIN.St_condacc lbl -> 144 130 [`WithLabel (`JNZ (`Label lbl))] … … 146 132 [`RET] 147 133 148 andtranslate_code env code =134 let translate_code env code = 149 135 List.flatten (List.map (translate_statement env) code) 150 136
Note: See TracChangeset
for help on using the changeset viewer.