Changed jump-if-tos-is-zero and jump-if-tos-is-negative to consume the test
authorAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 8 Jul 2019 21:25:23 +0000 (14:25 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Mon, 8 Jul 2019 21:25:23 +0000 (14:25 -0700)
value on TOS, matching the behavior of Whitespace.

tests/4003_flowcontrol_jump_if_tos_is_zero.pvvs
tests/4004_flowcontrol_jump_if_tos_is_negative.pvvs
vv_interpreter.c

index 42002b4..fbe806d 100644 (file)
@@ -5,6 +5,5 @@ SSSSN           | ST: Push +0
 NTSTSTSTSN      | FC: BRZ -> '42'
 NNN             | FC: Terminate program
 NSSVTSTSTSN     | FC: Mark label '42'
 NTSTSTSTSN      | FC: BRZ -> '42'
 NNN             | FC: Terminate program
 NSSVTSTSTSN     | FC: Mark label '42'
-SNN             | ST: Drop TOS
 TNSS            | IO: Output character
 NNN             | FC: Terminate program
 TNSS            | IO: Output character
 NNN             | FC: Terminate program
index 8517cd6..dc8a9c0 100644 (file)
@@ -5,6 +5,5 @@ SSTTN           | ST: Push -1
 NTTTSTSTSN      | FC: BLZ -> '42'
 NNN             | FC: Terminate program
 NSSVTSTSTSN     | FC: Mark label '42'
 NTTTSTSTSN      | FC: BLZ -> '42'
 NNN             | FC: Terminate program
 NSSVTSTSTSN     | FC: Mark label '42'
-SNN             | ST: Drop TOS
 TNSS            | IO: Output character
 NNN             | FC: Terminate program
 TNSS            | IO: Output character
 NNN             | FC: Terminate program
index dd72781..7705319 100644 (file)
@@ -286,13 +286,11 @@ process_imp_flowcontrol(uint8_t * code, size_t * pc, int32_t ** sp, uint32_t * l
                 switch (next_code_byte(code,pc)) {
                     case ' ':
                         /* Jump to a label if TOS == 0 */
                 switch (next_code_byte(code,pc)) {
                     case ' ':
                         /* Jump to a label if TOS == 0 */
-                        /* TODO: Does WS pop or peek the TOS? */
-                        if (stack_peek(sp,0) == 0) *pc = labels[parse_label(code, pc)];
+                        if (stack_pop(sp) == 0) *pc = labels[parse_label(code, pc)];
                         break;
                     case '\t':
                         /* Jump to a label if TOS < 0. */
                         break;
                     case '\t':
                         /* Jump to a label if TOS < 0. */
-                        /* TODO: Does WS pop or peek the TOS? */
-                        if (stack_peek(sp,0) < 0) *pc = labels[parse_label(code, pc)];
+                        if (stack_pop(sp) < 0) *pc = labels[parse_label(code, pc)];
                         break;
                     case '\n':
                         /* Return from subroutine. */
                         break;
                     case '\n':
                         /* Return from subroutine. */