6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Oct 01, 2024 7:28 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Machine cycles
PostPosted: Sat Jun 27, 2009 1:05 pm 
Offline

Joined: Sat Jun 27, 2009 1:01 pm
Posts: 1
Location: Maryland
How many machine cycles will CPU take to complete the following:

39+40+12+75-68


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jun 27, 2009 2:39 pm 
Offline

Joined: Fri Jun 27, 2003 8:12 am
Posts: 618
Location: Meadowbrook
Write the program then count the opcode cycles. Simple.

_________________
"My biggest dream in life? Building black plywood Habitrails"


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jun 27, 2009 6:34 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8521
Location: Southern California
Since you know the inputs beforehand and the result fits in a single byte without overflowing, you can do it with a half-dozen 2-clock instructions, for a total of 12 clocks (or T-states), which is only one machine cycle on some processors. That's one microsecond at 12MHz.

Code:
     LDA #39 ; These are all 2-clock instructions.
     CLC
     ADC #40
     ADC #12
     ADC #75
     ADC #68 ; Result is in accumulator.


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: Google [Bot] and 7 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: