Implement UTF16" to store UEFI-compatible string
[rrq/jonasforth.git] / main.asm
index d1ff2b3192e7b59a6a677841f0886a31e9d9f3f3..54b2a5dfd8c21cf4e7de8ef30c7470ab5c3ecac0 100644 (file)
--- a/main.asm
+++ b/main.asm
@@ -84,11 +84,11 @@ macro forth_asm label, name, immediate {
 .start:
 }
 
-os_code_section
-
 include "impl.asm"      ; Misc. subroutines
 include "bootstrap.asm" ; Forth words encoded in Assembly
 
+os_code_section
+
 main:
   cld                        ; Clear direction flag so LODSQ does the right thing.
   mov rbp, return_stack_top  ; Initialize return stack
@@ -588,6 +588,27 @@ forth MAIN, 'MAIN'
   dq BRANCH, -8 * 2
   dq TERMINATE
 
+;; EFI:
+
+forth EFI_SYSTEM_TABLE_CONSTANT, 'SystemTable'
+  dq LIT, system_table, GET
+  dq EXIT
+
+forth_asm EFICALL2, 'EFICALL2'
+  pop rax ; function pointer
+  pop rdx ; 2nd argument
+  pop rcx ; 1st argument
+
+  push rsi
+
+  sub rsp, 32
+  call rax
+  add rsp, 32
+
+  pop rsi
+
+  next
+
 ;; Built-in variables:
 
 forth STATE, 'STATE'
@@ -665,6 +686,6 @@ return_stack_top:
 ;; include the file directly in the binary, and then interpret it at startup.
 sysf:
 file 'sys.f'
-file 'example.f'
+file 'uefi.f'
 sysf.len = $ - sysf