I need a help with this

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Amenofhis
Posts: 31
Joined: 21 Nov 2008

Still Not Showing the 3 Digits or more

Post by Amenofhis »

Still not Showing the digits numbers

Code: Select all

Broken external image link
http://i52.tinypic.com/w9e9gh.jpg
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Post 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
Amenofhis
Posts: 31
Joined: 21 Nov 2008

Post by Amenofhis »

8BIT wrote:
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..
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post 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.
Amenofhis
Posts: 31
Joined: 21 Nov 2008

Post by Amenofhis »

GARTHWILSON wrote:
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
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post by GARTHWILSON »

Quote:
.db is like a database
I think it stands for "define byte," and "dw would be "define word," etc. (or "declare byte," "declare word," etc.).
Amenofhis
Posts: 31
Joined: 21 Nov 2008

Post by Amenofhis »

GARTHWILSON wrote:
Quote:
.db is like a database
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
Amenofhis
Posts: 31
Joined: 21 Nov 2008

Post 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
Amenofhis
Posts: 31
Joined: 21 Nov 2008

Post 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
teamtempest
Posts: 443
Joined: 08 Nov 2009
Location: Minnesota
Contact:

Post 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
Post Reply