6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 10:14 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: MOS vs WDC in BCD Mode
PostPosted: Sat May 04, 2024 5:14 am 
Offline
User avatar

Joined: Tue Feb 28, 2023 11:39 pm
Posts: 257
Location: Texas
So I'm working to convert the assembly level functions for the Kowalski emulator into C; that way it can be made portable across platforms.

One thing I've noticed is it seems that it has different BCD behavior for if it's in "Basic 6502" mode (I presume original MOS) and 6501/65C02

It appears that the negative and zero status flags are computed differently depending on which you use.


As I have no access to a MOS 6502 (or a 6501 for that matter) I was curious if anyone could confirm/deny if these variations do in fact have differences in how they calculate these flags.


Trying to make sure I get this conversion as close to accurate as I can get. Thanks!


Top
 Profile  
Reply with quote  
PostPosted: Sat May 04, 2024 6:20 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
I highly recommend Bruce's BCD article in the tutorials section.

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
PostPosted: Sat May 04, 2024 7:14 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8504
Location: Midwestern USA
Yuri wrote:
So I'm working to convert the assembly level functions for the Kowalski emulator into C; that way it can be made portable across platforms.

Pedantic note: the Kowalski package is a simulator...it doesn’t emulate any hardware

Quote:
One thing I've noticed is it seems that it has different BCD behavior for if it's in "Basic 6502" mode (I presume original MOS) and 6501/65C02

The reason for that is only carry is valid when the NMOS 6502 is performing BCD addition and subtraction.  The negative (n) and zero (z) flags are meaningless, as they reflect the result of the underlying binary operation that occurs before decimal correction is applied.

On the other hand, the 65C02’s n and z correctly reflect the BCD result.  This is also true with the 65C816, whether in emulation or native mode.

The overflow (v) flag is an outlier in BCD arithmetic, as the 6502 family can only do unsigned BCD addition and subtraction.  Hence v is effectively meaningless in BCD mode.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 14 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: