Skip to content

Commit

Permalink
Add aqaml_initial_rsp to remember address of stack bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Jun 28, 2019
1 parent 0002987 commit f12c7db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions generator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,12 @@ let rec generate (letfuncs, strings, typedefs, exps) =
appstr buf "push r13" ;
appstr buf "push r14" ;
appstr buf "mov r14, rsp" ;
(* set start address of stack *)
appstr buf ".data" ;
appstr buf "aqaml_initial_rsp:" ;
appstr buf ".zero 8" ;
appstr buf ".text" ;
appstr buf "mov [rip + aqaml_initial_rsp], rsp" ;
(* give unit value as an argument *)
appfmt buf "mov rax, %d" @@ tagged_int 0 ;
appstr buf "call aqaml_main" ;
Expand Down
2 changes: 2 additions & 0 deletions utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <stdlib.h>
#include <string.h>

extern uint64_t aqaml_initial_rsp;

typedef struct AQamlValue {
enum {
AQAML_INTEGER,
Expand Down

0 comments on commit f12c7db

Please sign in to comment.