Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,258 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program menu164.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"
szChoose: .asciz "\nMake your choise: "
szMessErrorNum: .asciz "Error : number do not exists!!\n"
szMesschoose: .asciz "\nYou have chosen: "
szLigne1: .asciz "fee fie"
szLigne2: .asciz "huff and puff"
szLigne3: .asciz "mirror mirror"
szLigne4: .asciz "tick tock"
tabMenu: .quad szLigne1
.quad szLigne2
.quad szLigne3
.quad szLigne4
.equ NBLIGNES, (. - tabMenu ) / 8
/*******************************************/
/* UnInitialized data */
/*******************************************/
.bss
.align 4
sBuffer: .skip BUFFERSIZE
sBuffex1: .skip BUFFERSIZE
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main:
ldr x0,qAdrszMessDebutPgm
bl affichageMess
1:
ldr x0,qAdrtabMenu // display menu
ldr x1,qAdrsBuffer
bl displayMenu
mov x5,x0
ldr x0,qAdrszChoose // display string
bl affichageMess
bl keyboardInput
sub x0,x0,#'0' // input control
cmp x0,#0
ble error
cmp x0,x5
bge error
sub x4,x0,#1 // compute index choose string
ldr x0,qAdrszMesschoose
bl affichageMess
ldr x1,qAdrtabMenu // menu
ldr x0,[x1,x4,lsl #3] // load line address
bl affichageMess // and display
ldr x0,qAdrszCarriageReturn
bl affichageMess
ldr x0,qAdrszCarriageReturn
bl affichageMess
b 1b // loop
error:
ldr x0,qAdrszMessErrorNum
bl affichageMess
b 1b
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
qAdrsBuffer: .quad sBuffer
qAdrszChoose: .quad szChoose
qAdrszMessDebutPgm: .quad szMessDebutPgm
qAdrszMessFinOK: .quad szMessFinOK
qAdrszCarriageReturn: .quad szCarriageReturn
qAdrszMessError: .quad szMessError
qAdrszMessErrorNum: .quad szMessErrorNum
qAdrszMesschoose: .quad szMesschoose
/******************************************************************/
/* display menu */
/******************************************************************/
/* r0 contains menu address */
/* r1 contains buffer address */
/* r0 return index max */
displayMenu:
stp x1,lr,[sp,-16]! // save registers
stp x2,x3,[sp,-16]!
stp x4,x5,[sp,-16]!
stp x6,x7,[sp,-16]!
stp x8,x9,[sp,-16]!
mov x8,x0
mov x9,x1
bl searchMaxSize // compute max size line
mov x7,x0 // maxi size
mov x5,#0
1:
ldr x6,[x8,x5,lsl #3] // load line address
mov x2,#0
2:
mov x0,x6
mov x1,x9
bl copyString // copy menu line to buffer
sub x1,x7,x0 // compute maxi len - string length
mov x3,#0
mov x2,#' '
3: // loop to add space in buffer
cmp x3,x1
bge 4f
strb w2,[x9,x0]
add x0,x0,#1
add x3,x3,#1
b 3b
4:
strb w2,[x9,x0] // add one space
add x0,x0,#1
mov x2,#':'
strb w2,[x9,x0] // add : to buffer
add x0,x0,#1
mov x2,#' '
strb w2,[x9,x0] // add one space
add x0,x0,#1
mov x4,x0
add x0,x5,#1 // index
add x1,x9,x4
bl conversion10 // decimal conversion
mov x2,' '
add x1,x0,x4
strb w2,[x9,x1] // replace zero by space
add x1,x1,#1
mov x2,#0x0a
strb w2,[x9,x1] // add : to buffer
add x1,x1,#1
mov x2,#0
strb w2,[x9,x1] // add 0 final to buffer
mov x0,x9 // buffer display
bl affichageMess
add x5,x5,#1 // increment indice
cmp x5,#NBLIGNES // maxi ?
blt 1b
add x0,x5,#1 // index max
100:
ldp x8,x9,[sp],16
ldp x6,x7,[sp],16
ldp x4,x5,[sp],16
ldp x2,x3,[sp],16
ldp x1,lr,[sp],16 // restaur registers
ret
/******************************************************************/
/* search max size of menu lines */
/******************************************************************/
/* r0 contains menu address */
/* r0 return max lenght */
searchMaxSize:
stp x1,lr,[sp,-16]! // save registers
stp x2,x3,[sp,-16]!
stp x4,x5,[sp,-16]!
mov x1,#0
mov x5,#0 // max size
1:
ldr x2,[x0,x1,lsl #3] // load line address
mov x3,#0 // char indice
2:
ldrb w4,[x2,x3] // load char
cmp x4,#0 // end string ?
beq 3f
add x3,x3,#1
b 2b // loop
3:
cmp x3,x5 // compare length and size maxi
csel x5,x3,x5,gt
add x1,x1,#1
cmp x1,#NBLIGNES
blt 1b
mov x0,x5 // return maxi size
100:
ldp x4,x5,[sp],16
ldp x2,x3,[sp],16
ldp x1,lr,[sp],16 // restaur registers
ret
qAdrtabMenu: .quad tabMenu
/******************************************************************/
/* copy strings */
/******************************************************************/
/* r0 contains string address */
/* r1 contains address buffer
/* r0 return max lenght */
copyString:
stp x1,lr,[sp,-16]! // save registers
stp x2,x3,[sp,-16]!
mov x2,#0
1:
ldrb w3,[x0,x2] // load byte
cmp x3,#0 // final zero
beq 2f
strb w3,[x1,x2] // store byte in buffer
add x2,x2,#1
b 1b
2:
mov x0,x2 // return buffer position
100:
ldp x2,x3,[sp],16
ldp x1,lr,[sp],16 // restaur registers
ret
/******************************************************************/
/* string entry */
/******************************************************************/
/* r0 return the first character of human entry */
keyboardInput:
stp x1,lr,[sp,-16]! // save registers
stp x2,x8,[sp,-16]!
mov x0,#STDIN // Linux input console
ldr x1,qAdrsBuffex1 // buffer address
mov x2,#BUFFERSIZE // buffer size
mov x8,#READ // request to read datas
svc 0 // call system
ldr x1,qAdrsBuffex1 // buffer address
ldrb w0,[x1] // load first character
100:
ldp x2,x8,[sp],16
ldp x1,lr,[sp],16 // restaur registers
ret
qAdrsBuffex1: .quad sBuffex1
/***************************************************/
/* ROUTINES INCLUDE */
/***************************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeARM64.inc"

View file

@ -0,0 +1,240 @@
/* ARM assembly Raspberry PI */
/* program menu1.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 STDIN, 1
.equ READ, 3
.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"
szChoose: .asciz "\nMake your choise: "
szMessErrorNum: .asciz "Error : number do not exists!!\n"
szMesschoose: .asciz "\nYou have chosen: "
szLigne1: .asciz "fee fie"
szLigne2: .asciz "huff and puff"
szLigne3: .asciz "mirror mirror"
szLigne4: .asciz "tick tock"
tabMenu: .int szLigne1
.int szLigne2
.int szLigne3
.int szLigne4
.equ NBLIGNES, (. - tabMenu ) / 4
/*******************************************/
/* UnInitialized data */
/*******************************************/
.bss
.align 4
sBuffer: .skip BUFFERSIZE
sBuffer1: .skip BUFFERSIZE
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main:
ldr r0,iAdrszMessDebutPgm
bl affichageMess
1:
ldr r0,iAdrtabMenu @ display menu
ldr r1,iAdrsBuffer
bl displayMenu
mov r5,r0
ldr r0,iAdrszChoose @ display string
bl affichageMess
bl keyboardInput
//affregtit saisie
sub r0,#'0' @ input control
cmp r0,#0
ble error
cmp r0,r5
bge error
sub r4,r0,#1 @ compute index choose string
ldr r0,iAdrszMesschoose
bl affichageMess
ldr r1,iAdrtabMenu @ menu
ldr r0,[r1,r4,lsl #2] @ load line address
bl affichageMess @ and display
ldr r0,iAdrszCarriageReturn
bl affichageMess
ldr r0,iAdrszCarriageReturn
bl affichageMess
b 1b @ loop
error:
ldr r0,iAdrszMessErrorNum
bl affichageMess
b 1b
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
iAdrsBuffer: .int sBuffer
iAdrszChoose: .int szChoose
iAdrszMessDebutPgm: .int szMessDebutPgm
iAdrszMessFinOK: .int szMessFinOK
iAdrszCarriageReturn: .int szCarriageReturn
iAdrszMessError: .int szMessError
iAdrszMessErrorNum: .int szMessErrorNum
iAdrszMesschoose: .int szMesschoose
/******************************************************************/
/* display menu */
/******************************************************************/
/* r0 contains menu address */
/* r1 contains buffer address */
/* r0 return index max */
displayMenu:
push {r1-r9,lr} @ save registers
mov r8,r0
mov r9,r1
bl searchMaxSize @ compute max size line
mov r7,r0 @ maxi size
mov r5,#0
1:
ldr r6,[r8,r5,lsl #2] @ load line address
mov r2,#0
2:
mov r0,r6
mov r1,r9
bl copyString @ copy menu line to buffer
sub r1,r7,r0 @ compute maxi len - string length
mov r3,#0
mov r2,#' '
3: @ loop to add space in buffer
cmp r3,r1
bge 4f
strb r2,[r9,r0]
add r0,r0,#1
add r3,r3,#1
b 3b
4:
strb r2,[r9,r0] @ add one space
add r0,r0,#1
mov r2,#':'
strb r2,[r9,r0] @ add : to buffer
add r0,r0,#1
mov r2,#' '
strb r2,[r9,r0] @ add one space
add r0,r0,#1
mov r4,r0
add r0,r5,#1 @ index
add r1,r9,r4
bl conversion10 @ decimal conversion
add r1,r0,r4
add r1,r1,#1
mov r2,#0x0a
strb r2,[r9,r1] @ add : to buffer
add r1,r1,#1
mov r2,#0
strb r2,[r9,r1] @ add 0 final to buffer
mov r0,r9 @ buffer display
bl affichageMess
add r5,r5,#1 @ increment indice
cmp r5,#NBLIGNES @ maxi ?
blt 1b
add r0,r5,#1 @ index max
100:
pop {r1-r9,pc} @ restaur registers
/******************************************************************/
/* search max size of menu lines */
/******************************************************************/
/* r0 contains menu address */
/* r0 return max lenght */
searchMaxSize:
push {r1-r5,lr} @ save registers
mov r1,#0
mov r5,#0 @ max size
1:
ldr r2,[r0,r1,lsl #2] @ load line address
mov r3,#0 @ char indice
2:
ldrb r4,[r2,r3] @ load char
cmp r4,#0 @ end string ?
beq 3f
add r3,r3,#1
b 2b @ loop
3:
cmp r3,r5 @ compare length and size maxi
movgt r5,r3
add r1,r1,#1
cmp r1,#NBLIGNES
blt 1b
mov r0,r5 @ return maxi size
100:
pop {r1-r5,pc} @ restaur registers
iAdrtabMenu: .int tabMenu
/******************************************************************/
/* copy strings */
/******************************************************************/
/* r0 contains string address */
/* r1 contains address buffer
/* r0 return max lenght */
copyString:
push {r1-r3,lr} @ save registers
mov r2,#0
1:
ldrb r3,[r0,r2] @ load byte
cmp r3,#0 @ final zero
beq 2f
strb r3,[r1,r2] @ store byte in buffer
add r2,r2,#1
b 1b
2:
mov r0,r2 @ return buffer position
100:
pop {r1-r3,pc} @ restaur registers
/******************************************************************/
/* string entry */
/******************************************************************/
/* r0 return the first character of human entry */
keyboardInput:
push {r1-r7,lr} @ save registers
mov r0,#STDIN @ Linux input console
ldr r1,iAdrsBuffer1 @ buffer address
mov r2,#BUFFERSIZE @ buffer size
mov r7,#READ @ request to read datas
svc 0 @ call system
ldr r1,iAdrsBuffer1 @ buffer address
ldrb r0,[r1] @ load first character
100:
pop {r1-r7,pc}
iAdrsBuffer1: .int sBuffer1
/***************************************************/
/* ROUTINES INCLUDE */
/***************************************************/
.include "../affichage.inc"

View file

@ -1,15 +0,0 @@
MENU(STRINGS,SEP)
;http://rosettacode.org/wiki/Menu
NEW I,A,MAX
;I is a loop variable
;A is the string read in from the user
;MAX is the number of substrings in the STRINGS list
;SET STRINGS="fee fie^huff and puff^mirror mirror^tick tock"
SET MAX=$LENGTH(STRINGS,SEP)
QUIT:MAX=0 ""
WRITEMENU
FOR I=1:1:MAX WRITE I,": ",$PIECE(STRINGS,SEP,I),!
READ:30 !,"Choose a string by its index: ",A,!
IF (A<1)!(A>MAX)!(A\1'=A) GOTO WRITEMENU
KILL I,MAX
QUIT $PIECE(STRINGS,SEP,A)

View file

@ -1,38 +1,60 @@
MODULE Menu;
FROM InOut IMPORT WriteString, WriteCard, WriteLn, ReadCard;
FROM STextIO IMPORT ReadChar, SkipLine;
FROM CharClass IMPORT IsNumeric, IsControl, IsWhiteSpace;
CONST StringLength = 100;
MenuSize = 4;
TYPE String = ARRAY[0..StringLength-1] OF CHAR;
VAR menu : ARRAY[0..MenuSize] OF String;
selection, index : CARDINAL;
PROCEDURE MenuF(): String;
VAR
menu : ARRAY[0..MenuSize] OF String;
inp : CHAR;
selection, index : CARDINAL;
BEGIN
menu[1] := "fee fie";
menu[2] := "huff and puff";
menu[3] := "mirror mirror";
menu[4] := "tick tock";
selection := 0;
WHILE selection=0 DO
FOR index := 1 TO HIGH(menu) DO
WriteString("[");
WriteCard( index,1);
WriteString( "] ");
WriteString( menu[index]);
WriteLn;
END;(*of FOR*)
FOR index := 1 TO HIGH(menu) DO
WriteString("[");
WriteCard( index,1);
WriteString( "] ");
WriteString( menu[index]);
WriteLn;
END;(*of FOR*)
inp := '';
WriteString("Choose what you want : ");
ReadChar(inp);
SkipLine;
WriteString("Choose what you want : ");
ReadCard(selection);
IF IsNumeric(inp) THEN
CASE inp OF
'1' : selection := 1 |
'2' : selection := 2 |
'3' : selection := 3 |
'4' : selection := 4 |
ELSE ;
selection := 0;
END;
IF (selection <= HIGH(menu)) AND (selection > 0) THEN
WriteString("You have chosen: ");
WriteString( menu[selection]);
WriteLn;
ELSE
WriteString("Selection is out of range!");
WriteLn;
END (*of IF*)
IF (selection <= HIGH(menu)) AND (selection > 0) THEN
RETURN menu[selection];
END (*of IF*)
ELSIF IsWhiteSpace(inp) OR IsControl(inp) THEN
RETURN "";
END;
END;
END MenuF;
BEGIN
WriteString(MenuF());
WriteLn;
END Menu.