| /* ARM assembly AARCH64 Raspberry PI 3B */ | |
| /* program 100doors64.s */ | |
| /*******************************************/ | |
| /* Constantes file */ | |
| /*******************************************/ | |
| /* for this file see task include a file in language AArch64 assembly*/ | |
| .include "../includeConstantesARM64.inc" | |
| .equ NBDOORS, 100 | |
| /*********************************/ | |
| /* Initialized data */ | |
| /*********************************/ | |
| .data | |
| sMessResult: .asciz "The door @ is open.\n" | |
| /*********************************/ | |
| /* UnInitialized data */ | |
| /*********************************/ | |
| .bss | |
| stTableDoors: .skip 8 * NBDOORS | |
| sZoneConv: .skip 24 | |
| /*********************************/ | |
| /* code section */ | |
| /*********************************/ | |
| .text | |
| .global main | |
| main: // entry of program | |
| // display first line | |
| ldr x3,qAdrstTableDoors // table address | |
| mov x5,1 | |
| 1: | |
| mov x4,x5 | |
| 2: // begin loop | |
| ldr x2,[x3,x4,lsl #3] // read doors index x4 | |
| cmp x2,#0 | |
| cset x2,eq | |
| //moveq x2,#1 // if x2 = 0 1 -> x2 | |
| //movne x2,#0 // if x2 = 1 0 -> x2 | |
| str x2,[x3,x4,lsl #3] // store value of doors | |
| add x4,x4,x5 // increment x4 with x5 value | |
| cmp x4,NBDOORS // number of doors ? | |
| ble 2b // no -> loop | |
| add x5,x5,#1 // increment the increment !! | |
| cmp x5,NBDOORS // number of doors ? | |
| ble 1b // no -> loop | |
| // loop display state doors | |
| mov x4,#0 | |
| 3: | |
| ldr x2,[x3,x4,lsl #3] // read state doors x4 index | |
| cmp x2,#0 | |
| beq 4f | |
| mov x0,x4 // open -> display message | |
| ldr x1,qAdrsZoneConv // display value index | |
| bl conversion10 // call function | |
| ldr x0,qAdrsMessResult | |
| ldr x1,qAdrsZoneConv | |
| bl strInsertAtCharInc // insert result at first @ character | |
| bl affichageMess // display message | |
| 4: | |
| add x4,x4,1 | |
| cmp x4,NBDOORS | |
| ble 3b // loop | |
| 100: // standard end of the program | |
| mov x0,0 // return code | |
| mov x8,EXIT // request to exit program | |
| svc 0 // perform the system call | |
| qAdrstTableDoors: .quad stTableDoors | |
| qAdrsMessResult: .quad sMessResult | |
| qAdrsZoneConv: .quad sZoneConv | |
| /***********************************************/ | |
| /* File Include fonctions */ | |
| /********************************************************/ | |
| /* for this file see task include a file in language AArch64 assembly */ | |
| .include "../includeARM64.inc" |