Jump to content
Pengwin

Basic MADS question - Repeat

Recommended Posts

I am trying to work my way through the 'translated' MADS documentation, but the 'repeat' instructions are just notmaking sense to me.

 

Could some explain how to repeat a line of code? So I don't need to put in things like:

 

lsr
lsr
lsr
lsr

 

or do that I could create a macro to repeat something x amount of times using a parameter?

Share this post


Link to post
Share on other sites

or for more complex stuff use .REPT/ENDR with preset parameters based on the iteration count (#)

 

.rept 4,#,#*2

lda $1000+:1

sta $2000+:2

.endr

 

 

=>

 

4 4000 AD 00 10 lda $1000+0

5 4003 8D 00 20 sta $2000+0

4 4006 AD 01 10 lda $1000+1

5 4009 8D 02 20 sta $2000+2

4 400C AD 02 10 lda $1000+2

5 400F 8D 04 20 sta $2000+4

4 4012 AD 03 10 lda $1000+3

5 4015 8D 06 20 sta $2000+6

  • Like 1

Share this post


Link to post
Share on other sites

or for more complex stuff use .REPT/ENDR with preset parameters based on the iteration count (#)

 

.rept 4,#,#*2

lda $1000+:1

sta $2000+:2

.endr

 

 

Nice, didn't know that you can use parameters with .REPT (I would have used # and #*2 directly in the inside).

 

You can also use the iteration count # with the other format:

 

:4 sta $2000+#*2

 

==>

 

sta $2000

sta $2002

sta $2004

sta $2006

 

Sometime ago I would have liked to nest .REPT statements, but I couldn't .. I don't know if it's possible now (but you can use the :n format inside a .REPT)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...