6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 21, 2024 5:22 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Sep 06, 2024 5:57 pm 
Offline

Joined: Fri Sep 06, 2024 5:39 pm
Posts: 1
During my adventures in emulator's land I found numerous discussions and many valuable articles about implementing ADC/SBC routines in 6502. Finally I was able to create something that should be - in my humble opinion - a sweet spot between a general description like:
Code:
if AL >= $0A, then AL = ((AL + $06) & $0F) + $10
and
Code:
DS3 = ( ((BS1 | BS2) & DAA) | (~BS1 | ~BS2) & DSA) ^ BS3
(in my opinion first version hides operations on particular nybbles by mixing $06 and $10 on AL, that suggest "lower part" - and second is too cumbersome for many to understood).

My attempt is available here: https://github.com/aniou/morfeo/blob/master/doc/6502-ADC-SBC-implementation.rst and I will be glad for Your opinions and suggestions. Code itself successfully passed two test suites - "classic" Clark's suite and SingleStepTests for 65C02 and 65C816 in both native and emulation mode. 6502 was not tested, but should work after small adjustments in flag checking.

Code itself is not too performant nor smart, but was created in this form intentionally - as clear and illustrative to particular CPU behaviors as possible. It is - surprisingly even to me - very compact and universal.

In worst case at least "Bibliography" section should be useful for someone. :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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: