xucaen Posted January 25, 2005 Share Posted January 25, 2005 Hi all, I hope this is the right forum for posting general questions about 6502 assembler.. For this question I am refering to the book Assembly Language Programming for the Atari Computers By Mark Chasin published 1984. I have read the online version at atariarchives and this question refers specifically to appendix one . SEC ;be sure C is set LDA #24 ;1st number SBC #26 ;2nd number ? ;answer now in accumulator What is the answer at the "?"? We set the Carry bit before we started, and it's obvious that we needed to borrow before we could perform the subtraction. Therefore, it's apparent that the Carry bit following this subtraction will be zero. When it is used for borrowing, the Carry bit has a value of 256; we began with the number 256 + 24 = 280 and we subtracted 26, leaving an answer of 254. Using the SBC instruction, we can subtract any number from another. Note that here we have confined our examples to numbers which can be expressed in a single byte. Double-precision arithmetic was used in several examples in Chapters 7 to 10. In this example, after SBC is completed, will the carry bit be set to zero or one? I had thought it would be zero, but after reading this I'm not so sure. If the Cary bit has a value of 256, then should I assume that any value less that 256 is zero? Or maybe a better way to look at might be that if the carry bit is set, then the value 256 is used in the borrow, then after the borrow the carry is zero? Jim Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.