6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 7:30 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Running Loops
PostPosted: Thu Jul 27, 2006 2:28 am 
Offline

Joined: Wed Jul 26, 2006 4:53 am
Posts: 12
Hello Everyone,
This is my first of many posts so hopefully i hope no one gets tierd of me. Ok now that thats over with, On With the Show!!
I have a Few questions about running loops.

1. When an index register has finshed its loop and goes on the next instruction, does the that index register ,pardon my french ," stay closed" when it branches back to continue the loop?

2. Do you have to clear out the index register everytime you want to load a new value, how long will the value stay in the register?

3. Up to how much data or routines can the accumulator contain at any given time?


Top
 Profile  
Reply with quote  
 Post subject: Re: Running Loops
PostPosted: Thu Jul 27, 2006 4:40 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
nineTENdo wrote:
1. When an index register has finshed its loop and goes on the next instruction, does the that index register ,pardon my french ," stay closed" when it branches back to continue the loop?

I'm not sure I understand your question, but hopefully this will help.
Code:
Init    LDX  #$FF       ; initialize the index register to 255
Loop    LDA  $C000,X    ;  load some data values in Accum.
         ...
         ...     manipulate the data             
        DEX               ; dec index register
        BNE  Loop      ; if index <> 0, then do the loop again.
        ...      post loop code starts here

The value of x will remain unchanged during the execution of the loop as long as the "manipulate the data" code does not alter it. The DEX will decrement its value by one on each pass through the loop.

Quote:
2. Do you have to clear out the index register everytime you want to load a new value, how long will the value stay in the register?

No, you can just load the index with the new value. The old value will be discarded. the value will stay there indefinitely as long as you don't use opcodes that modify it.

Quote:
3. Up to how much data or routines can the accumulator contain at any given time?

The accumulator is a single 8 bit register. It can hold only one data byte at a time. IF you wish to hold many values at once, you can either use zero-page addressing mode variables, absolute addressing mode variables, or use the stack to push and pop values. The best choice depends on your specific application.

Daryl


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Aug 01, 2006 1:31 pm 
Offline

Joined: Tue Dec 30, 2003 10:35 am
Posts: 42
The point is that the 6502 doesn't work at the higher level of loops and structures. You get the nuts and bolts and have to construct these yourself. The index registers can be loaded with a new value, incremented/decremented, tested, etc. Each operation is minimal and self-contained.


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 12 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: