@@ -261,10 +261,15 @@ let in_memory = function M _ | S _ | I _ -> true | C _ | R _ | L _ -> false
261
261
262
262
let mov x s =
263
263
(* Numeric literals with more than 32 bits cannot be directly moved to memory location *)
264
- let big_numeric_literal = function L num -> (num > 0xFFFFFFFF || num < - 0xFFFFFFFF ) | _ -> false in
264
+ let big_numeric_literal = function
265
+ | L num -> num > 0xFFFFFFFF || num < - 0xFFFFFFFF
266
+ | _ -> false
267
+ in
265
268
if x = s then []
266
- else if (in_memory x && in_memory s) || (big_numeric_literal x && (in_memory x || in_memory s)) then
267
- [ Mov (x, rax); Mov (rax, s) ]
269
+ else if
270
+ (in_memory x && in_memory s)
271
+ || (big_numeric_literal x && (in_memory x || in_memory s))
272
+ then [ Mov (x, rax); Mov (rax, s) ]
268
273
else [ Mov (x, s) ]
269
274
270
275
(* Boxing for numeric values *)
@@ -697,7 +702,10 @@ let compile cmd env imports code =
697
702
let l, env = env#allocate in
698
703
let env, call = compile_call env ~fname: " .string" 1 false in
699
704
(env, mov addr l @ call)
700
- | LDA _ -> failwith " Should not happen. Indirect assignemts are temporarily prohibited."
705
+ | LDA _ ->
706
+ failwith
707
+ " Should not happen. Indirect assignemts are temporarily \
708
+ prohibited."
701
709
(*
702
710
let s, env' = (env#variable x)#allocate in
703
711
let s', env'' = env'#allocate in
@@ -726,8 +734,11 @@ let compile cmd env imports code =
726
734
| S _ | M _ -> [ Mov (s, rax); Mov (rax, env'#loc x) ]
727
735
| _ -> [ Mov (s, env'#loc x) ] ))
728
736
| STA -> compile_call env ~fname: " .sta" 3 false
729
- | STI -> failwith " Should not happen. Indirect assignemts are temporarily prohibited."
730
- (*
737
+ | STI ->
738
+ failwith
739
+ " Should not happen. Indirect assignemts are temporarily \
740
+ prohibited."
741
+ (*
731
742
let v, env = env#pop in
732
743
let x = env#peek in
733
744
( env,
@@ -921,7 +932,7 @@ let compile cmd env imports code =
921
932
]
922
933
@ (if name = " main" then [ Binop (" ^" , rax, rax) ] else [] )
923
934
@ [
924
- Meta " \t .cfi_restore\t 5 " ;
935
+ Meta " \t .cfi_restore\t rbp " ;
925
936
Meta " \t .cfi_def_cfa\t 4, 4" ;
926
937
Ret ;
927
938
Meta " \t .cfi_endproc" ;
@@ -995,11 +1006,9 @@ let compile cmd env imports code =
995
1006
in
996
1007
let _, env = env#pop in
997
1008
( env,
998
- mov (L col) col_arg_addr
999
- @ mov (L line) line_arg_addr
1000
- @ mov msg_addr msg_arg_addr
1001
- @ mov value value_arg_addr
1002
- @ code )
1009
+ mov (L col) col_arg_addr @ mov (L line) line_arg_addr
1010
+ @ mov msg_addr msg_arg_addr @ mov value value_arg_addr @ code
1011
+ )
1003
1012
| i ->
1004
1013
invalid_arg
1005
1014
(Printf. sprintf " invalid SM insn: %s\n " (GT. show insn i))
0 commit comments