(** A playground function for developers where they can test very specific functionalities not available in the compiler. It is called with the -dev option. [filenames] are the file names given in the command line when calling acc. *) let do_dev_test (filenames : string list) : unit = let main_lbl = "main" in let exit_lbl = "exit" in let lbl = "label" in let code = [(* Prelude *) `Call main_lbl ; (* call main *) `Label exit_lbl ; (* when coming back from main, do an infinite jump here *) `Jmp exit_lbl ; (* Main *) `Label main_lbl ; `Mov (`DPTR, lbl) ; (* fetch the address of lbl in DPTR *) (* Push the address of lbl on the stack. *) `PUSH (I8051.reg_addr I8051.dpl) ; (* low bytes first *) `PUSH (I8051.reg_addr I8051.dph) ; (* then high bytes *) `RET ; (* this should jump to lbl, i.e. right below *) `Label lbl ; `RET (* jump to the exit label *)] in (* Create a labelled ASM program with the code. *) let prog = { ASM.ppreamble = [] ; ASM.pexit_label = exit_lbl ; ASM.pcode = code ; ASM.phas_main = true } in (* Assemble it. *) let prog = Languages.AstASM (ASMInterpret.assembly prog) in (* Save the result in a fresh file prefixed by "yop" and whose extension is "hex". *) Languages.save false false "yop" "" prog (* let f filename = Printf.printf "Processing %s...\n%!" filename ; let target = Languages.RTL in let print = false in let debug = true in let interpret = true in let p = Languages.parse Languages.Clight filename in let p = Languages.add_runtime p in let p = Languages.labelize p in let ps = Languages.compile false Languages.Clight target p in let f f' p = match Languages.language_of_ast p with | l when l = target -> f' p | _ -> () in let actions = [(print, Languages.save false false filename "") ; (interpret, (fun p -> ignore (Languages.interpret debug p)))] in List.iter (fun (b, f') -> if b then List.iter (f f') ps else ()) actions in List.iter f filenames *)