A function is a body of code that returns a value.

The value returned may depend on arguments provided to the function.



Task

Write a definition of a function called "multiply" that takes two arguments and returns their product.

(Argument types should be chosen so as not to distract from showing how functions are created and values returned).



Related task

   Function prototype


 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program functMul64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
/***********************/
/* Initialized data */
/***********************/
.data
szRetourLigne: .asciz "\n"
szMessResult:  .asciz "Resultat : @ \n"      // message result
/***********************   
/* No Initialized data */
/***********************/
.bss
sZoneConv:             .skip 24
.text
.global main 
main:
                                // function multiply
    mov x0,8
    mov x1,50
    bl multiply                 // call function
    ldr x1,qAdrsZoneConv
    bl conversion10S            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc       // insert result at @ character
    bl affichageMess            // display message
 
    mov x0,0                    // return code
 
100:                            // end of  program
    mov x8,EXIT                 // request to exit program
    svc 0                       // perform the system call
qAdrsZoneConv:    .quad sZoneConv
qAdrszMessResult: .quad szMessResult
/******************************************************************/
/*   Function multiply              */ 
/******************************************************************/
/* x0 contains value 1 */
/* x1 contains value 2 */
/* x0 return résult   */
multiply:
    mul x0,x1,x0
    ret               // return function
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 