Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
223
Task/Vigen-re-cipher/AArch64-Assembly/vigen-re-cipher.aarch64
Normal file
223
Task/Vigen-re-cipher/AArch64-Assembly/vigen-re-cipher.aarch64
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program vignere64.s */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
|
||||
.equ BUFFERSIZE, 2000
|
||||
/*******************************************/
|
||||
/* Macros */
|
||||
/*******************************************/
|
||||
//.include "../../ficmacros64.inc" // for developer debugging
|
||||
|
||||
|
||||
/*******************************************/
|
||||
/* Initialized data */
|
||||
/*******************************************/
|
||||
.data
|
||||
szMessDebutPgm: .asciz "Program 64 bits start. \n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessFinOK: .asciz "Program normal end. \n"
|
||||
szMessError: .asciz "\nError Buffer too small!!!\n"
|
||||
szMessString: .asciz "String :\n"
|
||||
szMessEncrip: .asciz "\nEncrypted :\n"
|
||||
szMessDecrip: .asciz "\nDecrypted :\n"
|
||||
szString1: .asciz "ABCDEFGHIJKLMNOPQRSTUVWXYZ!.?abcdefghijklmnopqrstuvwxyz"
|
||||
//szString1: .asciz "attackatdawn"
|
||||
//szString1: .asciz "ATTACKATDAWN"
|
||||
szKey1: .asciz "LEMON"
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
sBuffex1: .skip BUFFERSIZE
|
||||
sBuffex2: .skip BUFFERSIZE
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr x0,qAdrszMessDebutPgm
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszMessString // display message
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszString1 // display string
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszString1 // string address
|
||||
ldr x1,qAdrszKey1 // key
|
||||
ldr x2,qAdrsBuffex1 // encrypted buffer
|
||||
bl encrypt
|
||||
cmp x0,#0
|
||||
ble 99f
|
||||
ldr x0,qAdrszMessEncrip
|
||||
bl affichageMess
|
||||
ldr x0,qAdrsBuffex1 // display encrypted buffer
|
||||
bl affichageMess
|
||||
|
||||
ldr x0,qAdrsBuffex1 // encrypted buffer
|
||||
ldr x1,qAdrszKey1 // key
|
||||
ldr x2,qAdrsBuffex2 // decrypted buffer
|
||||
bl decrypt
|
||||
ldr x0,qAdrszMessDecrip
|
||||
bl affichageMess
|
||||
ldr x0,qAdrsBuffex2 // display decrypted buffer
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
ldr x0,qAdrszMessFinOK
|
||||
bl affichageMess
|
||||
b 100f
|
||||
99:
|
||||
ldr x0,qAdrszMessError // error
|
||||
bl affichageMess
|
||||
mov x0, #1
|
||||
100: // standard end of the program
|
||||
mov x0, #0 // return code
|
||||
mov x8,EXIT
|
||||
svc 0 // perform system call
|
||||
qAdrszMessString: .quad szMessString
|
||||
qAdrszMessDecrip: .quad szMessDecrip
|
||||
qAdrszMessEncrip: .quad szMessEncrip
|
||||
qAdrszString1: .quad szString1
|
||||
qAdrsBuffex1: .quad sBuffex1
|
||||
qAdrsBuffex2: .quad sBuffex2
|
||||
qAdrszKey1: .quad szKey1
|
||||
qAdrszMessDebutPgm: .quad szMessDebutPgm
|
||||
qAdrszMessFinOK: .quad szMessFinOK
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
qAdrszMessError: .quad szMessError
|
||||
/******************************************************************/
|
||||
/* encrypt strings */
|
||||
/******************************************************************/
|
||||
/* x0 contains the address of the string1 */
|
||||
/* x1 contains key address
|
||||
/* x2 contains the address of the encrypted string */
|
||||
/* x0 return buffer lenght */
|
||||
encrypt:
|
||||
stp x3,lr,[sp,-16]! // save registers
|
||||
stp x4,x5,[sp,-16]! // save registers
|
||||
stp x6,x7,[sp,-16]! // save registers
|
||||
stp x8,x9,[sp,-16]! // save registers
|
||||
mov x3,#0 // counter byte string 1
|
||||
mov x5,#0 // counter byte buffer
|
||||
1:
|
||||
mov x4,#0 // counter byte key
|
||||
2:
|
||||
cmp x5,#BUFFERSIZE // max length buffer ?
|
||||
bge 99f
|
||||
ldrb w6,[x1,x4] // load a byte
|
||||
cmp x6,#0 // end key ?
|
||||
beq 1b
|
||||
sub x6,x6,#'A' // character rang in alfabet
|
||||
add x4,x4,#1
|
||||
3:
|
||||
ldrb w7,[x0,x3] // load byte string 1
|
||||
cmp w7,#0 // zero final ?
|
||||
bne 4f
|
||||
strb w7,[x2,x5]
|
||||
mov x0,x5
|
||||
b 100f
|
||||
4:
|
||||
cmp x7,#65 // < A ?
|
||||
cinc x3,x3,lt
|
||||
blt 3b
|
||||
cmp x7,#90 // > Z
|
||||
bgt 5f
|
||||
add x7,x7,x6 // add key
|
||||
sub x8,x7,26
|
||||
cmp x7,#90 // > Z
|
||||
csel x7,x8,x7,gt
|
||||
strb w7,[x2,x5] // store result
|
||||
add x5,x5,#1
|
||||
add x3,x3,#1 // other byte of string
|
||||
b 2b // other byte of key
|
||||
5:
|
||||
cmp x7,#97 // < a ?
|
||||
cinc x3,x3,lt
|
||||
blt 3b
|
||||
cmp x7,#122 //> z
|
||||
cinc x3,x3,gt
|
||||
bgt 3b
|
||||
sub x7,x7,#32 // convert minuscul to majuscule
|
||||
add x7,x7,x6 // add key
|
||||
cmp x7,#90 // if > Z
|
||||
ble 6f
|
||||
sub x7,x7,#26 // - alphaget size
|
||||
6:
|
||||
strb w7,[x2,x5] // store result
|
||||
add x5,x5,#1
|
||||
add x3,x3,#1
|
||||
b 2b
|
||||
|
||||
99:
|
||||
mov x0,#-1 // error
|
||||
|
||||
100:
|
||||
ldp x8,x9,[sp],16 // restaur registers
|
||||
ldp x6,x7,[sp],16 // restaur registers
|
||||
ldp x4,x5,[sp],16 // restaur registers
|
||||
ldp x3,lr,[sp],16 // restaur registers
|
||||
ret
|
||||
/******************************************************************/
|
||||
/* decrypt strings */
|
||||
/******************************************************************/
|
||||
/* x0 contains the address of the encrypted string1 */
|
||||
/* x1 contains the key */
|
||||
/* x2 contains the address of the decrypted buffer */
|
||||
decrypt:
|
||||
stp x3,lr,[sp,-16]! // save registers
|
||||
stp x4,x5,[sp,-16]! // save registers
|
||||
stp x6,x7,[sp,-16]! // save registers
|
||||
stp x8,x9,[sp,-16]! // save registers
|
||||
mov x3,#0 // counter byte string 1
|
||||
mov x5,#0 // counter byte buffer
|
||||
|
||||
1:
|
||||
mov x4,#0 // counter byte key
|
||||
2:
|
||||
ldrb w6,[x1,x4] // load byte key
|
||||
cmp w6,#0 // end key
|
||||
beq 1b
|
||||
sub x6,x6,#'A'
|
||||
add x4,x4,#1
|
||||
3:
|
||||
ldrb w7,[x0,x3] // load byte string 1
|
||||
cmp x7,#0 // zero final ?
|
||||
bne 4f
|
||||
strb w7,[x2,x5]
|
||||
mov x0,x5
|
||||
b 100f
|
||||
4:
|
||||
cmp x7,#65 // < A ?
|
||||
cinc x3,x3,lt
|
||||
blt 3b
|
||||
cmp x7,#90 // > Z
|
||||
cinc x3,x3,gt // no minuscul
|
||||
bgt 3b
|
||||
sub x7,x7,x6 // add key
|
||||
add x8,x7,26
|
||||
cmp x7,#65 // < A
|
||||
csel x7,x8,x7,lt
|
||||
strb w7,[x2,x5]
|
||||
add x5,x5,#1
|
||||
add x3,x3,#1 // other byte of string
|
||||
b 2b // other byte of key
|
||||
|
||||
|
||||
100:
|
||||
ldp x8,x9,[sp],16 // restaur registers
|
||||
ldp x6,x7,[sp],16 // restaur registers
|
||||
ldp x4,x5,[sp],16 // restaur registers
|
||||
ldp x3,lr,[sp],16 // restaur registers
|
||||
ret
|
||||
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeARM64.inc"
|
||||
203
Task/Vigen-re-cipher/ARM-Assembly/vigen-re-cipher.arm
Normal file
203
Task/Vigen-re-cipher/ARM-Assembly/vigen-re-cipher.arm
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program vignere.s */
|
||||
/* REMARK 1 : this program use routines in a include file
|
||||
see task Include a file language arm assembly
|
||||
for the routine affichageMess conversion10
|
||||
see at end of this program the instruction include */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes */
|
||||
/*******************************************/
|
||||
.include "../constantes.inc"
|
||||
|
||||
.equ BUFFERSIZE, 2000
|
||||
/*******************************************/
|
||||
/* Macros */
|
||||
/*******************************************/
|
||||
//.include "../../ficmacros32.inc" @ for developer debugging
|
||||
|
||||
|
||||
/*******************************************/
|
||||
/* Initialized data */
|
||||
/*******************************************/
|
||||
.data
|
||||
szMessDebutPgm: .asciz "Program 32 bits start. \n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessFinOK: .asciz "Program normal end. \n"
|
||||
szMessError: .asciz "\nError Buffer too small!!!\n"
|
||||
szMessString: .asciz "String :\n"
|
||||
szMessEncrip: .asciz "\nEncrypted :\n"
|
||||
szMessDecrip: .asciz "\nDecrypted :\n"
|
||||
szString1: .asciz "ABCDEFGHIJKLMNOPQRSTUVWXYZ!.?abcdefghijklmnopqrstuvwxyz"
|
||||
//szString1: .asciz "attackatdawn"
|
||||
//szString1: .asciz "ATTACKATDAWN"
|
||||
szKey1: .asciz "LEMON"
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
sBuffer1: .skip BUFFERSIZE
|
||||
sBuffer2: .skip BUFFERSIZE
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr r0,iAdrszMessDebutPgm
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszMessString @ display message
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszString1 @ display string
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszString1 @ string address
|
||||
ldr r1,iAdrszKey1 @ key
|
||||
ldr r2,iAdrsBuffer1 @ encrypted buffer
|
||||
bl encrypt
|
||||
cmp r0,#0
|
||||
ble 99f
|
||||
ldr r0,iAdrszMessEncrip
|
||||
bl affichageMess
|
||||
ldr r0,iAdrsBuffer1 @ display encrypted buffer
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrsBuffer1 @ encrypted buffer
|
||||
ldr r1,iAdrszKey1 @ key
|
||||
ldr r2,iAdrsBuffer2 @ decrypted buffer
|
||||
bl decrypt
|
||||
ldr r0,iAdrszMessDecrip
|
||||
bl affichageMess
|
||||
ldr r0,iAdrsBuffer2 @ display decrypted buffer
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrszMessFinOK
|
||||
bl affichageMess
|
||||
b 100f
|
||||
99:
|
||||
ldr r0,iAdrszMessError @ error
|
||||
bl affichageMess
|
||||
mov r0, #1
|
||||
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
|
||||
iAdrszMessDecrip: .int szMessDecrip
|
||||
iAdrszMessEncrip: .int szMessEncrip
|
||||
iAdrszString1: .int szString1
|
||||
iAdrsBuffer1: .int sBuffer1
|
||||
iAdrsBuffer2: .int sBuffer2
|
||||
iAdrszKey1: .int szKey1
|
||||
iAdrszMessDebutPgm: .int szMessDebutPgm
|
||||
iAdrszMessFinOK: .int szMessFinOK
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
iAdrszMessError: .int szMessError
|
||||
/******************************************************************/
|
||||
/* encrypt strings */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the string1 */
|
||||
/* r1 contains key address
|
||||
/* r2 contains the address of the encrypted string */
|
||||
/* r0 return buffer lenght */
|
||||
encrypt:
|
||||
push {r3-r7,lr} @ save registers
|
||||
mov r3,#0 @ counter byte string 1
|
||||
mov r5,#0 @ counter byte buffer
|
||||
1:
|
||||
mov r4,#0 @ counter byte key
|
||||
2:
|
||||
cmp r5,#BUFFERSIZE @ max length buffer ?
|
||||
movge r0,#-1 @ error
|
||||
bge 100f
|
||||
ldrb r6,[r1,r4] @ load a byte
|
||||
cmp r6,#0 @ end key ?
|
||||
beq 1b
|
||||
sub r6,r6,#'A' @ character rang in alfabet
|
||||
add r4,r4,#1
|
||||
3:
|
||||
ldrb r7,[r0,r3] @ load byte string 1
|
||||
cmp r7,#0 @ zero final ?
|
||||
streqb r7,[r2,r5]
|
||||
moveq r0,r5
|
||||
beq 100f
|
||||
cmp r7,#65 @ < A ?
|
||||
addlt r3,#1
|
||||
blt 3b
|
||||
cmp r7,#90 @ > Z
|
||||
bgt 4f
|
||||
add r7,r6 @ add key
|
||||
cmp r7,#90 @ > Z
|
||||
subgt r7,#26 @ - alphaget size
|
||||
strb r7,[r2,r5] @ store result
|
||||
add r5,r5,#1
|
||||
add r3,r3,#1 @ other byte of string
|
||||
b 2b @ other byte of key
|
||||
4:
|
||||
cmp r7,#97 @ < a ?
|
||||
addlt r3,#1
|
||||
blt 3b
|
||||
cmp r7,#122 @> z
|
||||
addgt r3,#1
|
||||
bgt 3b
|
||||
sub r7,#32 @ convert minuscul to majuscule
|
||||
add r7,r6 @ add key
|
||||
cmp r7,#90 @ if > Z
|
||||
subgt r7,#26 @ - alphaget size
|
||||
strb r7,[r2,r5] @ store result
|
||||
add r5,r5,#1
|
||||
add r3,#1
|
||||
b 2b
|
||||
|
||||
100:
|
||||
pop {r3-r7,lr} @ restaur registers
|
||||
bx lr @ return
|
||||
/******************************************************************/
|
||||
/* decrypt strings */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the encrypted string1 */
|
||||
/* r1 contains the key */
|
||||
/* r2 contains the address of the decrypted buffer */
|
||||
decrypt:
|
||||
push {r3-r7,lr} @ save registers
|
||||
mov r3,#0 @ counter byte string 1
|
||||
mov r5,#0 @ counter byte buffer
|
||||
|
||||
1:
|
||||
mov r4,#0 @ counter byte key
|
||||
2:
|
||||
ldrb r6,[r1,r4] @ load byte key
|
||||
cmp r6,#0 @ end key
|
||||
beq 1b
|
||||
sub r6,r6,#'A'
|
||||
add r4,r4,#1
|
||||
3:
|
||||
ldrb r7,[r0,r3] @ load byte string 1
|
||||
cmp r7,#0 @ zero final ?
|
||||
streqb r7,[r2,r5]
|
||||
moveq r0,r5
|
||||
beq 100f
|
||||
cmp r7,#65 @ < A ?
|
||||
addlt r3,#1
|
||||
blt 3b
|
||||
cmp r7,#90 @ > Z
|
||||
addgt r3,#1 @ no minuscul
|
||||
bgt 3b
|
||||
sub r7,r6 @ add key
|
||||
cmp r7,#65 @ < A
|
||||
addlt r7,#26 @
|
||||
strb r7,[r2,r5]
|
||||
add r5,r5,#1
|
||||
add r3,r3,#1 @ other byte of string
|
||||
b 2b @ other byte of key
|
||||
|
||||
|
||||
100:
|
||||
pop {r3-r7,lr} @ restaur registers
|
||||
bx lr @ return
|
||||
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
.include "../affichage.inc"
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
const
|
||||
(
|
||||
const (
|
||||
key = "VIGENERECIPHER"
|
||||
text = "Beware the Jabberwock, my son! The jaws that bite, the claws that catch!"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue