Task

Write a program that prints the integers from   1   to   100   (inclusive).



But:

   for multiples of three,   print   Fizz     (instead of the number)
   for multiples of five,   print   Buzz     (instead of the number)
   for multiples of both three and five,   print   FizzBuzz     (instead of the number) 


The   FizzBuzz   problem was presented as the lowest level of comprehension required to illustrate adequacy.



Also see

   (a blog)   dont-overthink-fizzbuzz
   (a blog)   fizzbuzz-the-programmers-stairway-to-heaven


 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program FizzBuzz64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
/*******************************************/
/* Initialized data                        */
/*******************************************/
.data
szMessFizz:        .asciz "Fizz\n"
szMessBuzz:        .asciz "Buzz\n"
szMessFizzBuzz:    .asciz "FizzBuzz\n"
szMessNumber:      .asciz "Number : @ "
szCarriageReturn:  .asciz "\n"
 
/*******************************************/
/* UnInitialized data                      */
/*******************************************/
.bss 
sZoneConv:         .skip 24
/*******************************************/
/*  code section                           */
/*******************************************/
.text
.global main 
main:                           // entry of program 
    mov x10,3                   // divisor 3
    mov x11,5                   // divisor 5
    mov x12,15                  // divisor 15
    mov x13,1                   // indice
1:                              // loop begin
    udiv x14,x13,x12            // multiple 15
    msub x15,x14,x12,x13        // remainder
    cbnz x15,2f                 // zero ?
    mov x0,x13
    ldr x1,qAdrszMessFizzBuzz
    bl displayResult
    b 4f
2:                              // multiple 3
    udiv x14,x13,x10
    msub x15,x14,x10,x13        // remainder
    cbnz x15,3f                 // zero ?
    mov x0,x13
    ldr x1,qAdrszMessFizz
    bl displayResult
    b 4f
3:                               // multiple 5
    udiv x14,x13,x11
    msub x15,x14,x11,x13         // remainder 
    cbnz x15,4f                  // zero ?
    mov x0,x13
    ldr x1,qAdrszMessBuzz
    bl displayResult
4:
    add x13,x13,1                // increment indice 
    cmp x13,100                  // maxi ?
    ble 1b
 
100:                            // standard end of the program 
    mov x8,EXIT                 // request to exit program
    svc 0                       // perform the system call
qAdrszMessFizzBuzz:        .quad szMessFizzBuzz
qAdrszMessFizz:            .quad szMessFizz
qAdrszMessBuzz:            .quad szMessBuzz
/******************************************************************/
/*     Display résult                                            */ 
/******************************************************************/
/* x0 contains the number*/
/* x1 contains display string address    */
displayResult:
    stp x2,lr,[sp,-16]!            // save  registers
    mov x2,x1
    ldr x1,qAdrsZoneConv           // conversion number
    bl conversion10S               // decimal conversion
    ldr x0,qAdrszMessNumber
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc          // insert result at @ character
    bl affichageMess               // display message final
    mov x0,x2
    bl affichageMess 
 
    ldp x2,lr,[sp],16              // restaur  2 registers
    ret                            // return to address lr x30
qAdrsZoneConv:        .quad sZoneConv
qAdrszMessNumber:     .quad szMessNumber
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc" 
 