From e30666ecb57340af82327e49b157d3fa0d602888 Mon Sep 17 00:00:00 2001 From: Nafees10 Date: Sun, 19 Jan 2020 19:03:21 +0500 Subject: [PATCH] Updated to use jump positions instead of index --- examples/array | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/array b/examples/array index ee8c192..c08ef49 100644 --- a/examples/array +++ b/examples/array @@ -15,6 +15,7 @@ def 8 # 8 is just made up, I'm just assuming it doesn't need more than 8. pop # fill it with 0,1,2,3,4 - use element at stack[1] as counter + jumpBackToHere: pushFrom 1 # this one is value for writeTo pushFrom 1 # this one is index for arrayRefElement pushRefFrom 0 # and this is ref to array for arrayRefElement @@ -29,7 +30,7 @@ def 8 # 8 is just made up, I'm just assuming it doesn't need more than 8. pushFrom 1 push 5 isGreaterInt - JumpIf 12 # remember, lines that are comments don't count, so it needs to jump to instruction index 12, not line 12 + JumpIf jumpBackToHere # now write it's contents, lets just use a function for that pushFrom 0 @@ -43,6 +44,7 @@ def 8 # again, it **probably** doesn't need more than 8 pushFrom 0 arrayLength # this puts array length at stack[2] + jumpBackPosition: pushFrom 1 pushFrom 0 arrayElement @@ -58,5 +60,5 @@ def 8 # again, it **probably** doesn't need more than 8 pushFrom 1 pushFrom 2 isGreaterInt - jumpIf 3 + jumpIf jumpBackPosition terminate \ No newline at end of file