Hi, I have to code two programs in 6502, the first one - showing on the screen hexa number - is done, and it works correctly, but the second one - showing decimal number on the screen - isn't working. I'm trying to connect the program, which is working with the functions which let count decimal number to get a working program. What I can't achieve, is output on the screen. The loop seems to be working, so the convertion might be done correctly, but there is no output on the screen. I tried using something similar to pr in hexa, jumping there and storing accumulator in $80, but without any effects. I removed my efforts to readability of my code. Could you tell me what should be changed in BCD code?
HEX:
Code:
opt f-g-h+l+o+
org $1000
start equ *
lda <text
sta $80
lda >text
sta $81
ldy #1
lda #$ba ; input
jsr phex
lda <text
ldx >text
jsr $ff80
brk
phex pha
jsr prhex
pla
lsr @
lsr @
lsr @
lsr @
prhex and #%00001111
ora #'0'
cmp #'9'+1
bcc pr
adc #6
pr sta ($80),y
dey
rts
byte dta b(0)
org $2000
text equ *
dta b(0),b(0)
dta b(10) ; '\n'
org $2E0
dta a(start)
end of file
BCD:
Code:
opt f-g-h+l+o+
org $1000
start equ *
lda <text
sta $80
lda >text
sta $81
jsr BINBCD8
lda <text
ldx >text
jsr $ff80
brk
BINBCD8 SED ; Switch to decimal mode
LDA #0 ; Ensure the result is clear
STA BCD+0
STA BCD+1
LDX #8 ; The number of source bits
CNVBIT ASL BIN ; Shift out one bit
LDA BCD+0 ; And add into result
ADC BCD+0
STA BCD+0
LDA BCD+1 ; propagating any carry
ADC BCD+1
STA BCD+1
DEY
DEX ; And repeat for next bit
BNE CNVBIT
CLD ; Back to binary
BRK ; All Done.
BCD equ 0
BIN equ 96
org $2000
text equ *
dta b(0),b(0),b(0),b(0),b(0),b(0),b(0),b(0)
dta b(10) ; '\n'
org $2E0
dta a(start)
end of file