From: Aaron Taylor Date: Mon, 8 Jul 2019 21:25:23 +0000 (-0700) Subject: Changed jump-if-tos-is-zero and jump-if-tos-is-negative to consume the test X-Git-Url: http://git.subgeniuskitty.com/vvhitespace/.git/commitdiff_plain/140262a9623b3c225a5135b9003526cb6b837926 Changed jump-if-tos-is-zero and jump-if-tos-is-negative to consume the test value on TOS, matching the behavior of Whitespace. --- diff --git a/tests/4003_flowcontrol_jump_if_tos_is_zero.pvvs b/tests/4003_flowcontrol_jump_if_tos_is_zero.pvvs index 42002b4..fbe806d 100644 --- a/tests/4003_flowcontrol_jump_if_tos_is_zero.pvvs +++ b/tests/4003_flowcontrol_jump_if_tos_is_zero.pvvs @@ -5,6 +5,5 @@ SSSSN | ST: Push +0 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 diff --git a/tests/4004_flowcontrol_jump_if_tos_is_negative.pvvs b/tests/4004_flowcontrol_jump_if_tos_is_negative.pvvs index 8517cd6..dc8a9c0 100644 --- a/tests/4004_flowcontrol_jump_if_tos_is_negative.pvvs +++ b/tests/4004_flowcontrol_jump_if_tos_is_negative.pvvs @@ -5,6 +5,5 @@ SSTTN | ST: Push -1 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 diff --git a/vv_interpreter.c b/vv_interpreter.c index dd72781..7705319 100644 --- a/vv_interpreter.c +++ b/vv_interpreter.c @@ -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 */ - /* 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. */ - /* 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. */