Skip to content

Commit

Permalink
fixes #183 Enable EVALUATE-like feature by using indirect addressing …
Browse files Browse the repository at this point in the history
…for TIB
  • Loading branch information
TG9541 committed Apr 8, 2018
1 parent 85b9f91 commit 15ee0ce
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
44 changes: 32 additions & 12 deletions forth.asm
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@
USRHLD = UPP+24 ; "HLD" hold a pointer of output string
USRNTIB = UPP+26 ; "#TIB" count in terminal input buffer
USR_IN = UPP+28 ; ">IN" hold parsing pointer
YTEMP = UPP+30 ; extra working register for core words
USRBUFFER = UPP+30 ; "BUFFER" address, defaults to TIBB

; temporary core variables
RamWord YTEMP ; extra working register for core words

;***********************
;****** 7) Code ******
Expand Down Expand Up @@ -2068,8 +2071,8 @@ COUNT:
RAMHERE:
TNZ USRCP
JRPL HERE ; NVM: CP points to NVM, NVMCP points to RAM
DoLitW NVMCP ; 'eval in Interpreter mode: HERE returns pointer to RAM
JP AT
LD A,#(NVMCP) ; 'eval in Interpreter mode: HERE returns pointer to RAM
JP AAT
.else
RAMHERE = HERE
.endif
Expand Down Expand Up @@ -2747,7 +2750,8 @@ SUBPARS:

HEADER PARSE "PARSE"
PARSE:
DoLitW TIBB
LD A,#(USRBUFFER)
CALL AAT
ADDW Y,USR_IN ; current input buffer pointer
LDW (X),Y
LD A,USRNTIB+1
Expand Down Expand Up @@ -2848,7 +2852,6 @@ NAMET:
1$: RET ; THEN
.endif


; R@ indexed char lookup for SAME?
SAMEQCAT:
CALL OVER
Expand Down Expand Up @@ -2925,8 +2928,7 @@ FIND:
CALLR SWAPPF
FIND1: CALL AT
JREQ FIND6
CALL DUPP
CALL AT
CALL YAT ; DUPP AT
DoLitW MASKK
CALL ANDD
.ifne CASEINSENSITIVE
Expand Down Expand Up @@ -3056,7 +3058,8 @@ ACCP4: CALL DROP

HEADER QUERY "QUERY"
QUERY:
DoLitW TIBB
LD A,#(USRBUFFER)
CALL AAT
DoLitC TIBLENGTH
CALLR ACCEP
CALL AFLAGS ; NTIB !
Expand Down Expand Up @@ -3103,6 +3106,8 @@ ABOR2: CALL DOSTR
PRESE:
CLRW X
LDW USRNTIB,X
LDW X,#(TIBB)
LDW USRBUFFER,X
LDW X,#SPP ; initialize data stack
RET

Expand Down Expand Up @@ -3786,15 +3791,30 @@ DOESS:
.db EXIT_OPC ; 1 RET (EXIT)
RET

; A@ ( A:shortAddr -- n )
; push contents of A:shortAddr on stack
; HEADER AAT "A@"
AAT:
CLRW Y
LD YL,A
; fall through

; Y@ ( Y:Addr -- n )
; push contents of Y:Addr on stack
; HEADER YAT "Y@"
YAT:
LDW Y,(Y)
JP YSTOR

; dodoes ( -- )
; link action to words created by defining words

.ifne WORDS_LINKRUNTI
HEADER DODOES "dodoes"
.endif
DODOES:
CALL LAST ; ( link field of current word )
CALL AT
LD A,#(USRLAST) ; ( link field of current word )
CALLR AAT
CALL NAMET ; ' ( 'last )
DoLitC BRAN_OPC ; ' JP
CALL OVER ; ' JP '
Expand Down Expand Up @@ -3849,8 +3869,8 @@ CONST:

HEADER DOCON "docon"
DOCON:
CALL RFROM
CALL AT ; push constant in interpreter mode
POPW Y
CALLR YAT ; R> AT push constant in interpreter mode
CALL COMPIQ
JREQ 1$
CALL LITER ; compile constant in compiler mode
Expand Down
11 changes: 11 additions & 0 deletions lib/S"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\ S" STM8 eForth string utility word
\ refer to github.com/TG9541/stm8ef/blob/master/LICENSE.md

#require COMPILE
#require [COMPILE]
#require COUNT
#require $"

: S" ( string -- a u )
[COMPILE] $" COMPILE COUNT
; IMMEDIATE

0 comments on commit 15ee0ce

Please sign in to comment.