/* Example code for loop/lend Loop/Lend is a simple way to repeat a block of instructions a number of times. It does nothing you couldn't do with a repeat or while loop, but it doesn't require a control variable. Note that if the count for a loop is zero or negative it will be ignored, i.e. the statements inside the loop won't be used even once. So, here are a couple of examples. */ ; A simple loop that fills a block of memory with a pattern. ; (look at the code tab to see it) org 0 ; Start at zero loop 32 ; 32 * 8 = 256 bytes db $00,$01,$02,$03,$04,$05,$06,$07 ; lend ; ; Now, two nested loops with a relative instruction inside, so the value changes. org $200 ; Start at $200 Fred loop 8 ; 8 outer loops loop 2 ; 2 inner loops jr Fred ; Something that changes lend ; lend ; ; Now, same again but all on one line... loop 8:loop 2: jr Fred:lend:lend; Neurgh! ; I'm sure you get the idea. ; For backward-compatibility with other assemblers Zeus also supports "rept" .. "mend" for loops. ; rept 32 ; 32 * 8 = 256 bytes ; db $00,$01,$02,$03,$04,$05,$06,$07 ; ; mend ;