139 lines
4.5 KiB
Plaintext
139 lines
4.5 KiB
Plaintext
/* ARM assembly AARCH64 Raspberry PI 3B */
|
|
/* program crehtml64.s */
|
|
|
|
/*******************************************/
|
|
/* Constantes */
|
|
/*******************************************/
|
|
/* for this file see task include a file in language AArch64 assembly*/
|
|
.include "../includeConstantesARM64.inc"
|
|
|
|
.equ MAXILINE, 5
|
|
.equ MAXIRANDOMNUMBER, 3
|
|
|
|
/*********************************/
|
|
/* Initialized data */
|
|
/*********************************/
|
|
.data
|
|
szMessDebutPgm: .asciz "Program 64 bits start. \n"
|
|
szRetourLigne: .asciz "\n"
|
|
szMessFinOK: .asciz "Program normal end. \n"
|
|
szMessErreur: .asciz "Error !!!\n"
|
|
|
|
szarrayheader: .asciz "<html><table> \n"
|
|
szarrayend: .asciz "</table></html>\n"
|
|
szLine1: .asciz "<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>\n"
|
|
szDebLine: .asciz "<TR><TD align=\042right\042>"
|
|
szEndLine: .asciz "</TD></TR>\n"
|
|
szEndCol: .asciz "</TD><TD align=\042right\042>"
|
|
.align 4
|
|
qGraine: .quad 1234567 // seed for number random
|
|
/*********************************/
|
|
/* UnInitialized data */
|
|
/*********************************/
|
|
.bss
|
|
sZoneConv: .skip 24
|
|
.align 4
|
|
|
|
/*********************************/
|
|
/* code section */
|
|
/*********************************/
|
|
.text
|
|
.global main
|
|
main:
|
|
ldr x0,qAdrszMessDebutPgm
|
|
bl affichageMess // start message
|
|
ldr x0,qAdrszarrayheader
|
|
bl affichageMess
|
|
ldr x0,qAdrszLine1
|
|
bl affichageMess
|
|
mov x4,#1 // line counter
|
|
1: // begin line loop
|
|
ldr x0,qAdrszDebLine
|
|
bl affichageMess
|
|
mov x0,x4 // convert line to décimal
|
|
ldr x1,qAdrsZoneConv
|
|
bl conversion10
|
|
mov x2,#0 // add final zero
|
|
strb w2,[x1,x0]
|
|
ldr x0,qAdrsZoneConv // and display N° line
|
|
bl affichageMess
|
|
ldr x0,qAdrszEndCol
|
|
bl affichageMess
|
|
mov x5,#0 // random number counter
|
|
2:
|
|
mov x0,#10000 // limit random number
|
|
bl genereraleas // call random
|
|
ldr x1,qAdrsZoneConv // conversion to décimal
|
|
bl conversion10
|
|
mov x2,#0 // add final zero
|
|
strb w2,[x1,x0]
|
|
ldr x0,qAdrsZoneConv // and display random number
|
|
bl affichageMess
|
|
ldr x0,qAdrszEndCol
|
|
bl affichageMess
|
|
add x5,x5,#1 // increment counter
|
|
cmp x5,#MAXIRANDOMNUMBER // and loop
|
|
blt 2b
|
|
ldr x0,qAdrszEndLine
|
|
bl affichageMess
|
|
add x4,x4,#1 // increment line counter
|
|
cmp x4,#MAXILINE // and loop
|
|
blt 1b
|
|
ldr x0,qAdrszarrayend
|
|
bl affichageMess
|
|
|
|
ldr x0,qAdrszMessFinOK
|
|
bl affichageMess
|
|
b 100f
|
|
99:
|
|
ldr x0,qAdrszMessErreur // error
|
|
bl affichageMess
|
|
mov x0, #1 // return code error
|
|
b 100f
|
|
100:
|
|
mov x8,EXIT
|
|
svc #0 // system call
|
|
qAdrszMessDebutPgm: .quad szMessDebutPgm
|
|
qAdrszMessFinOK: .quad szMessFinOK
|
|
qAdrszMessErreur: .quad szMessErreur
|
|
qAdrsZoneConv: .quad sZoneConv
|
|
qAdrszarrayheader: .quad szarrayheader
|
|
qAdrszLine1: .quad szLine1
|
|
qAdrszDebLine: .quad szDebLine
|
|
qAdrszEndCol: .quad szEndCol
|
|
qAdrszEndLine: .quad szEndLine
|
|
qAdrszarrayend: .quad szarrayend
|
|
|
|
/***************************************************/
|
|
/* Generation random number */
|
|
/***************************************************/
|
|
/* x0 contains limit */
|
|
genereraleas:
|
|
stp x1,lr,[sp,-16]! // save registers
|
|
stp x2,x3,[sp,-16]! // save registers
|
|
ldr x1,qAdrqGraine
|
|
ldr x2,[x1]
|
|
ldr x3,qNbDep1
|
|
mul x2,x3,x2
|
|
ldr x3,qNbDep2
|
|
add x2,x2,x3
|
|
str x2,[x1] // maj de la graine pour l appel suivant
|
|
cmp x0,#0
|
|
beq 100f
|
|
udiv x3,x2,x0
|
|
msub x0,x3,x0,x2 // résult = remainder
|
|
|
|
100: // end function
|
|
ldp x2,x3,[sp],16 // restaur 2 registers
|
|
ldp x1,lr,[sp],16 // restaur 2 registers
|
|
ret // return to address lr x30
|
|
qAdrqGraine: .quad qGraine
|
|
qNbDep1: .quad 0x0019660d
|
|
qNbDep2: .quad 0x3c6ef35f
|
|
|
|
/***************************************************/
|
|
/* ROUTINES INCLUDE */
|
|
/***************************************************/
|
|
/* for this file see task include a file in language AArch64 assembly*/
|
|
.include "../includeARM64.inc"
|