mirror of
https://github.com/nineties/planckforth
synced 2025-01-13 08:01:10 +01:00
Add "value" and "to"
This commit is contained in:
parent
3bc61795fb
commit
487ece4158
2 changed files with 24 additions and 7 deletions
19
bootstrap.fs
19
bootstrap.fs
|
@ -915,6 +915,22 @@ allot-cell : &find! [ ' L , , ] ; \ ( c-addr -- nt ) Throw exception at error
|
|||
\ ( n "name" -- )
|
||||
: constant create , does> @ ;
|
||||
|
||||
( === Value === )
|
||||
|
||||
\ ( n "name" -- )
|
||||
: value create , does> @ ;
|
||||
|
||||
\ ( n "name" -- )
|
||||
: to
|
||||
word! find! >cfa >body
|
||||
state @ if
|
||||
[compile] literal
|
||||
compile !
|
||||
else
|
||||
!
|
||||
then
|
||||
; immediate
|
||||
|
||||
( === Throw and Catch === )
|
||||
|
||||
\ 'xt catch' saves data stack pointer and a marker
|
||||
|
@ -2561,7 +2577,8 @@ need-defined (read)
|
|||
.s . .r u. u.r dec. hex. type typen
|
||||
." s" bl '\n' cr space base decimal hex
|
||||
catch throw success
|
||||
: ; [ ] immediate create >body :noname does> variable constant
|
||||
: ; [ ] immediate create >body :noname does>
|
||||
variable constant value to
|
||||
' ['] compile [compile] literal state
|
||||
+ - * /mod / mod negate not and or xor invert within max min abs
|
||||
< > <= >= = <> 0< 0> 0<= 0>= 0= 0<> 1+ 1-
|
||||
|
|
|
@ -324,22 +324,22 @@ skip T{ 111 BUF:TEST ! 222 BUF:TEST CELL+ ! -> }T
|
|||
skip T{ BUF:TEST @ BUF:TEST CELL+ @ -> 111 222 }T
|
||||
|
||||
\ -----------------------------------------------------------------------------
|
||||
testing VALUE TO
|
||||
testing value to
|
||||
|
||||
T{ 111 VALUE VAL1 -999 VALUE VAL2 -> }T
|
||||
T{ 111 value VAL1 -999 value VAL2 -> }T
|
||||
T{ VAL1 -> 111 }T
|
||||
T{ VAL2 -> -999 }T
|
||||
T{ 222 TO VAL1 -> }T
|
||||
T{ 222 to VAL1 -> }T
|
||||
T{ VAL1 -> 222 }T
|
||||
T{ : VD1 VAL1 ; -> }T
|
||||
T{ VD1 -> 222 }T
|
||||
T{ : VD2 TO VAL2 ; -> }T
|
||||
T{ : VD2 to VAL2 ; -> }T
|
||||
T{ VAL2 -> -999 }T
|
||||
T{ -333 VD2 -> }T
|
||||
T{ VAL2 -> -333 }T
|
||||
T{ VAL1 -> 222 }T
|
||||
T{ 123 VALUE VAL3 IMMEDIATE VAL3 -> 123 }T
|
||||
T{ : VD3 VAL3 LITERAL ; VD3 -> 123 }T
|
||||
T{ 123 value VAL3 immediate VAL3 -> 123 }T
|
||||
T{ : VD3 VAL3 literal ; VD3 -> 123 }T
|
||||
|
||||
\ -----------------------------------------------------------------------------
|
||||
testing CASE OF ENDOF ENDCASE
|
||||
|
|
Loading…
Reference in a new issue