Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,124 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program insertList64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes file */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
.equ NBELEMENTS, 100 // list size
|
||||
|
||||
/*******************************************/
|
||||
/* Structures */
|
||||
/********************************************/
|
||||
/* structure linkedlist*/
|
||||
.struct 0
|
||||
llist_next: // next element
|
||||
.struct llist_next + 8
|
||||
llist_value: // element value
|
||||
.struct llist_value + 8
|
||||
llist_fin:
|
||||
/*******************************************/
|
||||
/* Initialized data */
|
||||
/*******************************************/
|
||||
.data
|
||||
szMessInitListe: .asciz "List initialized.\n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
/* datas error display */
|
||||
szMessErreur: .asciz "Error detected.\n"
|
||||
/* datas message display */
|
||||
szMessResult: .asciz "Element No : @ value : @ \n"
|
||||
sZoneConv: .skip 100
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
lList1: .skip llist_fin * NBELEMENTS // list memory place
|
||||
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr x0,qAdrlList1
|
||||
mov x1,#0 // list init
|
||||
str x1,[x0,#llist_next]
|
||||
ldr x0,qAdrszMessInitListe
|
||||
bl affichageMess
|
||||
ldr x0,qAdrlList1
|
||||
mov x1,#2
|
||||
bl insertElement // add element value 2
|
||||
ldr x0,qAdrlList1
|
||||
mov x1,#5
|
||||
bl insertElement // add element value 5
|
||||
//
|
||||
ldr x3,qAdrlList1
|
||||
mov x2,#0 // ident element
|
||||
1:
|
||||
ldr x0,[x3,#llist_next] // end list ?
|
||||
cmp x0,#0
|
||||
beq 100f // yes
|
||||
add x2,x2,#1
|
||||
mov x0,x2 // display No element and value
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl conversion10S
|
||||
ldr x0,qAdrszMessResult
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl strInsertAtCharInc
|
||||
mov x5,x0 // address of new string
|
||||
ldr x0,[x3,#llist_value]
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl conversion10S
|
||||
mov x0,x5 // new address of message
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl strInsertAtCharInc
|
||||
bl affichageMess
|
||||
ldr x3,[x3,#llist_next] // next element
|
||||
b 1b // and loop
|
||||
|
||||
100: // standard end of the program
|
||||
mov x8, #EXIT // request to exit program
|
||||
svc 0 // perform system call
|
||||
qAdrszMessInitListe: .quad szMessInitListe
|
||||
qAdrszMessErreur: .quad szMessErreur
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
qAdrlList1: .quad lList1
|
||||
qAdrszMessResult: .quad szMessResult
|
||||
qAdrsZoneConv: .quad sZoneConv
|
||||
|
||||
/******************************************************************/
|
||||
/* insert element at end of list */
|
||||
/******************************************************************/
|
||||
/* x0 contains the address of the list */
|
||||
/* x1 contains the value of element */
|
||||
/* x0 returns address of element or - 1 if error */
|
||||
insertElement:
|
||||
stp x1,lr,[sp,-16]! // save registers
|
||||
stp x2,x3,[sp,-16]! // save registers
|
||||
mov x2,#llist_fin * NBELEMENTS
|
||||
add x2,x2,x0 // compute address end list
|
||||
1: // start loop
|
||||
ldr x3,[x0,#llist_next] // load next pointer
|
||||
cmp x3,#0 // = zero
|
||||
csel x0,x3,x0,ne
|
||||
bne 1b // no -> loop with pointer
|
||||
add x3,x0,#llist_fin // yes -> compute next free address
|
||||
cmp x3,x2 // > list end
|
||||
bge 99f // yes -> error
|
||||
str x3,[x0,#llist_next] // store next address in current pointer
|
||||
str x1,[x0,#llist_value] // store element value
|
||||
mov x1,#0
|
||||
str x1,[x3,#llist_next] // init next pointer in next address
|
||||
b 100f
|
||||
99: // error
|
||||
mov x0,-1
|
||||
100:
|
||||
ldp x2,x3,[sp],16 // restaur 2 registers
|
||||
ldp x1,lr,[sp],16 // restaur 2 registers
|
||||
ret // return to address lr x30
|
||||
/********************************************************/
|
||||
/* File Include fonctions */
|
||||
/********************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly */
|
||||
.include "../includeARM64.inc"
|
||||
Loading…
Add table
Add a link
Reference in a new issue