Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions 64th.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
BITS 64


sys_write EQU 1

extern _binary_rc_4_start
Expand All @@ -20,9 +19,9 @@ SECTION .bss

emitbuf RESB 1


SECTION .rodata

; marked as exec because some code ends up there
SECTION .rodata exec
platform: db PLATFORM_DEF

; Start of Dictionary
; The Dictionary is a key Forth datastructure.
Expand Down Expand Up @@ -95,6 +94,15 @@ EXECUTE:
jmp rax
CtoL(EXECUTE)

DQ 8
DQ 'PLATFORM'
PLATFORM:
DQ $+8
; PLATFORM (-- u)
mov rax, [platform]
jmp pushrax
CtoL(PLATFORM)

DQ 4
DQ 'EXIT'
EXIT: DQ $+8
Expand Down Expand Up @@ -1260,7 +1268,11 @@ doestarget:
; it is _absolute_.
; Meaning that it can be copied anywhere, and
; still has the same behaviour.
jmp [.n+0]
; lea r7, [rel pushparam]
jmp r14
;jmp [.n+0]
; mov rax, strict qword pushparam
; jmp rax
.n:
DQ pushparam
ALIGN 8
Expand Down Expand Up @@ -1924,8 +1936,8 @@ scansign:
DQ EXIT



SECTION .data
; code ends up here too
SECTION .data exec

vRESET:
DQ stdexe
Expand Down Expand Up @@ -2006,10 +2018,12 @@ dictfree TIMES 8000 DQ 0
SECTION .text
GLOBAL _start
_start:

dreset: ; ABORT jumps here (data reset)
; Initialise the model registers.
mov rbp, stack
reset: ; QUIT jumps here
lea r14, [rel pushparam]
mov rcx, 0
mov r12, returnstack
mov rax, stateaddr
Expand Down
22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
64th: 64th.o rc.o
ld -g -o $@ $^
ifeq ($(OS),Windows_NT)
include windows.mk
else
include linux.mk
endif

rc.o: rc.4
objcopy --input binary --output elf64-x86-64 --binary-architecture i386:x86-64 $< $@

64th.o: 64th.asm
nasm -w+error -g -f elf64 -o $@ -l ignore/listing $<

node_modules/urchin/urchin:
npm install urchin

test: node_modules/urchin/urchin 64th .PHONY
$< test

clean:
rm *.o 64th

.PHONY:
19 changes: 19 additions & 0 deletions linux.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
64th: 64th.o rc.o
ld -g -o $@ $^

rc.o: rc.4
objcopy --input binary --output elf64-x86-64 --binary-architecture i386:x86-64 $< $@

64th.o: 64th.asm
nasm -w+error -dPLATFORM_DEF=0 -g -f elf64 -o $@ -l ignore/listing $<

node_modules/urchin/urchin:
npm install urchin

test: node_modules/urchin/urchin 64th .PHONY
$< test

clean:
rm *.o 64th

.PHONY:
Loading