diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-11-07 15:26:04 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-11-07 15:26:04 -0800 |
commit | 8338c38698aab9f885af0ddac3a1d47a31991f97 (patch) | |
tree | 92e8799eada5677ca805f6398492ffd78703651d /apps/tile | |
parent | 2136ad26b86599fd4a38190d29f590c3e5557371 (diff) | |
download | mu-8338c38698aab9f885af0ddac3a1d47a31991f97.tar.gz |
7205 - tile: magnitudes for up/down/left/right
Diffstat (limited to 'apps/tile')
-rw-r--r-- | apps/tile/rpn.mu | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu index 0f6e16fa..2563928f 100644 --- a/apps/tile/rpn.mu +++ b/apps/tile/rpn.mu @@ -300,7 +300,6 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: compare *top-addr, 0 break-if-<= # pop string from out - var out2/esi: (addr value-stack) <- copy out var top-addr/ecx: (addr int) <- get out2, top compare *top-addr, 0 break-if-<= @@ -334,6 +333,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: compare is-move?, 0 break-if-= var out2/esi: (addr value-stack) <- copy out + # pop args var _r/eax: int <- pop-int-from-value-stack out2 var r/ecx: int <- copy _r var _c/eax: int <- pop-int-from-value-stack out2 @@ -362,10 +362,15 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: compare is-up?, 0 break-if-= var out2/esi: (addr value-stack) <- copy out - # select screen from top of out (but don't pop it) var top-addr/ebx: (addr int) <- get out2, top compare *top-addr, 0 break-if-<= + # pop args + var _d/eax: int <- pop-int-from-value-stack out2 + var d/ecx: int <- copy _d + # select screen from top of out (but don't pop it) + compare *top-addr, 0 + break-if-<= var data-ah/eax: (addr handle array value) <- get out2, data var _data/eax: (addr array value) <- lookup *data-ah var data/edi: (addr array value) <- copy _data @@ -382,7 +387,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var dest/eax: (addr int) <- get target, cursor-row compare *dest, 1 break-if-<= $evaluate:process-word - decrement *dest + subtract-from *dest, d break $evaluate:process-word } { @@ -390,10 +395,15 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: compare is-down?, 0 break-if-= var out2/esi: (addr value-stack) <- copy out - # select screen from top of out (but don't pop it) var top-addr/ebx: (addr int) <- get out2, top compare *top-addr, 0 break-if-<= + # pop args + var _d/eax: int <- pop-int-from-value-stack out2 + var d/ecx: int <- copy _d + # select screen from top of out (but don't pop it) + compare *top-addr, 0 + break-if-<= var data-ah/eax: (addr handle array value) <- get out2, data var _data/eax: (addr array value) <- lookup *data-ah var data/edi: (addr array value) <- copy _data @@ -407,12 +417,14 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-ah/eax: (addr handle screen) <- get target-val, screen-data var _target/eax: (addr screen) <- lookup *target-ah var target/edi: (addr screen) <- copy _target - var bound-a/ecx: (addr int) <- get target, num-rows - var bound/ecx: int <- copy *bound-a var dest/eax: (addr int) <- get target, cursor-row - compare *dest, bound - break-if->= $evaluate:process-word - increment *dest + { + var bound-a/ecx: (addr int) <- get target, num-rows + var bound/ecx: int <- copy *bound-a + compare *dest, bound + break-if->= $evaluate:process-word + } + add-to *dest, d break $evaluate:process-word } { @@ -420,10 +432,15 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: compare is-left?, 0 break-if-= var out2/esi: (addr value-stack) <- copy out - # select screen from top of out (but don't pop it) var top-addr/ebx: (addr int) <- get out2, top compare *top-addr, 0 break-if-<= + # pop args + var _d/eax: int <- pop-int-from-value-stack out2 + var d/ecx: int <- copy _d + # select screen from top of out (but don't pop it) + compare *top-addr, 0 + break-if-<= var data-ah/eax: (addr handle array value) <- get out2, data var _data/eax: (addr array value) <- lookup *data-ah var data/edi: (addr array value) <- copy _data @@ -440,7 +457,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var dest/eax: (addr int) <- get target, cursor-col compare *dest, 1 break-if-<= $evaluate:process-word - decrement *dest + subtract-from *dest, d break $evaluate:process-word } { @@ -448,10 +465,15 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: compare is-right?, 0 break-if-= var out2/esi: (addr value-stack) <- copy out - # select screen from top of out (but don't pop it) var top-addr/ebx: (addr int) <- get out2, top compare *top-addr, 0 break-if-<= + # pop args + var _d/eax: int <- pop-int-from-value-stack out2 + var d/ecx: int <- copy _d + # select screen from top of out (but don't pop it) + compare *top-addr, 0 + break-if-<= var data-ah/eax: (addr handle array value) <- get out2, data var _data/eax: (addr array value) <- lookup *data-ah var data/edi: (addr array value) <- copy _data @@ -465,12 +487,14 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var target-ah/eax: (addr handle screen) <- get target-val, screen-data var _target/eax: (addr screen) <- lookup *target-ah var target/edi: (addr screen) <- copy _target - var bound-a/ecx: (addr int) <- get target, num-cols - var bound/ecx: int <- copy *bound-a var dest/eax: (addr int) <- get target, cursor-col - compare *dest, bound - break-if->= $evaluate:process-word - increment *dest + { + var bound-a/ecx: (addr int) <- get target, num-cols + var bound/ecx: int <- copy *bound-a + compare *dest, bound + break-if->= $evaluate:process-word + } + add-to *dest, d break $evaluate:process-word } ## HACKS: we're trying to avoid turning this into Forth |