Include a file: Difference between revisions

Content added Content deleted
(Modify task arm assembly)
(Modify task for aarch64 raspberry)
Line 23: Line 23:
.equ WRITE, 64 // call system Linux 64 bits
.equ WRITE, 64 // call system Linux 64 bits
.equ EXIT, 93 // call system Linux 64 bits
.equ EXIT, 93 // call system Linux 64 bits
.equ HEAPSIZE, 100000
.equ CHARPOS, '@' // position character
.equ CHARPOS, '@' // position character


Line 37: Line 38:
'file fonctions include : includeARM64.inc'
'file fonctions include : includeARM64.inc'
/* File include fonctions */
/* File include fonctions */
.data
ptzZoneHeap: .quad zZoneHeap
.bss
.align 8
zZoneHeap: .skip HEAPSIZE
zEndZoneHeap:
.text
/******************************************************************/
/******************************************************************/
/* String display with size compute */
/* String display with size compute */
Line 248: Line 256:
szMessErrDep: .asciz "Number too large: overflow of 64 bits. :\n"
szMessErrDep: .asciz "Number too large: overflow of 64 bits. :\n"
.align 4 // instruction to realign the following routines
.align 4 // instruction to realign the following routines
/***************************************************/
/* reserve heap area */
/***************************************************/
// x0 contains size in byte to reserve */
// x0 returne begin address of area */
reserverPlace: // INFO: reserverPlace
stp x1,lr,[sp,-16]! // save registers
stp x2,x3,[sp,-16]! // save registers
mov x1,x0
tst x1,#0b111 // size multiple of 8 ?
beq 1f // yes
and x1,x1,0xFFFFFFFFFFFFFFF8 // else align to 8 superior
add x1,x1,8
1:
ldr x2,qAdrptzZoneHeap
ldr x0,[x2]
add x1,x1,x0 // size too large ?
ldr x3,qAdrzEndZoneHeap
cmp x1,x3
blt 2f // no it is ok
adr x0,szMessErrTas // yes -> error
bl affichageMess
mov x0,#-1
b 100f
2:
str x1,[x2] // store new pointer
100: // fin standard de la fonction
ldp x2,x3,[sp],16 // restaur 2 registers
ldp x1,lr,[sp],16 // restaur 2 registers
ret // retur address lr x30
qAdrptzZoneHeap: .quad ptzZoneHeap
qAdrzEndZoneHeap: .quad zEndZoneHeap
szMessErrTas: .asciz "Error : heap not large !!!\n"
.align 4
/***************************************************/
/* liberer place sur le tas */
/***************************************************/
// r0 contains begin address area
libererPlace: // INFO: libererPlace
stp x1,lr,[sp,-16]! // save registers
ldr x1,qAdrzZoneHeap
cmp x0,x1
blt 99f
ldr x1,qAdrzEndZoneHeap
cmp x0,x1
bge 99f
ldr x1,qAdrptzZoneHeap
str x0,[x1]
b 100f
99:
adr x0,szMessErrTas1
bl affichageMess
mov x0,-1
100:
ldp x1,lr,[sp],16 // restaur 2 registers
ret // retur address lr x30
qAdrzZoneHeap: .quad zZoneHeap
szMessErrTas1: .asciz "Error : address < or > heap addresses !!!\n"
.align 4

/******************************************************************/
/******************************************************************/
/* insert string at character insertion */
/* insert string at character insertion */
Line 255: Line 323:
/* x0 return the address of new string on the heap */
/* x0 return the address of new string on the heap */
/* or -1 if error */
/* or -1 if error */

strInsertAtCharInc:
strInsertAtCharInc:
stp x2,lr,[sp,-16]! // save registers
stp x2,lr,[sp,-16]! // save registers
Line 278: Line 345:
add x3,x3,#1 // +1 for final zero
add x3,x3,#1 // +1 for final zero
mov x6,x0 // save address string 1
mov x6,x0 // save address string 1
mov x0,x3
mov x0,#0 // allocation place heap
bl reserverPlace
mov x8,BRK // call system 'brk'
svc #0
mov x5,x0 // save address heap for output string
add x0,x0,x3 // reservation place x3 length
mov x8,BRK // call system 'brk'
svc #0
cmp x0,#-1 // allocation error
cmp x0,#-1 // allocation error
beq 99f
beq 99f
mov x5,x0 // save address heap for output string
mov x2,0
mov x2,0
mov x4,0
mov x4,0