aforth

FORTH for Linux x86-64, written in assembly.
git clone git://henryandlizzy.uk/aforth
Log | Files | Refs | README

commit 26e5a5edb6dac458b076c3fb15def59d07600d25
parent f788f8f17a41845687f0743965502d0802a72af3
Author: Henry Wilson <m3henry@googlemail.com>
Date:   Wed,  2 Aug 2017 13:44:01 +0100

begin codefield flags

Diffstat:
Mcompiler.s | 8++++----
Mextras.s | 2+-
Mmacros.i | 17++++++++++++++---
Mmain.s | 8++++++--
Mmemory.s | 2++
5 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/compiler.s b/compiler.s @@ -158,10 +158,10 @@ verb forth THEN "THEN" immediate do store endword -#verb forth STRIPFLAGS -# const 0x0000FFFFFFFFFFFF -# do AND -# endword +verb forth STRIPFLAGS + const 0x0000FFFFFFFFFFFF + do AND + endword verb forth GETFLAGS const 0x0001000000000000 diff --git a/extras.s b/extras.s @@ -1,6 +1,6 @@ # User Words -verb forth greet GREET +verb forth GREET say "Hello, World!" do CR endword diff --git a/macros.i b/macros.i @@ -2,8 +2,12 @@ .quad \label .endm -.macro forthword +.macro forthword immediate +.ifnb \immediate + .quad 0x8000000000000000 + enter +.else .quad enter +.endif .endm .macro endword @@ -114,14 +118,21 @@ .else .quad 0 .endif - +.ifnb \immediate +\name\(): \type\()word \immediate +.else \name\(): \type\()word +.endif .endm # Codeword macros -.macro codeword +.macro codeword immediate +.ifnb \immediate + .quad 0x8000000000000008 + . +.else .quad . + 8 +.endif .endm .macro advance register diff --git a/main.s b/main.s @@ -29,7 +29,9 @@ _start: movq %rsp, rspbk next: mov (IP), WP advance IP - jmp *(WP) + mov $0x0000FFFFFFFFFFFF, ACC + and (WP), ACC # Strip flags off the codefield + jmp *ACC enter: push IP @@ -151,7 +153,9 @@ verb code EXECUTE mov TOS, WP mov (SP), TOS advance SP - jmp *(WP) + mov $0x0000FFFFFFFFFFFF, ACC + and (WP), ACC # Strip flags off the codefield + jmp *ACC dictionaryend: # "STACK" diff --git a/memory.s b/memory.s @@ -2,6 +2,8 @@ verb code fetch "@>" minstk 1 + mov $0x0000FFFFFFFFFFFF, ACC + and ACC, TOS mov (TOS), TOS jmp next