From 046e43cd668e86057443f03ec1c87f91f20a5435 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Tue, 27 Nov 2018 13:05:19 +0000 Subject: [PATCH] Add another example. Even more convincing that the order is wrong. --- eg/rudiments/cmp-byte.60p | 74 ++++++++++++++++++++++++++ eg/rudiments/{cmp.60p => cmp-word.60p} | 14 +++-- 2 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 eg/rudiments/cmp-byte.60p rename eg/rudiments/{cmp.60p => cmp-word.60p} (87%) diff --git a/eg/rudiments/cmp-byte.60p b/eg/rudiments/cmp-byte.60p new file mode 100644 index 0000000..c2613d9 --- /dev/null +++ b/eg/rudiments/cmp-byte.60p @@ -0,0 +1,74 @@ +// Should print ENGGL + +byte b + +define chrout routine + inputs a + trashes a + @ 65490 + +define main routine + outputs b + trashes a, x, y, z, n, c, v +{ + ld a, 40 + st a, b + + cmp a, b + if z { + ld a, 69 // E + call chrout + } else { + ld a, 78 // N + call chrout + } + + ld a, 41 + st a, b + ld a, 40 + + cmp a, b + if z { + ld a, 69 // E + call chrout + } else { + ld a, 78 // N + call chrout + } + + ld a, 20 + st a, b + + ld a, 21 + + cmp a, b // 21 >= 20 + if c { + ld a, 71 // G + call chrout + } else { + ld a, 76 // L + call chrout + } + + ld a, 20 + + cmp a, b // 20 >= 21 + if c { + ld a, 71 // G + call chrout + } else { + ld a, 76 // L + call chrout + } + + ld a, 19 + + cmp a, b // 19 < 21 + if c { + ld a, 71 // G + call chrout + } else { + ld a, 76 // L + call chrout + } +} diff --git a/eg/rudiments/cmp.60p b/eg/rudiments/cmp-word.60p similarity index 87% rename from eg/rudiments/cmp.60p rename to eg/rudiments/cmp-word.60p index 23ec7ee..ffbd46a 100644 --- a/eg/rudiments/cmp.60p +++ b/eg/rudiments/cmp-word.60p @@ -1,4 +1,4 @@ -// Should print ENLGG +// Should print ENGGL word w1 word w2 @@ -36,10 +36,10 @@ define main routine call chrout } - copy 20000, w1 + copy 20002, w1 copy 20001, w2 - cmp w1, w2 + cmp w1, w2 // 20002 >= 20001 if c { ld a, 71 // G call chrout @@ -49,9 +49,8 @@ define main routine } copy 20001, w1 - copy 20001, w2 - cmp w1, w2 + cmp w1, w2 // 20001 >= 20001 if c { ld a, 71 // G call chrout @@ -60,10 +59,9 @@ define main routine call chrout } - copy 20002, w1 - copy 20001, w2 + copy 20000, w1 - cmp w1, w2 + cmp w1, w2 // 20000 < 20001 if c { ld a, 71 // G call chrout