/* ARM assembly AARCH64 Raspberry PI 3B */ /* program concAreaString.s */ /*******************************************/ /* Constantes file */ /*******************************************/ /* for this file see task include a file in language AArch64 assembly*/ .include "../includeConstantesARM64.inc" .equ NBMAXITEMS, 20 // /*******************************************/ /* Initialized data */ /*******************************************/ .data szMessLenArea: .asciz "The length of area 3 is : @ \n" szCarriageReturn: .asciz "\n" /* areas strings */ szString1: .asciz "Apples" szString2: .asciz "Oranges" szString3: .asciz "Pommes" szString4: .asciz "Raisins" szString5: .asciz "Abricots" /* pointer items area 1*/ tablesPoi1: pt1_1: .quad szString1 pt1_2: .quad szString2 ptVoid_1: .quad 0 /* pointer items area 2*/ tablesPoi2: pt2_1: .quad szString3 pt2_2: .quad szString4 pt2_3: .quad szString5 ptVoid_2: .quad 0 /*******************************************/ /* UnInitialized data */ /*******************************************/ .bss tablesPoi3: .skip 8 * NBMAXITEMS sZoneConv: .skip 30 /*******************************************/ /* code section */ /*******************************************/ .text .global main main: // entry of program // copy area 1 -> area 3 ldr x1,qAdrtablesPoi1 // begin pointer area 1 ldr x3,qAdrtablesPoi3 // begin pointer area 3 mov x0,0 // counter 1: ldr x2,[x1,x0,lsl 3] // read string pointer address item x0 (8 bytes by pointer) cbz x2,2f // is null ? str x2,[x3,x0,lsl 3] // no store pointer in area 3 add x0,x0,1 // increment counter b 1b // and loop 2: // copy area 2 -> area 3 ldr x1,qAdrtablesPoi2 // begin pointer area 2 ldr x3,qAdrtablesPoi3 // begin pointer area 3 mov x4,#0 // counter area 2 3: // x0 contains the first void item in area 3 ldr x2,[x1,x4,lsl #3] // read string pointer address item x0 (8 bytes by pointer) cbz x2,4f // is null ? str x2,[x3,x0,lsl #3] // no store pointer in area 3 add x0,x0,1 // increment counter add x4,x4,1 // increment counter b 3b // and loop 4: // count items number in area 3 ldr x1,qAdrtablesPoi3 // begin pointer table mov x0,#0 // counter 5: // begin loop ldr x2,[x1,x0,lsl #3] // read string pointer address item x0 (8 bytes by pointer) cmp x2,#0 // is null ? cinc x0,x0,ne // no increment counter bne 5b // and loop ldr x1,qAdrsZoneConv // conversion decimal bl conversion10S ldr x0,qAdrszMessLenArea ldr x1,qAdrsZoneConv bl strInsertAtCharInc // insert result at @ character 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 qAdrtablesPoi1: .quad tablesPoi1 qAdrtablesPoi2: .quad tablesPoi2 qAdrtablesPoi3: .quad tablesPoi3 qAdrszMessLenArea: .quad szMessLenArea qAdrsZoneConv: .quad sZoneConv qAdrszCarriageReturn: .quad szCarriageReturn /****************************************************/ /* File Include fonctions */ /********************************************************/ /* for this file see task include a file in language AArch64 assembly */ .include "../includeARM64.inc"