Data update
This commit is contained in:
parent
07c7092a52
commit
61b93a2cd1
313 changed files with 6160 additions and 346 deletions
195
Task/Best-shuffle/AArch64-Assembly/best-shuffle.aarch64
Normal file
195
Task/Best-shuffle/AArch64-Assembly/best-shuffle.aarch64
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program shuffleperf64.s */
|
||||
/************************************/
|
||||
/* Constantes */
|
||||
/************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
|
||||
/************************************/
|
||||
/* Initialized data */
|
||||
/************************************/
|
||||
.data
|
||||
szMessString: .asciz "String :\n"
|
||||
szString1: .asciz "abracadabra"
|
||||
.equ LGSTRING1, . - szString1 - 1
|
||||
szString2: .asciz "seesaw"
|
||||
.equ LGSTRING2, . - szString2 - 1
|
||||
szString3: .asciz "elk"
|
||||
.equ LGSTRING3, . - szString3 - 1
|
||||
szString4: .asciz "grrrrrr"
|
||||
.equ LGSTRING4, . - szString4 - 1
|
||||
szString5: .asciz "up"
|
||||
.equ LGSTRING5, . - szString5 - 1
|
||||
szString6: .asciz "a"
|
||||
.equ LGSTRING6, . - szString6 - 1
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessStart: .asciz "Program 64 bits start.\n"
|
||||
.align 4
|
||||
qGraine: .quad 123456789
|
||||
/************************************/
|
||||
/* UnInitialized data */
|
||||
/************************************/
|
||||
.bss
|
||||
sZoneConv: .skip 24
|
||||
sBuffer: .skip 80
|
||||
/************************************/
|
||||
/* code section */
|
||||
/************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr x0,qAdrszMessStart
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszString1 // string address
|
||||
mov x1,#LGSTRING1 // string length
|
||||
ldr x2,qAdrsBuffer // result address
|
||||
bl testshuffle // call test
|
||||
ldr x0,qAdrszString2
|
||||
mov x1,#LGSTRING2
|
||||
ldr x2,qAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr x0,qAdrszString3
|
||||
mov x1,#LGSTRING3
|
||||
ldr x2,qAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr x0,qAdrszString4
|
||||
mov x1,#LGSTRING4
|
||||
ldr x2,qAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr x0,qAdrszString5
|
||||
mov x1,#LGSTRING5
|
||||
ldr x2,qAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr x0,qAdrszString6
|
||||
mov x1,#LGSTRING6
|
||||
ldr x2,qAdrsBuffer
|
||||
bl testshuffle
|
||||
100: // standard end of the program
|
||||
mov x0, #0 // return code
|
||||
mov x8, #EXIT // request to exit program
|
||||
svc 0 // perform system call
|
||||
qAdrszMessString: .quad szMessString
|
||||
qAdrsBuffer: .quad sBuffer
|
||||
qAdrszString1: .quad szString1
|
||||
qAdrszString2: .quad szString2
|
||||
qAdrszString3: .quad szString3
|
||||
qAdrszString4: .quad szString4
|
||||
qAdrszString5: .quad szString5
|
||||
qAdrszString6: .quad szString6
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
qAdrszMessStart: .quad szMessStart
|
||||
/******************************************************************/
|
||||
/* test shuffle strings */
|
||||
/******************************************************************/
|
||||
/* x0 contains the address of the string */
|
||||
/* x1 contains string length */
|
||||
/* x2 contains result area */
|
||||
testshuffle:
|
||||
stp x1,lr,[sp,-16]! // register save
|
||||
stp x2,x3,[sp,-16]!
|
||||
stp x4,x5,[sp,-16]!
|
||||
stp x6,x7,[sp,-16]!
|
||||
mov x3,x0 // display string
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
mov x0,x3
|
||||
bl shufflestrings
|
||||
mov x0,x2 // display result string
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
mov x4,#0 // string index
|
||||
mov x0,#0 // score
|
||||
1: // compute score loop
|
||||
ldrb w6,[x3,x4]
|
||||
ldrb w5,[x2,x4]
|
||||
cmp x6,x5
|
||||
add x6,x0,1
|
||||
csel x0,x6,x0,eq // equal -> increment score
|
||||
add x4,x4,#1
|
||||
cmp x4,x1
|
||||
blt 1b
|
||||
ldr x1,qAdrsZoneConv
|
||||
bl conversion10 // conversion score in decimal
|
||||
ldr x0,qAdrsZoneConv
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
100:
|
||||
ldp x6,x7,[sp],16
|
||||
ldp x4,x5,[sp],16
|
||||
ldp x2,x3,[sp],16
|
||||
ldp x1,lr,[sp],16
|
||||
ret
|
||||
qAdrsZoneConv: .quad sZoneConv
|
||||
/******************************************************************/
|
||||
/* shuffle strings algorithme Fisher-Yates */
|
||||
/******************************************************************/
|
||||
/* x0 contains the address of the string */
|
||||
/* x1 contains string length */
|
||||
/* x2 contains address result string */
|
||||
shufflestrings:
|
||||
stp x1,lr,[sp,-16]! // TODO: save à completer
|
||||
stp x2,x3,[sp,-16]!
|
||||
stp x4,x5,[sp,-16]!
|
||||
mov x3,#0
|
||||
1: // loop copy string in result
|
||||
ldrb w4,[x0,x3]
|
||||
strb w4,[x2,x3]
|
||||
add x3,x3,#1
|
||||
cmp x3,x1
|
||||
ble 1b
|
||||
sub x1,x1,#1 // last element
|
||||
2:
|
||||
mov x0,x1
|
||||
bl genereraleas // call random
|
||||
ldrb w4,[x2,x1] // load byte string index loop
|
||||
ldrb w3,[x2,x0] // load byte string random index
|
||||
strb w3,[x2,x1] // and exchange
|
||||
strb w4,[x2,x0]
|
||||
subs x1,x1,#1
|
||||
cmp x1,#1
|
||||
bge 2b
|
||||
|
||||
100:
|
||||
ldp x4,x5,[sp],16
|
||||
ldp x2,x3,[sp],16
|
||||
ldp x1,lr,[sp],16
|
||||
ret
|
||||
|
||||
/***************************************************/
|
||||
/* 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"
|
||||
176
Task/Best-shuffle/ARM-Assembly/best-shuffle.arm
Normal file
176
Task/Best-shuffle/ARM-Assembly/best-shuffle.arm
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program shuffleperf.s */
|
||||
/************************************/
|
||||
/* Constantes */
|
||||
/************************************/
|
||||
/* for this file see task include a file in language ARM assembly*/
|
||||
.include "../constantes.inc"
|
||||
|
||||
/************************************/
|
||||
/* Initialized data */
|
||||
/************************************/
|
||||
.data
|
||||
szMessString: .asciz "String :\n"
|
||||
szString1: .asciz "abracadabra"
|
||||
.equ LGSTRING1, . - szString1 - 1
|
||||
szString2: .asciz "seesaw"
|
||||
.equ LGSTRING2, . - szString2 - 1
|
||||
szString3: .asciz "elk"
|
||||
.equ LGSTRING3, . - szString3 - 1
|
||||
szString4: .asciz "grrrrrr"
|
||||
.equ LGSTRING4, . - szString4 - 1
|
||||
szString5: .asciz "up"
|
||||
.equ LGSTRING5, . - szString5 - 1
|
||||
szString6: .asciz "a"
|
||||
.equ LGSTRING6, . - szString6 - 1
|
||||
szCarriageReturn: .asciz "\n"
|
||||
.align 4
|
||||
iGraine: .int 1234567
|
||||
/************************************/
|
||||
/* UnInitialized data */
|
||||
/************************************/
|
||||
.bss
|
||||
sZoneConv: .skip 24
|
||||
sBuffer: .skip 80
|
||||
/************************************/
|
||||
/* code section */
|
||||
/************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr r0,iAdrszString1 @ string address
|
||||
mov r1,#LGSTRING1 @ string length
|
||||
ldr r2,iAdrsBuffer @ result address
|
||||
bl testshuffle @ call test
|
||||
ldr r0,iAdrszString2
|
||||
mov r1,#LGSTRING2
|
||||
ldr r2,iAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr r0,iAdrszString3
|
||||
mov r1,#LGSTRING3
|
||||
ldr r2,iAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr r0,iAdrszString4
|
||||
mov r1,#LGSTRING4
|
||||
ldr r2,iAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr r0,iAdrszString5
|
||||
mov r1,#LGSTRING5
|
||||
ldr r2,iAdrsBuffer
|
||||
bl testshuffle
|
||||
ldr r0,iAdrszString6
|
||||
mov r1,#LGSTRING6
|
||||
ldr r2,iAdrsBuffer
|
||||
bl testshuffle
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc 0 @ perform system call
|
||||
iAdrszMessString: .int szMessString
|
||||
iAdrsBuffer: .int sBuffer
|
||||
iAdrszString1: .int szString1
|
||||
iAdrszString2: .int szString2
|
||||
iAdrszString3: .int szString3
|
||||
iAdrszString4: .int szString4
|
||||
iAdrszString5: .int szString5
|
||||
iAdrszString6: .int szString6
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
/******************************************************************/
|
||||
/* test shuffle strings */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the string */
|
||||
/* r1 contains string length */
|
||||
/* r2 contains result area */
|
||||
testshuffle:
|
||||
push {r1-r6,lr} @ save registers
|
||||
mov r3,r0 @ display string
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
mov r0,r3
|
||||
bl shufflestrings
|
||||
mov r0,r2 @ display result string
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
mov r4,#0 @ string index
|
||||
mov r0,#0 @ score
|
||||
1: @ compute score loop
|
||||
ldrb r6,[r3,r4]
|
||||
ldrb r5,[r2,r4]
|
||||
cmp r6,r5
|
||||
addeq r0,r0,#1 @ equal -> increment score
|
||||
add r4,r4,#1
|
||||
cmp r4,r1
|
||||
blt 1b
|
||||
ldr r1,iAdrsZoneConv
|
||||
bl conversion10 @ conversion score in decimal
|
||||
ldr r0,iAdrsZoneConv
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
100:
|
||||
pop {r1-r6,pc} @ restaur registers
|
||||
iAdrsZoneConv: .int sZoneConv
|
||||
/******************************************************************/
|
||||
/* shuffle strings algorithme Fisher-Yates */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the string */
|
||||
/* r1 contains string length */
|
||||
/* r2 contains address result string */
|
||||
shufflestrings:
|
||||
push {r1-r4,lr} @ save registers
|
||||
mov r3,#0
|
||||
1: @ loop copy string in result
|
||||
ldrb r4,[r0,r3]
|
||||
strb r4,[r2,r3]
|
||||
add r3,r3,#1
|
||||
cmp r3,r1
|
||||
ble 1b
|
||||
sub r1,r1,#1 @ last element
|
||||
2:
|
||||
mov r0,r1 @ limit random number
|
||||
bl genereraleas @ call random
|
||||
ldrb r4,[r2,r1] @ load byte string index loop
|
||||
ldrb r3,[r2,r0] @ load byte string random index
|
||||
strb r3,[r2,r1] @ and exchange
|
||||
strb r4,[r2,r0]
|
||||
subs r1,r1,#1
|
||||
cmp r1,#1
|
||||
bge 2b
|
||||
|
||||
100:
|
||||
pop {r1-r4,pc} @ restaur registers
|
||||
|
||||
/***************************************************/
|
||||
/* Generation random number */
|
||||
/***************************************************/
|
||||
/* r0 contains limit */
|
||||
genereraleas:
|
||||
push {r1-r4,lr} @ save registers
|
||||
ldr r4,iAdriGraine
|
||||
ldr r2,[r4]
|
||||
ldr r3,iNbDep1
|
||||
mul r2,r3,r2
|
||||
ldr r3,iNbDep1
|
||||
add r2,r2,r3
|
||||
str r2,[r4] @ maj de la graine pour l appel suivant
|
||||
cmp r0,#0
|
||||
beq 100f
|
||||
mov r1,r0 @ divisor
|
||||
mov r0,r2 @ dividende
|
||||
bl division
|
||||
mov r0,r3 @ résult = remainder
|
||||
|
||||
100: @ end function
|
||||
pop {r1-r4,pc} @ restaur registers
|
||||
iAdriGraine: .int iGraine
|
||||
iNbDep1: .int 0x343FD
|
||||
iNbDep2: .int 0x269EC3
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
/* for this file see task include a file in language ARM assembly*/
|
||||
.include "../affichage.inc"
|
||||
Loading…
Add table
Add a link
Reference in a new issue