Added ?DUP.

This commit is contained in:
Brad Nelson
2022-02-27 21:23:37 -08:00
parent 0bc9be1e19
commit bf88a73336
3 changed files with 9 additions and 0 deletions

View File

@ -122,3 +122,10 @@ e: test-empty-string
: test s" " ;
test 0 =assert drop
;e
e: test-?dup
123 ?dup 123 =assert 123 =assert
depth 0 =assert
0 ?dup 0 =assert
depth 0 =assert
;e

View File

@ -25,6 +25,7 @@
X("-", MINUS, tos = (*sp--) - tos) \
Y(rot, w = sp[-1]; sp[-1] = *sp; *sp = tos; tos = w) \
X("-rot", MROT, w = tos; tos = *sp; *sp = sp[-1]; sp[-1] = w) \
X("?dup", QDUP, if (tos) DUP) \
X("<", LESS, tos = (*sp--) < tos ? -1 : 0) \
X(">", GREATER, tos = (*sp--) > tos ? -1 : 0) \
X("<=", LESSEQ, tos = (*sp--) <= tos ? -1 : 0) \

View File

@ -152,6 +152,7 @@ e: check-extra-opcodes
out: -
out: rot
out: -rot
out: ?dup
out: <
out: >
out: <=