Skip to content

Commit

Permalink
7807 ficl: add xemit, dollar-prefix and UGreaterThan
Browse files Browse the repository at this point in the history
Reviewed by: Sebastian Wiedenroth <wiedi@frubar.net>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
  • Loading branch information
tsoome authored and hrosenfeld committed Feb 2, 2017
1 parent ab8c1d4 commit 152e375
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions usr/src/common/ficl/ficltokens.h
Expand Up @@ -49,6 +49,7 @@ FICL_INSTRUCTION_TOKEN(ficlInstructionExitParen, "(exit)",
FICL_INSTRUCTION_TOKEN(ficlInstructionDup, "dup", FICL_WORD_DEFAULT)
FICL_INSTRUCTION_TOKEN(ficlInstructionSwap, "swap", FICL_WORD_DEFAULT)
FICL_INSTRUCTION_TOKEN(ficlInstructionGreaterThan, ">", FICL_WORD_DEFAULT)
FICL_INSTRUCTION_TOKEN(ficlInstructionUGreaterThan, "u>", FICL_WORD_DEFAULT)
FICL_INSTRUCTION_TOKEN(ficlInstructionBranchParenWithCheck, "(branch)",
FICL_WORD_COMPILE_ONLY)
FICL_INSTRUCTION_TOKEN(ficlInstructionBranchParen, "(branch-final)",
Expand Down
8 changes: 8 additions & 0 deletions usr/src/common/ficl/softcore/ficl.fr
Expand Up @@ -63,4 +63,12 @@ S" FICL_WANT_LOCALS" ENVIRONMENT? drop [if]

[endif]

: xemit ( xchar -- )
dup $80 u< if emit exit then \ special case ASCII
0 swap $3F
begin 2dup u> while
2/ >r dup $3F and $80 or swap 6 rshift r>
repeat $7F xor 2* or
begin dup $80 u< 0= while emit repeat drop
;
\ end-of-file
3 changes: 2 additions & 1 deletion usr/src/common/ficl/softcore/prefix.fr
Expand Up @@ -28,7 +28,7 @@ S" FICL_WANT_EXTENDED_PREFIX" ENVIRONMENT? drop [if]
: // postpone \ ; immediate


\ ** add 0b, 0o, 0d, and 0x as prefixes
\ ** add 0b, 0o, 0d, 0x and $ as prefixes
\ ** these temporarily shift the base to 2, 8, 10, and 16 respectively
\ ** and consume the next number in the input stream, pushing/compiling
\ ** as normal
Expand All @@ -42,5 +42,6 @@ S" FICL_WANT_EXTENDED_PREFIX" ENVIRONMENT? drop [if]

: 0d 10 __tempbase ; immediate
: 0x 16 __tempbase ; immediate
: $ 16 __tempbase ; immediate

end-prefixes
7 changes: 7 additions & 0 deletions usr/src/common/ficl/vm.c
Expand Up @@ -1123,6 +1123,13 @@ ficlVmInnerLoop(ficlVm *vm, ficlWord *fw)
x = dataTop->i;
dataTop->i = FICL_BOOL(x > y);
continue;

case ficlInstructionUGreaterThan:
CHECK_STACK(2, 1);
u = (dataTop--)->u;
dataTop->i = FICL_BOOL(dataTop->u > u);
continue;

}

/*
Expand Down

0 comments on commit 152e375

Please sign in to comment.