浏览代码

forth: add words "[" and "]"

pull/95/head
Virgil Dupras 4 年前
父节点
当前提交
684cb028ff
共有 3 个文件被更改,包括 14 次插入10 次删除
  1. +7
    -6
      forth/core.fs
  2. +4
    -1
      forth/dictionary.txt
  3. +3
    -3
      forth/z80a.fs

+ 7
- 6
forth/core.fs 查看文件

@@ -1,7 +1,8 @@
: H@ HERE @ ;
: -^ SWAP - ;
: [LITN] LITN ; IMMEDIATE
: LIT ROUTINE S [LITN] , ;
: [ INTERPRET 1 FLAGS ! ; IMMEDIATE
: ] R> DROP ;
: LIT [ ROUTINE S LITN ] , ;
: LITS LIT SCPY ;
: LIT< WORD LITS ; IMMEDIATE
: _err LIT< word-not-found (print) ABORT ;
@@ -48,9 +49,9 @@
; IMMEDIATE

: CREATE
(entry) ( empty header with name )
ROUTINE C [LITN] ( push cellWord addr )
, ( write it )
(entry) ( empty header with name )
[ ROUTINE C LITN ] ( push cellWord addr )
, ( write it )
;
: VARIABLE CREATE 2 ALLOT ;
: CONSTANT CREATE H@ ! DOES> @ ;
@@ -86,7 +87,7 @@

: (sysv)
(entry)
ROUTINE Y [LITN] ,
[ ROUTINE Y LITN ] ,
SYSVNXT @ ,
2 SYSVNXT +!
;


+ 4
- 1
forth/dictionary.txt 查看文件

@@ -52,7 +52,6 @@ DOES> -- See description at top of file
IMMED? a -- f Checks whether wordref at a is immediate.
IMMEDIATE -- Flag the latest defined word as immediate.
LITN n -- Write number n as a literal.
[LITN] n -- *I* Immediate version of LITN.
ROUTINE x -- a Push the addr of the specified core routine
C=cellWord J=JUMPTBL V=nativeWord N=next S=LIT
M=NUMBER Y=sysvarWord D=doesWord
@@ -81,6 +80,10 @@ input stream is executed immediately. In this context, branching doesn't work.
atom's cell.
(bbr) -- Branches backward by the number specified in its
atom's cell.
[ -- Begin interetative mode. In a definition, words
between here and "]" will be executed instead of
compiled.
] -- End interpretative mode.
ABORT -- Resets PS and RS and returns to interpreter
ABORT" x" -- *I* Compiles a ." followed by a ABORT.
AGAIN I:a -- *I* Jump backwards to preceeding BEGIN.


+ 3
- 3
forth/z80a.fs 查看文件

@@ -222,16 +222,16 @@
0x10 OPJR DJNZe,

( Specials )
: JPNEXT, ROUTINE N [LITN] JPnn, ;
: JPNEXT, [ ROUTINE N LITN ] JPnn, ;

: CODE
( same as CREATE, but with ROUTINE V )
(entry)
ROUTINE V [LITN] ,
[ ROUTINE V LITN ] ,
;

: ;CODE JPNEXT, ;


( Routines )
: chkPS, ROUTINE P [LITN] CALLnn, ;
: chkPS, [ ROUTINE P LITN ] CALLnn, ;

正在加载...
取消
保存