It is currently Tue Oct 17, 2017 6:38 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sat May 13, 2017 1:04 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10046
Location: Rio de Janeiro - Brazil
Signed or unsigned is the same when represented in binary. The program gets to choose whether to interpret them as signed or unsigned.


Top
 Profile  
 
PostPosted: Sat May 13, 2017 11:37 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5709
Location: Canada
PolarBITS wrote:
rainwarrior wrote:
(On the first test it will be $FF = -1, on the 256th test it will be back down to 0.)

So you're saying that all numbers in RAM are unsigned bytes? I completely forgot about that lol.

Well, I was really saying that $FF and -1 are equivalent names for binary %11111111. It's a standard two's complement binary representation of numbers.

Aside from the indexed address modes where X or Y is always interpreted as unsigned, or the immediate branch argument which is always signed, it's generally up to how you use it. Usually "unsigned" usage is simpler/faster, so it's sort of the default case for 6502.

For instance: an unsigned less-than comparison is just CMP followed by BCC or BCS. The equivalent signed less-than comparison involves a few more steps, though if the numbers involved are small enough not to cause an overflow, CMP followed by BMI or BPL can be sufficient as a limited "signed" comparison. BMI might also be useful for testing an unsigned byte for >= 128, so it's not necessarily a "signed" instruction.

Anyhow, it may be helpful when learning to think of it as unsigned by default?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 2 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:  
Powered by phpBB® Forum Software © phpBB Group