.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
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
+
+ sub rsp, 32
+ call rax
+ add rsp, 32
+
+ next
+
+forth_asm EFICALL3, 'EFICALL3'
+ pop rax ; function pointer
+ pop r8 ; 3rd argument
+ pop rdx ; 2nd argument
+ pop rcx ; 1st argument
+
+ sub rsp, 32
+ call rax
+ add rsp, 32
+
+ push rax
+
+ next
+
+forth_asm EFICALL10, 'EFICALL10'
+ pop rax ; function pointer
+
+ mov rcx, [rsp + 8 * 9]
+ mov rdx, [rsp + 8 * 8]
+ mov r8, [rsp + 8 * 7]
+ mov r9, [rsp + 8 * 6]
+
+ ;; Reverse order of stack arguments
+ mov r10, [rsp + 8 * 5]
+ mov r11, [rsp + 8 * 0]
+ mov [rsp + 8 * 5], r11
+ mov [rsp + 8 * 0], r10
+
+ mov r10, [rsp + 8 * 4]
+ mov r11, [rsp + 8 * 1]
+ mov [rsp + 8 * 4], r11
+ mov [rsp + 8 * 1], r10
+
+ mov r10, [rsp + 8 * 3]
+ mov r11, [rsp + 8 * 2]
+ mov [rsp + 8 * 3], r11
+ mov [rsp + 8 * 2], r10
+
+ sub rsp, 32
+ call rax
+ add rsp, 32 + 8 * 10
+
+ push rax
+
+ next
+
;; Built-in variables:
forth STATE, 'STATE'
;; 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