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