diff options
1 files changed, 27 insertions, 2 deletions
| -rw-r--r-- | isprime/kernal.oph.s | 29 |
diff --git a/isprime/kernal.oph.s b/isprime/kernal.oph.s index b39d212..5dda4a4 100644 --- a/isprime/kernal.oph.s +++ b/isprime/kernal.oph.s @@ -14,9 +14,15 @@ tax .macend -printx: +.macro printm + lda _1 + jsr printa +.macend + +printx: txa ; a = x + +printa: .scope - txa ; a = x cmp #10 ; if (a < 10) bcc _1digit cmp #100 ; if (a < 100) @@ -59,6 +65,25 @@ _end: buffer: .byte 0 +; a = a % MemoryAddress +.macro modm + cmp _1 ; if (a < _1) return + bcc _end + + sec ; carry = 1 +_loop: sbc _1 ; do a -= _1 + !carry + beq _end ; if (a == 0) break + cmp _1 ; while (a >= _1) + bcs _loop +_end: +.macend + +; a = a % y +.macro mody + sty buffer + `modm buffer +.macend + ; a = a / _1 .macro div ora #0 ; The CMP (and friends) instruction changes the carry and zero flag, |
