6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed May 08, 2024 12:00 pm

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: [55.1] SBC & BCD
PostPosted: Mon May 22, 2000 11:56 am 
I now have all of my 6502 emulator working but for one thing - BCD arithmetic. I can't help wondering exactly what the process is for BCD arithmetic. I've tried several things and none of them seem to work quite correctly.

This ties in to a question I have about SBC. I have read in several places that SBC uses exactly the same logic as ADC except that all the bits are inverted first. This explains neatly why carry should be set for no borrow, but confuses me further with BCD arithmetic. How could ADC possibly just be an inverted SBC when BCD arithmetic is concerned?

None of the documents seem to cover this at all, and even the sole remaining 6502 book in the library skips over the matter.

Thanks in advance
-Thomas


Report this post
Top
  
Reply with quote  
 Post subject: [55.2] SBC & BCD
PostPosted: Thu May 25, 2000 6:32 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 993
Location: near Heidelberg, Germany
Maybe you want to check the code of an

existing emulator, like the VICE C64
emulator. The homepage holds the

"64doc" file, that documents the 6502
opcodes incl. test programs und "undocumented" opcodes too.

Find the link on my homepage
http://www.6502.org/users/andre

Andre

_________________
Author of the GeckOS multitasking operating system, the usb65 stack, designer of the Micro-PET and many more 6502 content: http://6502.org/users/andre/


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [55.3] SBC & BCD
PostPosted: Sat Jun 10, 2000 2:58 am 
I'd recommend one thing, Thomas.

Consider what happens when you add $66 to a packed BCD value in the range 0..99 and then to that, add a second packed BCD value of that same range. As you'll see, the addition of the hex66 causes the subsequent value of the result, the carry, and the overflow to take legitimate values. Now consider that two's complement addition simply takes the subtractor, complements it and adds a one, then adds that to the subtrahend. If you follow the same procedure, doesn't that yield the correct result?

Think about it!

regards,

Dick


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: