diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-11-27 13:24:50 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-11-27 21:37:20 -0800 |
commit | 6f65b65f7d7261d79b58df25e5e0b20bfbc240ec (patch) | |
tree | 02197d3c76d993cf61ff0c2a5ff2bf7e016462b3 /apps/tile | |
parent | 704265bd3c805ea71c0a0bc8a4280de46976b126 (diff) | |
download | mu-6f65b65f7d7261d79b58df25e5e0b20bfbc240ec.tar.gz |
7290
I've wrestled for a long time with how to support integer division with its hard-coded registers. The answer's always been staring me in the face: just turn it into a function! We already expect function outputs to go to hard-coded registers.
Diffstat (limited to 'apps/tile')
-rw-r--r-- | apps/tile/value.mu | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/tile/value.mu b/apps/tile/value.mu index c3ff5fe4..790b2de2 100644 --- a/apps/tile/value.mu +++ b/apps/tile/value.mu @@ -155,8 +155,10 @@ fn render-screen screen: (addr screen), row: int, col: int, _target-screen: (add } fn hash-color val: int -> _/eax: int { - var result/eax: int <- try-modulo val, 7 # assumes that 7 is always the background color - return result + var quotient/eax: int <- copy 0 + var remainder/edx: int <- copy 0 + quotient, remainder <- integer-divide val, 7 # assumes that 7 is always the background color + return remainder } fn print-screen-cell-of-fake-screen screen: (addr screen), _target: (addr screen), _row: int, _col: int { |