File size: 2,946 Bytes
497f2f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* 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"