From bd9edb1309e8726f3737f258c423b056c999a5c8 Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Thu, 20 Mar 2025 19:39:06 -0600 Subject: [PATCH] bcd conversion --- main.s | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/main.s b/main.s index 62f7001..89ebbbe 100644 --- a/main.s +++ b/main.s @@ -5,7 +5,7 @@ .byte $01, $00 ; mapper 0, vertical mirroring .segment "VECTORS" - .addr 0 ; nmi interrupt + .addr nmi ; nmi interrupt .addr reset ; reset interrupt .addr 0 ; external interrupt @@ -13,12 +13,65 @@ .segment "CODE" -reset: - ldx #3 - inx - inx - dex +check: + cmp #5 + bcc skip + clc + adc #3 +skip: + rts - ldy #7 - dey - rts \ No newline at end of file +reset: + lda #173 + sta $00 + lda #0 + sta $01 + sta $02 +dabble: + ; check first digit + lda $01 + and #$F + jsr check + sta $03 + lda #$F0 + and $01 + ora $03 + sta $01 + ; check second digit + lda $01 + and #$F0 + lsr + lsr + lsr + lsr + jsr check + asl + asl + asl + asl + sta $03 + lda #$F + and $01 + ora $03 + sta $01 + ; check third digit + lda $02 + and #$F + jsr check + sta $03 + lda #$F0 + and $02 + ora $03 + sta $02 + ; Shift + clc + rol $00 + rol $01 + rol $02 + lda $00 + cmp #0 + bne dabble + rts + +nmi: + rti \ No newline at end of file