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 Raspberry PI  */
/*  program taufunction.s   */
 
 /* REMARK 1 : this program use routines in a include file 
   see task Include a file language arm assembly 
   for the routine affichageMess conversion10 
   see at end of this program the instruction include */
/* for constantes see task include a file in arm assembly */
/************************************/
/* Constantes                       */
/************************************/
.include "../constantes.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 r0,#1                     @ factor number one
    bl displayResult
    mov r0,#2                     @ factor number two
    bl displayResult
    mov r2,#3                     @ begin number three
1:                                @ begin loop 
    mov r5,#2                     @ divisor counter
    mov r4,#2                     @ first divisor 1
2:
    udiv r0,r2,r4                 @ compute divisor 2
    mls r3,r0,r4,r2               @ remainder
    cmp r3,#0
    bne 3f                        @ remainder = 0 ?
    cmp r0,r4                     @ same divisor ?
    addeq r5,r5,#1                @ yes increment one
    addne r5,r5,#2                @ no increment two
3:
    add r4,r4,#1                  @ increment divisor
    cmp r4,r0                     @ divisor 1  < divisor 2
    blt 2b                        @ yes -> loop
 
    mov r0,r5                     @ equal -> display
    bl displayResult
 
    add r2,#1                     @ 
    cmp r2,#MAXI                  @ end ?
    bls 1b                        @ no -> loop
 
    ldr r0,iAdrszCarriageReturn
    bl affichageMess
 
100:                              @ standard end of the program 
    mov r0, #0                    @ return code
    mov r7, #EXIT                 @ request to exit program
    svc #0                        @ perform the system call
iAdrszCarriageReturn:        .int szCarriageReturn
/***************************************************/
/*   display message number                        */
/***************************************************/
/* r0 contains the number            */
displayResult:
    push {r1,r2,lr}               @ save registers 
    ldr r1,iAdrsZoneConv
    bl conversion10               @ call décimal conversion
    mov r2,#0
    strb r2,[r1,r0]
    ldr r0,iAdrsMessResult
    ldr r1,iAdrsZoneConv          @ insert conversion in message
    bl strInsertAtCharInc
    bl affichageMess              @ display message
    pop {r1,r2,pc}                @ restaur des registres
iAdrsMessResult:     .int sMessResult
iAdrsZoneConv:       .int sZoneConv  
/***************************************************/
/*      ROUTINES INCLUDE                           */
/***************************************************/
.include "../affichage.inc"
 