about summary refs log tree commit diff
path: root/hello.e
blob: 593dc95e2446e982c58ed085dd75e706afabf803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
~ ./evoke hello.e enchant > hello && chmod 755 hello && ./hello

s" evoke.e" include drop

: output-start-routine
  current-offset L!' cold-start
  1 :rax mov-reg64-imm32
  1 :rdi mov-reg64-imm64
  L@' origin L@' greeting + :rsi mov-reg64-imm64
  L@' greeting-size :rdx mov-reg64-imm64
  syscall
  60 :rax mov-reg64-imm32
  0 :rdi mov-reg64-imm32
  syscall
  ;

: output-greeting
  current-offset dup L!' greeting 3unroll
  s" Hello, Irenes!" packstring
  current-offset 4 roll - L!' greeting-size ;

~ (output memory start, current output point
~  -- output memory start, current output point)
~
~ Everything directly called by all-contents has this same interface.
~
: all-contents
  0x08000000 L!' origin
  elf-file-header
  elf-program-header
  output-start-routine
  output-greeting
  current-offset L!' total-size
  ;


: define-compilation
  allocate-compilation-definition
  dup zero-compilation-definition
  ~ (definition)

  :raw-executable over compilation-definition-executable-type !

  [ current-input-file-name literal-string ]
  over compilation-definition-top-level-filename !

  x' all-contents over compilation-definition-compile-body !

  s" hello-executable-data" variable ;
define-compilation

: latest-executable-data hello-executable-data ;