aforth

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

commit 1db65aae618a6b7941410052d33808a12af80f34
parent 830e23b805e3e2aa989d3b3f37251de72facd554
Author: Henry Wilson <m3henry@googlemail.com>
Date:   Fri, 16 Jun 2017 13:47:19 +0100

rudimentary dot

Diffstat:
MREADME.md | 4+++-
Mmain.s | 50+++++++++++++++++++++++++++++++++-----------------
2 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/README.md b/README.md @@ -1,5 +1,7 @@ # aforth -A FORTH written in assembly language +A FORTH written in assembly language for Linux x64 + +Compiles with GNU Assembler Written by Henry Wilson diff --git a/main.s b/main.s @@ -18,20 +18,20 @@ 2: .endm -.macro while label - .quad dowhile - .quad . - \label +.macro if label + .quad dobranch + .quad \label .endm .data -cold: forthword +cold: forthword _cold: .quad abort -abort: forthword +abort: forthword .quad quit -quit: forthword +quit: forthword const 10 const 4 .quad flag @@ -39,41 +39,57 @@ quit: forthword string "Hello, World!" .quad print .quad cr + const -8 + .quad dot + .quad cr const -10 .quad negate const 10 .quad equal .quad halt -flag: forthword +flag: forthword flaglp: .quad over .quad line .quad dec .quad dup - while flaglp + if flaglp .quad drop .quad drop endword -line: forthword +line: forthword starlp: .quad star .quad dec .quad dup - while starlp + if starlp .quad drop .quad cr endword -star: forthword - const 42 +star: forthword + const '*' .quad emit endword -cr: forthword +cr: forthword string "\n\r" .quad print endword +dot: forthword + .quad dup + const 0 + .quad gequal + if dotif + const '-' + .quad emit + .quad negate +dotif: const '0' + .quad plus + .quad emit + endword + buff: .quad stack: .skip 1024 #1048576 @@ -174,14 +190,14 @@ dostr: codeword advanceIP jmp next -doagain: codeword - sub (IP), IP +dojump: codeword + mov (IP), IP jmp next -dowhile: codeword +dobranch: codeword cmp $0, TOS je __brk - sub (IP), IP + mov (IP), IP jmp _drop __brk: advanceIP jmp _drop