commit fdf8d105527623d18c9e6a6edc7601c4672464db
parent 709bd005473496bfac1b279c22fb7170c71ea74d
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 1 Jun 2022 13:51:41 -0400
Add 1+ 1- c@ c! @ ! + -
Diffstat:
12 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -2,7 +2,7 @@ TARGETS = dusk
WORDOBJS = xcomp.o $(addsuffix .o,$(addprefix words/, \
bye emit drop dup swap over rot \
aset aget acfetch acstore ainc adec \
- to))
+ to inc dec cfetch cstore fetch store add sub))
all: $(TARGETS)
diff --git a/f2asm.py b/f2asm.py
@@ -14,6 +14,8 @@ aliases = {
'r>': 'rs2ps',
'r@': 'rsget',
'r~': 'rsdrop',
+ '+': 'add',
+ '-': 'sub',
'A>r': 'a2rs',
'r>A': 'rs2a',
'rot>': 'rotr',
@@ -27,6 +29,14 @@ aliases = {
'Ac!+': 'acstoreplus',
'in>': 'inptr',
"'curword": 'curword',
+ '1+': 'inc',
+ '1-': 'dec',
+ 'c@': 'cfetch',
+ 'c!': 'cstore',
+ '@': 'fetch',
+ '!': 'store',
+ 'c@+': 'cfetchplus',
+ 'c!+': 'cstoreplus',
}
knownwords = set()
diff --git a/words/add.asm b/words/add.asm
@@ -0,0 +1,4 @@
+defword '+', 1, word_add, word_store
+ pspop eax
+ add [ebp], eax
+ ret
diff --git a/words/cfetch.asm b/words/cfetch.asm
@@ -0,0 +1,5 @@
+defword 'c@', 2, word_cfetch, word_dec
+ mov eax, 0
+ mov al, [ebp]
+ mov [ebp], eax
+ ret
diff --git a/words/cstore.asm b/words/cstore.asm
@@ -0,0 +1,6 @@
+defword 'c!', 2, word_cstore, word_cfetch
+ pspop eax
+ pspop ebx
+ mov [eax], bl
+ ret
+
diff --git a/words/dec.asm b/words/dec.asm
@@ -0,0 +1,3 @@
+defword '1-', 2, word_dec, word_inc
+ dec dword [ebp]
+ ret
diff --git a/words/fetch.asm b/words/fetch.asm
@@ -0,0 +1,5 @@
+defword '@', 1, word_fetch, word_cstore
+ mov eax, [ebp]
+ mov [ebp], eax
+ ret
+
diff --git a/words/inc.asm b/words/inc.asm
@@ -0,0 +1,3 @@
+defword '1+', 2, word_inc, word_to
+ inc dword [ebp]
+ ret
diff --git a/words/store.asm b/words/store.asm
@@ -0,0 +1,5 @@
+defword '!', 1, word_store, word_fetch
+ pspop eax
+ pspop ebx
+ mov [eax], ebx
+ ret
diff --git a/words/sub.asm b/words/sub.asm
@@ -0,0 +1,7 @@
+defword '-', 1, word_sub, word_add
+GLOBAL word_asmlast
+word_asmlast:
+ pspop eax
+ sub [ebp], eax
+ ret
+
diff --git a/words/to.asm b/words/to.asm
@@ -1,6 +1,4 @@
defword 'to', 2, word_to, word_adec
-GLOBAL word_asmlast
-word_asmlast:
EXTERN toflag
mov byte [toflag], 1
ret
diff --git a/xcomp2.txt b/xcomp2.txt
@@ -13,5 +13,8 @@ syscell 'curword curword
: leave r> r~ 1 >r >r ;
: Ac@+ Ac@ A+ ;
: Ac!+ Ac! A+ ;
+: c@+ dup 1+ swap c@ ;
+: c!+ tuck c! 1+ ;
+: allot here + to here ;
create _ ," foo"
: boot _ >A Ac@+ emit Ac@+ emit Ac@+ emit bye ;