Add all the assignment code.
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
58c6b1f81c
commit
cfe502c598
1277 changed files with 48709 additions and 1 deletions
34
hw4/x86/testX86.ml
Normal file
34
hw4/x86/testX86.ml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
open X86
|
||||
open Cunit
|
||||
|
||||
let hello_label = mk_lbl_named "hellostr"
|
||||
let puts_label = mk_lbl_named "_puts" (* gcc on linux/mac uses _ to munge names *)
|
||||
|
||||
let main_seq = [
|
||||
Push (esp);
|
||||
Mov (ebp, esp);
|
||||
|
||||
Add (esp, Imm (-8l)); (* Not sure why this has to be 8 *)
|
||||
Mov (stack_offset 0l, Lbl hello_label);
|
||||
Call (Lbl puts_label);
|
||||
|
||||
Mov (esp, ebp);
|
||||
Pop (ebp);
|
||||
Ret
|
||||
]
|
||||
|
||||
let main_bb = {
|
||||
(mk_insn_block (mk_lbl_named "_main") main_seq) with
|
||||
global = true
|
||||
}
|
||||
|
||||
let hello_data = {
|
||||
link = false;
|
||||
label = (mk_lbl_named "hellostr");
|
||||
value = GStringz "Hello, world!"
|
||||
}
|
||||
|
||||
let cu = [Data hello_data; Code main_bb]
|
||||
|
||||
let _ =
|
||||
print_endline (string_of_cunit cu)
|
||||
Loading…
Add table
Add a link
Reference in a new issue