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,138 @@
/* 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"

View file

@ -31,10 +31,10 @@ BEGIN
STRING align = "align="""
+ CASE column alignment OF t IN "left", "right" OUT "center" ESAC
+ """";
PROC th element = ( REF FILE f, HTMLTABLE t, STRING content )VOID:
put( f, ( "<th " + align + ">" + content + "</th>", newline ) );
PROC td element = ( REF FILE f, HTMLTABLE t, HTMLTABLEDATA content )VOID:
put( f, ( "<td " + align + ">" + TOSTRING content + "</td>", newline ) );
PROC th element = ( REF FILE hf, STRING content )VOID:
put( hf, ( "<th " + align + ">" + content + "</th>", newline ) );
PROC td element = ( REF FILE hf, HTMLTABLEDATA content )VOID:
put( hf, ( "<td " + align + ">" + TOSTRING content + "</td>", newline ) );
# table element #
put( f, ( "<table"
@ -47,32 +47,42 @@ BEGIN
);
# table headings #
put( f, ( "<tr>", newline ) );
IF row numbering OF t = numbered left THEN th element( f, t, "" ) FI;
IF row numbering OF t = numbered left THEN th element( f, "" ) FI;
FOR col FROM LWB headings OF t TO UPB headings OF t DO
th element( f, t, ( headings OF t )[ col ] )
th element( f, ( headings OF t )[ col ] )
OD;
IF row numbering OF t = numbered right THEN th element( f, t, "" ) FI;
IF row numbering OF t = numbered right THEN th element( f, "" ) FI;
put( f, ( "</tr>", newline ) );
# table rows #
FOR row FROM 1 LWB data OF t TO 1 UPB data OF t DO
put( f, ( "<tr>", newline ) );
IF row numbering OF t = numbered left THEN th element( f, t, whole( row, 0 ) ) FI;
IF row numbering OF t = numbered left THEN th element( f, whole( row, 0 ) ) FI;
FOR col FROM 2 LWB data OF t TO 2 UPB data OF t DO
td element( f, t, ( data OF t )[ row, col ] )
td element( f, ( data OF t )[ row, col ] )
OD;
IF row numbering OF t = numbered right THEN th element( f, t, whole( row, 0 ) ) FI;
IF row numbering OF t = numbered right THEN th element( f, whole( row, 0 ) ) FI;
put( f, ( "</tr>", newline ) )
OD;
# end of table #
put( f, ( "</table>", newline ) )
END # write html table # ;
# create an HTMLTABLE and print it to standard output #
HTMLTABLE t;
cell spacing OF t := col spacing OF t := 0;
border OF t := 1;
column alignment OF t := align right;
row numbering OF t := numbered left;
headings OF t := ( "A", "B", "C" );
data OF t := ( ( 1001, 1002, 1003 ), ( 21, 22, 23 ), ( 201, 202, 203 ) );
write html table( stand out, t )
BEGIN # tests #
# create an HTMLTABLE and print it to standard output #
HTMLTABLE t;
cell spacing OF t := col spacing OF t := 0;
border OF t := 1;
column alignment OF t := align right;
row numbering OF t := numbered left;
headings OF t := ( "A", "B", "C" );
data OF t := ( ( 1001, 1002, 1003 ), ( 21, 22, 23 ), ( 201, 202, 203 ) );
write html table( stand out, t );
# show the effect of the other alignment and numering options #
column alignment OF t := align left;
row numbering OF t := numbered right;
write html table( stand out, t );
column alignment OF t := align centre;
row numbering OF t := not numbered;
write html table( stand out, t )
END

View file

@ -0,0 +1,141 @@
/* ARM assembly Raspberry PI */
/* program crehtml.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 MAXILINE, 5
.equ MAXIRANDOMNUMBER, 3
/*********************************/
/* Initialized data */
/*********************************/
.data
szMessDebutPgm: .asciz "Program 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
iGraine: .int 1234567 @ seed for number random
/*********************************/
/* UnInitialized data */
/*********************************/
.bss
sZoneConv: .skip 24
.align 4
/*********************************/
/* code section */
/*********************************/
.text
.global main
main:
ldr r0,iAdrszMessDebutPgm
bl affichageMess @ start message
ldr r0,iAdrszarrayheader
bl affichageMess
ldr r0,iAdrszLine1
bl affichageMess
mov r4,#1 @ line counter
1: @ begin line loop
ldr r0,iAdrszDebLine
bl affichageMess
mov r0,r4 @ convert line to décimal
ldr r1,iAdrsZoneConv
bl conversion10
mov r2,#0 @ add final zero
strb r2,[r1,r0]
ldr r0,iAdrsZoneConv @ and display N° line
bl affichageMess
ldr r0,iAdrszEndCol
bl affichageMess
mov r5,#0 @ random number counter
2:
mov r0,#10000 @ limit random number
bl genereraleas @ call random
ldr r1,iAdrsZoneConv @ conversion to décimal
bl conversion10
mov r2,#0 @ add final zero
strb r2,[r1,r0]
ldr r0,iAdrsZoneConv @ and display random number
bl affichageMess
ldr r0,iAdrszEndCol
bl affichageMess
add r5,r5,#1 @ increment counter
cmp r5,#MAXIRANDOMNUMBER @ and loop
blt 2b
ldr r0,iAdrszEndLine
bl affichageMess
add r4,r4,#1 @ increment line counter
cmp r4,#MAXILINE @ and loop
blt 1b
ldr r0,iAdrszarrayend
bl affichageMess
ldr r0,iAdrszMessFinOK
bl affichageMess
b 100f
99:
ldr r0,iAdrszMessErreur @ error
bl affichageMess
mov r0, #1 @ return code error
b 100f
100:
mov r7,#EXIT @ program end
svc #0 @ system call
iAdrszMessDebutPgm: .int szMessDebutPgm
iAdrszMessFinOK: .int szMessFinOK
iAdrszMessErreur: .int szMessErreur
iAdrsZoneConv: .int sZoneConv
iAdrszarrayheader: .int szarrayheader
iAdrszLine1: .int szLine1
iAdrszDebLine: .int szDebLine
iAdrszEndCol: .int szEndCol
iAdrszEndLine: .int szEndLine
iAdrszarrayend: .int szarrayend
/***************************************************/
/* 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 */
/***************************************************/
.include "../affichage.inc"

View file

@ -7,7 +7,7 @@ print ""
for r to 3
write "<tr align=right><td>" & r
for c to 3
write "<td>" & randint 200
write "<td>" & random 200
.
print ""
.

View file

@ -0,0 +1,323 @@
; creating html table
; assembly X86 window
; download and install visual studio 2022 free site microsoft
; search and open X64 native tools command prompt
; compil and link program with this command :
; ml64 <pgmmame>.asm /link /ENTRY:main /SUBSYSTEM:console kernel32.lib user32.lib Shell32.lib
; this program respects the 64-bit calling convention :
; registers arguments : rcx rdx r8 r9 and stack
; registers saved : rbx,rbp,rdi,rsi, r12-r15
; ATTENTION les registres rax,rcx,rdx,r8-r11 peuvent être
; perdus lors d'un appel de fonction
;*********************************
; constantes
;*********************************
STD_OUTPUT_HANDLE equ -11
NBLIGNES equ 5
BUFFERSIZE equ 200
;*********************************
; MACROS
;*********************************
afficherLib MACRO messa
local mess1,LGMESS1C
.data
mess1 db messa,10,0
LGMESS1C equ $ - mess1
.code
push rax
push rcx
push rdx
push r8
push r9
push r10
push r11
mov rcx, offset mess1
mov rdx,LGMESS1C
call afficherConsole
pop r11
pop r10
pop r9
pop r8
pop rdx
pop rcx
pop rax
ENDM
;*********************************
; user data
;*********************************
.data
szarrayheader db "<html><table> ",10,0
LGSZARRAYHEADER equ $ - szarrayheader -1
szarrayend db "</table></html>",10,0
LGSZARRAYEND equ $ - szarrayend -1
szLine1 db "<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>",10,0
LGSZLINE1 equ $ - szLine1 - 1
szDebLine db "<TR><TD align=",34,"right",34,">",0
LGSZDEBLINE equ $ - szDebLine - 1
szEndLine db "</TD></TR>",10,0
LGSZENDLINE equ $ - szEndLine - 1
szEndCol db "</TD><TD align=",34,"right",34,">",0
LGSZENDCOL equ $ - szEndCol - 1
sBuffer db BUFFERSIZE dup (' ')
szRetourLigne db 10,0
sZoneConv db 24 dup (' ')
sZoneConv1 db 24 dup (' ')
sZoneConv2 db 24 dup (' ')
sZoneConv3 db 24 dup (' ')
align 8
qgraine dq 123456789
qNbDep1 dq 0019660dh
qNbDep2 dq 3c6ef35fh
hConsole dq 0
;*********************************
; user code fonction principale
;*********************************
.code
extern WriteFile : proc, GetStdHandle : proc, ExitProcess : proc
extern GetLastError : proc
main PROC public
afficherLib "Program start."
mov rcx, offset szarrayheader
mov rdx,LGSZARRAYHEADER
call afficherConsole
mov rcx, offset szLine1
mov rdx,LGSZLINE1
call afficherConsole
mov rbx,1 ; indice loop
lineLoop: ; line loop begin
mov rcx,rbx
mov rdx,offset sZoneConv
call conversion10
mov rax, offset szDebLine
push rax
mov rax,LGSZDEBLINE
push rax
mov rax,offset sZoneConv
push rax
push 1
mov rax,offset szEndCol
push rax
mov rax,LGSZENDCOL
push rax
mov rcx,10000
call randomNumber
mov rcx,rax
mov rdx,offset sZoneConv1
call conversion10
mov rcx,offset sZoneConv1
push rcx
push rax
mov rax,offset szEndCol
push rax
mov rax,LGSZENDCOL
push rax
mov rcx,10000
call randomNumber
mov rcx,rax
mov rdx,offset sZoneConv2
call conversion10
mov rcx,offset sZoneConv2
push rcx
push rax
mov rax,offset szEndCol
push rax
mov rax,LGSZENDCOL
push rax
mov rcx,10000
call randomNumber
mov rcx,rax
mov rdx,offset sZoneConv3
call conversion10
mov rcx,offset sZoneConv3
push rcx
push rax
mov rax, offset szEndLine
push rax
mov rax,LGSZENDLINE
push rax
mov rcx, offset sBuffer
mov rdx,BUFFERSIZE
mov r8,9
call grouperChaines
add rsp,8 * 2 * 9
mov rcx, offset sBuffer
mov rdx,rax
call afficherConsole
inc rbx
cmp rbx,NBLIGNES
jle lineLoop
mov rcx, offset szarrayend
mov rdx,LGSZARRAYEND
call afficherConsole
mov rcx, offset szRetourLigne
mov rdx,1
call afficherConsole
finProgramme:
afficherLib "Programm end."
sub rsp,28h
mov rcx,0 ; return code
call ExitProcess
main ENDP
;**************************************
; console display
;**************************************
; rcx : string address
; rdx : length string
afficherConsole:
push rbx
push r12
sub rsp,28h ; 40 bytes on stack (shadow variables)
mov rbx,rcx ; string address
mov r12,rdx ; size string
cmp QWORD ptr hConsole,0 ; console handle ?
jne @B3
mov rcx,STD_OUTPUT_HANDLE
call GetStdHandle ; load console handle
mov hConsole, rax ; save in data
@B3:
mov rcx,hconsole ; handle
mov rdx,rbx ; string address
mov r8,r12 ; string length
mov r9,0 ;
sub rsp,8 ; stack alignement (one push)
push 0
sub rsp,20h ; stack for shadow variable
call WriteFile ; winapi function
add rsp,20h
add rsp,10h ; 1 push and alignement
add rsp,28h ; stack alignement
pop r12
pop rbx
ret
;***************************************************
;conversion to unsigned base 10
;with removal of unnecessary zeros
;and left shift
;****************************************************
; rcx : value to convert
; rdx : conversion area address length > 22
LONGUEUR equ 24
conversion10:
push rbx
push rdi
mov rdi,rdx ; conversion area address
mov BYTE ptr [rdi+LONGUEUR],0 ; 0 final conversion area
mov rax,rcx ; value
mov rcx,LONGUEUR-1
mov rbx ,10
CA1: ; loop begin
mov rdx,0 ; division rax by 10
div rbx
add rdx,'0' ; remainder conversion ascii
mov byte ptr [rdi+rcx],dl
dec rcx
cmp rax,0 ; end ?
jne CA1
xor rax,rax
inc rcx
CA5: ; copy loop
mov dl,[rdi+rcx] ; load a result character
mov byte ptr [rdi+rax],dl ; and store at conversion area begin
inc rcx
inc rax
cmp rcx,LONGUEUR ; loop if not zero final
jle CA5
pop rdi
pop rbx
ret
;**************************************
; generate random number
;**************************************
; rcx number limit
randomNumber:
mov rax,0
cmp rcx,0
je randfin
mov rax, qGraine ; load seed
mov r8,qNbDep1
mov rdx,qNbDep2
mul r8
add rax,rdx
mov qGraine,rax ; store new seed
inc rcx
mov rdx,0
div rcx
mov rax,rdx ; result = remainder
randfin:
ret
;***************************************************
; string concatenation
;**************************************************
; rcx destination area address
; rdx destination area length
; r8 strings number
; r9 0
; on stack address and length of each string
; in order of insertion
grouperChaines:
enter 0,0
push rbx
push r12
push r13
cmp r8,0
je fingrp
mov r12,rdx
mov r9,0 ; indice strings
mov r10,0 ; number of characters inserted
bouclezone:
mov r13,r8
shl r13,1
mov rbx,[rbp+8+(r13 * 8)] ; string address
mov rax,[rbp+(r13 * 8)] ; sring length
mov r11,0
bouclecopie: ; loop string copy
mov dl,byte ptr[rbx+r11]
mov byte ptr[rcx+r10],dl
inc r11
cmp r11,rax
jg finbouclecopie
inc r10 ;number of characters inserted
cmp r10,r12 ; max?
jge erreur
jmp bouclecopie
finbouclecopie:
dec r8 ; other string
jnz bouclezone
mov rax,r10 ; return size final string
jmp fingrp
erreur:
afficherLib "reception area too small"
mov rax,0
fingrp:
pop r13
pop r12
pop rbx
leave
ret
end