
Basic Data Operation

This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:


Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses


Task

Get two integers from the user,   and then (for those two integers), display their:

   sum 
   difference 
   product 
   integer quotient
   remainder 
   exponentiation   (if the operator exists) 


Don't include error handling.

For quotient, indicate how it rounds   (e.g. towards zero, towards negative infinity, etc.).

For remainder, indicate whether its sign matches the sign of the first operand or of the second operand, if they are different.




 
/* ARM assembly AARCH64 Raspberry PI 3B */
/*  program arith64.s   */
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc" 
 
/***********************/
/* Initialized data */
/***********************/
.data
szMessError:          .asciz " Two numbers in command line please ! \n"       // message
szRetourLigne:        .asciz "\n"
szMessResult:         .asciz "resultat : @ \n"      // message result
sMessValeur:          .fill 12, 1, ' '
                      .asciz "\n"
szMessAddition:       .asciz "Addition "
szMessSoustraction:   .asciz "soustraction :"
szMessMultiplication: .asciz "multiplication :"
szMessDivision:       .asciz "division :"
szMessReste:          .asciz "remainder :"
 
/***********************/
/* No Initialized data */
/***********************/
.bss
qValeur:            .skip  8        // reserve 8 bytes in memory
sZoneConv:          .skip 30  
.text
.global main 
main:
    mov fp,sp                   // fp <- stack address
    ldr x0,[fp]                 // recup number of parameter in command line
    cmp x0,3
    blt error
    ldr x0,[fp,16]              // adresse of 1er number
    bl conversionAtoD
    mov x3,x0
    ldr x0,[fp,24]              // adresse of 2eme number
    bl conversionAtoD
    mov x4,x0
                                // addition
    add x0,x3,x4
    ldr x1,qAdrsZoneConv        // result in x0
    bl conversion10S            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessAddition
    bl affichageMess            // display message
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc       // insert result at @ character
    bl affichageMess            // display message
    ldr x0,qAdrsZoneConv
                                // soustraction
    sub x0,x3,x4
    ldr x1,qAdrsZoneConv        // result in x0
    bl conversion10S            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessSoustraction
    bl affichageMess            // display message
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc       // insert result at @ character
    bl affichageMess            // display message
    ldr x0,qAdrsZoneConv
                                // multiplication
    mul x0,x3,x4
    ldr x1,qAdrsZoneConv        // result in x0
    bl conversion10S            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessMultiplication
    bl affichageMess            // display message
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc       // insert result at @ character
    bl affichageMess            // display message
    ldr x0,qAdrsZoneConv
                                // division 
    mov x0,x3
    mov x1,x4
    udiv x0,x3,x4               // quotient
    msub x3,x0,x4,x3            // remainder x3 = x3 - (x0*x4)
    ldr x1,qAdrsZoneConv        // result in x0
    bl conversion10S            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessDivision
    bl affichageMess            // display message
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc       // insert result at @ character
    bl affichageMess            // display message
    ldr x0,qAdrsZoneConv
 
    mov x0,x3                   // remainder
    ldr x1,qAdrsZoneConv        // result in x0
    bl conversion10S            // call function with 2 parameter (x0,x1)
    ldr x0,qAdrszMessReste
    bl affichageMess            // display message
    ldr x0,qAdrszMessResult
    ldr x1,qAdrsZoneConv
    bl strInsertAtCharInc       // insert result at @ character
    bl affichageMess            // display message
    ldr x0,qAdrsZoneConv
 
    mov x0,0                    // return code
    b 100f
error:
    ldr x0,qAdrszMessError
    bl affichageMess            // call function with 1 parameter (x0)
    mov x0,1                    // return code
100:                            // end of  program
    mov x8,EXIT                 // request to exit program
    svc 0                       // perform the system call
qAdrsMessValeur:          .quad sMessValeur    
qAdrszMessResult:         .quad szMessResult
qAdrszMessError:          .quad szMessError
qAdrszMessAddition:       .quad szMessAddition
qAdrszMessSoustraction:   .quad szMessSoustraction
qAdrszMessMultiplication: .quad szMessMultiplication
qAdrszMessDivision:       .quad szMessDivision
qAdrszMessReste:          .quad szMessReste
qAdrsZoneConv:            .quad sZoneConv
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 