Wolfgang,
are you trying to tell us, that it works even while we don't know what we are doing?
What's wrong with: The first part (2^A) describes the number of bits necessary to decode 1 digit, the last part (2^C) compensates the number of shifts done on the accumulator on the previous digits ...
Search found 8 matches
- Sun Sep 08, 2013 4:07 pm
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
- Sun Sep 08, 2013 9:21 am
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
Re: binary to ascii
The assumption itself is not wrong but the assumption of what A is going to be in 2^A*10^B.
It hopefully gets clearer if one writes:
2^2*10^4
2^3*10^3*2^2
2^3*10^2*2^5
2^3*10^1*2^8
2^3*10^0*2^11
If my assumption would be right, then the second value for example should be:
2^6*10^3 or 2^3*10^3*2 ...
It hopefully gets clearer if one writes:
2^2*10^4
2^3*10^3*2^2
2^3*10^2*2^5
2^3*10^1*2^8
2^3*10^0*2^11
If my assumption would be right, then the second value for example should be:
2^6*10^3 or 2^3*10^3*2 ...
- Sat Sep 07, 2013 11:04 am
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
Re: binary to ascii
So that was helpful. A looping version pretty easily follows:
ldy #$00
sty outchar
ldy #2
ldx #10-1
@1 cmp table,x
bcc @2
sbc table,x
@2 rol outchar
dex
dey
bne @1
tay
lda outchar
and #$0F
ora #$30
jsr output
tya
ldy #4
cpx #-1
bne @1
rts
table: byte 1,2,4,8,10,20,40,80,100 ...
ldy #$00
sty outchar
ldy #2
ldx #10-1
@1 cmp table,x
bcc @2
sbc table,x
@2 rol outchar
dex
dey
bne @1
tay
lda outchar
and #$0F
ora #$30
jsr output
tya
ldy #4
cpx #-1
bne @1
rts
table: byte 1,2,4,8,10,20,40,80,100 ...
- Sat Sep 07, 2013 10:27 am
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
Re: binary to ascii
You are mixing the compare and subtract constant table .A with the preset for .B ...
No! I started with the assumption that all values in .A have to be of the form 2^A*10^B and (may be that was wrong?) that they have to be maximal but lower than 2^16. With this I get the .A values:
2^02*10^4
2 ...
- Fri Sep 06, 2013 1:47 pm
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
Re: binary to ascii
I have tried to expand it to 16 bits.
The .B constants would be for
1 shift : 10011000=$98
2 shifts: 01001100=$4C
3 shifts: 00100110=$26
4 shifts: 00010011=$13
all this constants fit in 1 byte. Unfortunately the second loop (4. decimal digit) needs 5 shifts. Can anybody confirm this?
Wolfgang
The .B constants would be for
1 shift : 10011000=$98
2 shifts: 01001100=$4C
3 shifts: 00100110=$26
4 shifts: 00010011=$13
all this constants fit in 1 byte. Unfortunately the second loop (4. decimal digit) needs 5 shifts. Can anybody confirm this?
Wolfgang
- Thu Sep 05, 2013 6:24 pm
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
Re: binary to ascii
barrym95838 wrote:
I agree, and I would like to place my bet for authorship on dclxvi (Bruce).
Mike
Mike
Wolfgang
- Thu Sep 05, 2013 6:23 pm
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
Re: binary to ascii
After staring at it for a bit I can tell that it's dreadfully clever, and that the hex constants loaded into the Y register (and subsequently stored in .B) serve two purposes, at least for OUTDEC8Z. The high bit is iteration control for the inner loop which runs two or four times per digit ...
- Thu Sep 05, 2013 2:36 pm
- Forum: Programming
- Topic: binary to ascii
- Replies: 25
- Views: 6031
binary to ascii
Hallo,
I am new to this forum. I have registered here because I found a little routine here , coded in 6502, which does a binary to ascii conversion and I could not understand fully how it is working.
I hope someone in this forum will give me some hints.
What is the name of that algorithm?
Is ...
I am new to this forum. I have registered here because I found a little routine here , coded in 6502, which does a binary to ascii conversion and I could not understand fully how it is working.
I hope someone in this forum will give me some hints.
What is the name of that algorithm?
Is ...