X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=main.asm;h=e510410a5069b239621a1c14edb58893bce05dac;hb=61b721d365efaaae4d5ebb8d13972faa697be54b;hp=d1ff2b3192e7b59a6a677841f0886a31e9d9f3f3;hpb=5224cfbc1856cd2f4c786f73223b1182acbc96cc;p=rrq%2Fjonasforth.git diff --git a/main.asm b/main.asm index d1ff2b3..e510410 100644 --- 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,69 @@ 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 + + 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' @@ -665,6 +728,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