“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code.

Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers.



Task

Show how two loops may be nested within each other, with the number of iterations performed by the inner for loop being controlled by the outer for loop.

Specifically print out the following pattern by using one for loop nested in another:

*
**
***
****
*****


Related tasks

   Loop over multiple arrays simultaneously
   Loops/Break
   Loops/Continue
   Loops/Do-while
   Loops/Downward for
   Loops/For
   Loops/For with a specified step
   Loops/Foreach
   Loops/Increment loop index within loop body
   Loops/Infinite
   Loops/N plus one half
   Loops/Nested
   Loops/While
   Loops/with multiple ranges
   Loops/Wrong ranges




Reference

 For loop Wikipedia.


 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program loop64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*******************************************/
/* Initialized data                        */
/*******************************************/
.data
szMessX: .asciz "X"
szCarriageReturn:  .asciz "\n"
/*******************************************/
/* UnInitialized data                      */
/*******************************************/
.bss 
/*******************************************/
/*  code section                           */
/*******************************************/
.text
.global main 
main:                     // entry of program
 
    mov x2,0              // counter loop 1
1:                        // loop start 1
    mov x1,0              // counter loop 2
2:                        // loop start 2
    ldr x0,qAdrszMessX
    bl affichageMess
    add x1,x1,1           // x1 + 1
    cmp x1,x2             // compare x1 x2
    ble 2b                // loop label 2 before
    ldr x0,qAdrszCarriageReturn   
    bl affichageMess
    add x2,x2,1           // x2 + 1
    cmp x2,#5             // for five loop
    blt 1b                // loop label 1 before
 
 
100:                      // standard end of the program */
    mov x0,0              // return code
    mov x8,EXIT           // request to exit program
    svc 0                 // perform the system call
 
qAdrszMessX:           .quad szMessX
qAdrszCarriageReturn:  .quad  szCarriageReturn
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 