type opcode = | MATH of (int*int*int) | LOGIC of (int*int*int) | SCIENCE of int | PHYSICS of int;; let code instr = match instr with | MATH (d,a,b) -> 0x20 + d * 0x10 + a * 0x04 + b * 0x01 | LOGIC (d,a,b) -> 0x40 + d * 0x08 + a * 0x04 + b * 0x01 | SCIENCE hyp -> 0x00 + hyp | PHYSICS imm -> 0x60 + imm ;; let string_of_prog prog name = "\n" ^"yang\n" ^"U+262F\n" ^"rm f\n/bin/umodem f PLOP\n" ^(List.fold_left (fun s op -> Printf.sprintf "%s%02X" s (code op)) "" prog) ^"PLOP\n./certify "^name^" f\n" ;;