I don't have my references handy and google search doesn't bring up what I want in the first few searches. I want to do: 16 bits = 2 byte hex number with hi/lo bytes 16bit+16bit addition with 16 bit result 16bit-16bit subtraction with 16 bit result 16bit/16 bit division with 16 bit result (or 8?), with remainder 16 bit to 16 bit compare (greater than, less than, equal) all with 6502 instructions. I have plenty of books with this information in it but They aren't available to me right now. any help appreciated. Rich In article , "John B. Matthews" wrote: > In article <370265cd.0405111045.7cd359b7@posting.google.com>, > aiiadict@hotmail.com (Rich J.) wrote: > > > I don't have my references handy and google > > search doesn't bring up what I want in the first > > few searches. > > > > I want to do: > > > > 16 bits = 2 byte hex number with hi/lo bytes > > > > 16bit+16bit addition with 16 bit result > > 16bit-16bit subtraction with 16 bit result > > 16bit/16 bit division with 16 bit result (or 8?), with remainder > > 16 bit to 16 bit compare (greater than, less than, equal) > > > > all with 6502 instructions. > > > > I have plenty of books with this information in it but They aren't > > available to me right now. any help appreciated. > > > > Rich > > Steve Wozniak's Sweet 16 interpreter implements variations of > all these operations: > > http://www.6502.org/source/interpreters/sweet16.htm Egad! I'd have sworn Sweet 16 does multiply and divide. Instead, see lines 522 & 543 of the system monitor listing http://members.buckeye-express.com/marksm/6502/MON.TXT > You might also look at the /source/ and /tutorials/ directories > on the same site. > > John > ---- > jmatthews at wright dot edu > www dot wright dot edu/~john.matthews/ John ---- jmatthews at wright dot edu www dot wright dot edu/~john.matthews/ Rich J. wrote: > I don't have my references handy and google > search doesn't bring up what I want in the first > few searches. > > I want to do: > > 16 bits = 2 byte hex number with hi/lo bytes > > 16bit+16bit addition with 16 bit result > 16bit-16bit subtraction with 16 bit result > 16bit/16 bit division with 16 bit result (or 8?), with remainder > 16 bit to 16 bit compare (greater than, less than, equal) > > all with 6502 instructions. My meta-thought: 16-bit addition, subtraction, and comparison are operations you should be able to do without thinking. If not, examine the instruction set in the reference manual and figure it out. The exercise will help you learn 6502 far better than copying and pasting. 16-bit multiplication is harder. I recommend to anyone planning to do 6502 work that they sit down and figure out how to do it themselves, and only then compare it to optimized algorithms. (It just comes down to a collection of shifts and adds in base 2. Once you figure out how to multiply, other operations become more obvious.) 16-bit division is a bit harder to figure out... -- Send mail to fadden@fadden.com (Andy McFadden) - http://www.fadden.com/ CD-Recordable FAQ - http://www.cdrfaq.org/ CiderPress Apple II archive utility for Windows - http://www.faddensoft.com/ Fight Internet Spam - http://spam.abuse.net/spam/ & http://spamcop.net/ "Rich J." wrote in message news:370265cd.0405111045.7cd359b7@posting.google.com... > I don't have my references handy and google > search doesn't bring up what I want in the first > few searches. > > I want to do: > > 16 bits = 2 byte hex number with hi/lo bytes > > 16bit+16bit addition with 16 bit result > 16bit-16bit subtraction with 16 bit result > 16bit/16 bit division with 16 bit result (or 8?), with remainder > 16 bit to 16 bit compare (greater than, less than, equal) > > all with 6502 instructions. > > I have plenty of books with this information in it but They aren't > available to me right now. any help appreciated. > > Rich N1LO N1HI N2LO N2HI RSLTLO RSLTHI addition LDA N1LO CLC ADC N2LO STA RSLTLO LDA N1HI ADC N2HI STA RSTLHI subtraction LDA N1LO SEC SBC N2LO STA RSLTLO LDA N1HI SBC N2HI STA RSLTHI For comparison and division different routes are taken for signed verses unsigned numbers. And a fair degree of additional steps are needed. Also for dividing it matters whether you want the quotient or remainder. If you're using orca/m the macros might be quicker to code here. In article <370265cd.0405111045.7cd359b7@posting.google.com>, aiiadict@hotmail.com (Rich J.) wrote: > I don't have my references handy and google > search doesn't bring up what I want in the first > few searches. > > I want to do: > > 16 bits = 2 byte hex number with hi/lo bytes > > 16bit+16bit addition with 16 bit result > 16bit-16bit subtraction with 16 bit result > 16bit/16 bit division with 16 bit result (or 8?), with remainder > 16 bit to 16 bit compare (greater than, less than, equal) > > all with 6502 instructions. > > I have plenty of books with this information in it but They aren't > available to me right now. any help appreciated. > > Rich Steve Wozniak's Sweet 16 interpreter implements variations of all these operations: http://www.6502.org/source/interpreters/sweet16.htm You might also look at the /source/ and /tutorials/ directories on the same site. John ---- jmatthews at wright dot edu www dot wright dot edu/~john.matthews/