6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 12:51 am

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: [117.1] Carry blues
PostPosted: Wed Jun 13, 2001 7:53 am 
Hi there

I am new to the 6502, and I am using on Sunplus chips which implement a %age of the cpu. Anyways my first question concerns the CMP instruction, do you need to set the carry before use, as you do for SBC?

My second question is whether anyone knows a relatively current book that covers the 6502. Because most books are from the early and mid 80s they are impossible to get :-(

Any help would be appretiated. happy coding

Charles.


Report this post
Top
  
Reply with quote  
 Post subject: [117.2] Carry blues
PostPosted: Thu Jun 14, 2001 1:38 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
Welcome Charles,

As far as the first question, no, you do not need to set the carry flag.

The operation description of the SBC command is:
A-M-(-C)->A with NVZC flags affected. The -C is the inverse of the carry flag.

The CMP operation description is:
A-M->A with NZC flags affected.

As far as the second question, I cannot answer that. My books are all from the 80's. However, www.6502.org has a good list of books and also some datasheets that may offer some help. Also, follow the link under commercial support to Sierra Circuit design. On their download links there is a 65C02 programmer's reference guide that could help as well.

Good luck!

Daryl (65c02@altavista.com)

_________________
Please visit my website -> https://sbc.rictor.org/


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [117.3] Carry blues
PostPosted: Thu Jun 14, 2001 3:11 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
Charles,

I'll add a little here to what Daryl said. Note that the CMP (as well as CPX and CPY) don't alter anything except the status flags he mentioned. A related dual-purpose instruction, BIT, allows quick testing of bits 6 & 7 of a memory location without any regard to what's in _any_ of the processor registers, and again without altering anything except status bits which you then normally branch on. One of the factors contributing to the efficiency of the 65 family of processors is the integration of instructions; ie, some instructions are already implied in others and don't need extra clocks to execute. This was a glaring shortcoming of the PIC microcontrollers when I started to use them. They're very inefficient compared to the 65c02.

Western Design Center in Mesa, AZ sells an excellent manual, "Programming the 65816, Including the 6502, 65c02, 65802." It's not cheap (maybe $60-- I can't remember) but it's very detailed and complete. At least at the time I bought mine a few years ago, it came in a large 3-ring binder with two inches of paper, all printed on both sides. This may sound daunting, but it's actually very well organized and written, and clear. If you ever thought the 16-bit version, the 65c816, was scarry, get this book, and you'll soon be hooked on the new possibilities opened up to you. Actually, if you only do 8-bit work in assembly language, the 65c816 may not have as much to offer you; but for 16(or more)-bit math and for running any higher-level language, the '816 is much more efficient than the '02. You'll really like it. Sure, it requires more learning, but it's not any harder. Even if you never become interested in the '816 though, this book will still be the one to get even for the 6502.

Garth

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [117.4] Carry blues
PostPosted: Thu Jun 14, 2001 11:58 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
Thanks for pointing out an error in my comments, Garth.

The corrected operation description for the CMP command is just:
A-M, with NZC flags affected. The results of the A-M operation are NOT stored back to A.

Sorry for that mistake!

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [117.5] Carry blues
PostPosted: Thu Jun 14, 2001 7:20 pm 
Offline

Joined: Thu Jul 24, 2003 8:01 pm
Posts: 24
Where in the world are you? I have a duplicate 6502 book or two.

Paul R. Santa-Maria
Monroe Michigan USA


Report this post
Top
 Profile  
Reply with quote  
 Post subject: [117.6] Carry blues
PostPosted: Fri Jun 15, 2001 6:05 am 
Hi Paul

I am actually in the UK, in Cambridge, so it may be a bit complicated.

Cheers

Charles.


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.  [ 6 posts ] 

All times are UTC


Who is online

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