Given a positive integer, count the number of its positive divisors.



Task
Show the result for the first   100   positive integers.



Related task
  Tau number


 
/* ARM assembly AARCH64 Raspberry PI 3B or android 64 bits */
/*  program taufunction64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
.equ MAXI,      100
 
/*********************************/
/* Initialized data              */
/*********************************/
.data
sMessResult:        .asciz " @ "
szCarriageReturn:   .asciz "\n"
 
/*********************************/
/* UnInitialized data            */
/*********************************/
.bss  
sZoneConv:                  .skip 24
/*********************************/
/*  code section                 */
/*********************************/
.text
.global main 
main:                             // entry of program 
    mov x0,#1                     // factor number one
    bl displayResult
    mov x0,#2                     // factor number two
    bl displayResult
    mov x2,#3                     // begin number three
1:                                // begin loop 
    mov x5,#2                     // divisor counter
    mov x4,#2                     // first divisor 1
2:
    udiv x0,x2,x4                 // compute divisor 2
    msub x3,x0,x4,x2              // remainder
    cmp x3,#0
    bne 3f                        // remainder = 0 ?
    cmp x0,x4                     // same divisor ?
    add x3,x5,1
    add x6,x5,2
    csel x5,x3,x6,eq
3:
    add x4,x4,#1                  // increment divisor
    cmp x4,x0                     // divisor 1  < divisor 2
    blt 2b                        // yes -> loop
 
    mov x0,x5                     // equal -> display
    bl displayResult
 
    add x2,x2,1
    cmp x2,MAXI                   // end ?
    bls 1b                        // no -> loop
 
    ldr x0,qAdrszCarriageReturn
    bl affichageMess
 
100:                              // standard end of the program 
    mov x0, #0                    // return code
    mov x8, #EXIT                 // request to exit program
    svc #0                        // perform the system call
qAdrszCarriageReturn:        .quad szCarriageReturn
/***************************************************/
/*   display message number                        */
/***************************************************/
/* x0 contains the number            */
displayResult:
    stp x1,lr,[sp,-16]!      // save  registres
    ldr x1,qAdrsZoneConv
    bl conversion10          // call décimal conversion
    strb wzr,[x1,x0]
    ldr x0,qAdrsMessResult
    ldr x1,qAdrsZoneConv     // insert conversion in message
    bl strInsertAtCharInc
    bl affichageMess         // display message
    ldp x1,lr,[sp],16        // restaur des  2 registres
    ret
qAdrsMessResult:     .quad sMessResult
qAdrsZoneConv:       .quad sZoneConv 
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc" 
 