Page 2 of 2
Still Not Showing the 3 Digits or more
Posted: Wed Nov 10, 2010 1:39 pm
by Amenofhis
Still not Showing the digits numbers
Code: Select all
Broken external image link
http://i52.tinypic.com/w9e9gh.jpg
Posted: Wed Nov 10, 2010 4:42 pm
by 8BIT
You replaced the BRA f1 with JSR f1.
I said use JMP F1. Using JSR will cause possible stack problems.
Give that a try.
Daryl
Posted: Wed Nov 10, 2010 6:54 pm
by Amenofhis
You replaced the BRA f1 with JSR f1.
I said use JMP F1. Using JSR will cause possible stack problems.
Give that a try.
Daryl
i tried both still getting same result..
Posted: Wed Nov 10, 2010 10:22 pm
by GARTHWILSON
The part at the end that says
Code: Select all
n1: .db $10 ; multiplicand
n2: .db $15 ; multiplier
p: .DB $0 ; product
could be part of the problem. I initially misinterpreted the ".DB" (or ".db") because none of the 6502 assemblers I've used this notation, and I was thinking that n1 was stored at
address $0010, n2 at $0015, and p at $0000, which now I realize is incorrect. Since you're putting the actual variable space after the code and only leaving one byte for each, now with the modification for higher precision you will have to put in two bytes for each so the high byte of each does not overwrite the low byte of the next one. Then, put your inputs in the code there at n1 and n2, low byte first (as is customary with 6502).
For output, you can watch the content of p. You didn't tell us what kind of output is at "salida"; and when I added "salida+1", I had no way of knowing if that byte was available for the high byte. I probably should have used "salida2" which you never referenced except to define it.
Posted: Thu Nov 11, 2010 12:21 am
by Amenofhis
The part at the end that says
Code: Select all
n1: .db $10 ; multiplicand
n2: .db $15 ; multiplier
p: .DB $0 ; product
could be part of the problem. I initially misinterpreted the ".DB" (or ".db") because none of the 6502 assemblers I've used this notation, and I was thinking that n1 was stored at
address $0010, n2 at $0015, and p at $0000, which now I realize is incorrect. Since you're putting the actual variable space after the code and only leaving one byte for each, now with the modification for higher precision you will have to put in two bytes for each so the high byte of each does not overwrite the low byte of the next one. Then, put your inputs in the code there at n1 and n2, low byte first (as is customary with 6502).
For output, you can watch the content of p. You didn't tell us what kind of output is at "salida"; and when I added "salida+1", I had no way of knowing if that byte was available for the high byte. I probably should have used "salida2" which you never referenced except to define it.
.db is like a database
Posted: Thu Nov 11, 2010 1:02 am
by GARTHWILSON
I think it stands for "define byte," and "dw would be "define word," etc. (or "declare byte," "declare word," etc.).
Posted: Thu Nov 11, 2010 1:16 pm
by Amenofhis
I think it stands for "define byte," and "dw would be "define word," etc. (or "declare byte," "declare word," etc.).
thats true... sorry i related db to database.. im also working on Oracle right now well Anyway thanks you
Posted: Thu Nov 11, 2010 1:20 pm
by Amenofhis
I find IT!!!!!!!!!! FINALY!!! its multiply to 99!!! without NO PROBLEM!!!!
salida=io_area+3
salida2=io_area+3
.ORG $0200
sed
LDA n2
BEQ fin
f1: LDA p
CLC
ADC n1
STA p
BCs carry
f2:
LDA n2
SEC
SBC #1
STA n2
BEQ fin
JMP f1
fin:
LDA $00
STA salida
LDA p
STA salida
BRK
carry:
LDA #00
ADC 00
sta 00
jmp f2
n1: .DB $99
n2: .db $99
p: .DB $0
now what i want to do is multiply more than 2 digits so.. i have to make 8 bit to 16 bit using my program, how i do this?
Thank you to all of you, who helped me and did gave me some advice and help with my programing hope u guys keep helping me with this one
Posted: Fri Nov 12, 2010 10:40 pm
by Amenofhis
I need to make this one to 16 bit.. so i could see larger numbers can some one give me some help me
Posted: Sat Nov 13, 2010 5:13 pm
by teamtempest
I assume your output device likes to see its input in BCD form, which is why you use decimal mode. That would also explain why the "dec" instruction is commented out in your original code and replaced with a subtraction, since "dec" would not have the desired result.
There is a nice tutorial on 65xx decimal mode operations on this very site:
http://www.6502.org/tutorials/decimal_mode.html
It includes details on how to do multiple-byte additions and subtractions. Briefly, they are no different than binary multiple-byte additions and subtractions. You can do your multiplication by repeated addition of multiple-byte numbers.
More efficient algorithms are possible, but decimal multiplication and division are much more difficult than binary on 65xx processors. A pair of routines using the "Russian Peasant" algorithm can be found here:
http://www.llx.com/~nparker/a2/decimal.html