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,143 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program bincompl64.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*********************************/
/* Initialized data */
/*********************************/
.data
szMessDebutPgm: .asciz "Program 64 bits start. \n"
szMessFinOK: .asciz "Program normal end. \n"
szMessError: .asciz "Error detected !!!!. \n"
szMessNumber: .asciz "Start number : "
szMessResUns: .asciz "Result unsigned : "
szMessResS: .asciz "Result signed : "
szMessResMvn: .asciz "Result with mvn instruction : "
szCarriageReturn: .asciz "\n"
/*********************************/
/* UnInitialized data */
/*********************************/
.bss
.align 4
sZoneConv: .skip 24
/*********************************/
/* code section */
/*********************************/
.text
.global main
main:
ldr x0,qAdrszMessDebutPgm
bl affichageMess // start message
mov x4,12345 // number
mov x0,x4
ldr x1,qAdrsZoneConv
bl conversion10 // decimal conversion
mov x0,3
ldr x1,qAdrszMessNumber
ldr x2,qAdrsZoneConv
ldr x3,qAdrszCarriageReturn
bl displayStrings
mov x0,x4
neg x0,x0
ldr x1,qAdrsZoneConv
bl conversion10 // decimal conversion unsigned
mov x0,3
ldr x1,qAdrszMessResUns
ldr x2,qAdrsZoneConv
ldr x3,qAdrszCarriageReturn
bl displayStrings
mov x0,x4
neg x0,x0
ldr x1,qAdrsZoneConv
bl conversion10S // decimal conversion signed
mov x0,3
ldr x1,qAdrszMessResS
ldr x2,qAdrsZoneConv
ldr x3,qAdrszCarriageReturn
bl displayStrings
mov x0,x4
mvn x0,x0 // use mvn instruction
ldr x1,qAdrsZoneConv
bl conversion10S // decimal conversion signed
mov x0,3
ldr x1,qAdrszMessResMvn
ldr x2,qAdrsZoneConv
ldr x3,qAdrszCarriageReturn
bl displayStrings
ldr x0,qAdrszMessFinOK
bl affichageMess
100: // standard end of the program
mov x0,0 // return code
mov x8,EXIT // request to exit program
svc 0 // perform the system call
qAdrszMessDebutPgm: .quad szMessDebutPgm
qAdrszMessFinOK: .quad szMessFinOK
qAdrszMessError: .quad szMessError
qAdrszCarriageReturn: .quad szCarriageReturn
qAdrsZoneConv: .quad sZoneConv
qAdrszMessNumber: .quad szMessNumber
qAdrszMessResUns: .quad szMessResUns
qAdrszMessResS: .quad szMessResS
qAdrszMessResMvn: .quad szMessResMvn
/***************************************************/
/* display multi strings */
/* new version 24/05/2023 */
/***************************************************/
/* x0 contains number strings address */
/* x1 address string1 */
/* x2 address string2 */
/* x3 address string3 */
/* x4 address string4 */
/* x5 address string5 */
/* x6 address string6 */
displayStrings: // INFO: displayStrings
stp x7,lr,[sp,-16]! // save registers
stp x2,fp,[sp,-16]! // save registers
add fp,sp,#32 // save paraméters address (4 registers saved * 8 bytes)
mov x7,x0 // save strings number
cmp x7,#0 // 0 string -> end
ble 100f
mov x0,x1 // string 1
bl affichageMess
cmp x7,#1 // number > 1
ble 100f
mov x0,x2
bl affichageMess
cmp x7,#2
ble 100f
mov x0,x3
bl affichageMess
cmp x7,#3
ble 100f
mov x0,x4
bl affichageMess
cmp x7,#4
ble 100f
mov x0,x5
bl affichageMess
cmp x7,#5
ble 100f
mov x0,x6
bl affichageMess
100:
ldp x2,fp,[sp],16 // restaur registers
ldp x7,lr,[sp],16 // restaur registers
ret
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

View file

@ -0,0 +1,6 @@
int d = 1234567;
int b[] = {-d,-d + 1,-2,-1,0,1,2,d -2,d -1};
for(int i = 0; i < b.length; ++i) {
write(string(b[i]) + " -> " + string(-b[i]));
}

View file

@ -0,0 +1,6 @@
d = 1234567
dim b = {-d, -d+1, -2, -1, 0, 1, 2, d-2, d-1}
for i = 0 to b[?]-1
print b[i]; " -> "; -b[i]
next i

View file

@ -0,0 +1,31 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Twos_complement.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 d PIC S9(7) COMP-5 VALUE 1234567.
01 neg-d PIC S9(7) COMP-5.
01 neg-d1 PIC S9(7) COMP-5.
01 neg-b PIC S9(7) COMP-5.
01 d2 PIC S9(7) COMP-5.
01 d1 PIC S9(7) COMP-5.
01 b OCCURS 9 TIMES PIC S9(7) COMP-5.
01 i PIC 9(2) VALUE 1.
PROCEDURE DIVISION.
COMPUTE neg-d = -d
COMPUTE neg-d1 = -d + 1
COMPUTE d2 = d - 2
COMPUTE d1 = d - 1
MOVE neg-d TO b(1)
MOVE neg-d1 TO b(2)
MOVE -2 TO b(3)
MOVE -1 TO b(4)
MOVE 0 TO b(5)
MOVE 1 TO b(6)
MOVE 2 TO b(7)
MOVE d2 TO b(8)
MOVE d1 TO b(9)
PERFORM VARYING i FROM 1 BY 1 UNTIL i > 9
COMPUTE neg-b = -b(i)
DISPLAY b(i) " -> " neg-b
END-PERFORM
STOP RUN.

View file

@ -0,0 +1,14 @@
10 d = 1234567
20 dim b(8)
30 b(0) = -d
40 b(1) = -d+1
50 b(2) = -2
60 b(3) = -1
70 b(4) = 0
80 b(5) = 1
90 b(6) = 2
100 b(7) = d-2
110 b(8) = d-1
120 for i = 0 to ubound(b)
130 print b(i);"-> ";-b(i)
140 next i

View file

@ -3,4 +3,5 @@ Dim As Integer b(1 To ...) = {-d1, -d1+1, -2, -1, 0, 1, 2, d1-2, d1-1}
For i As Integer = 1 To Ubound(b)
Print b(i); " -> "; -b(i)
Next i
Sleep

View file

@ -17,4 +17,5 @@ Dim As Integer a2c, l
#endif
Print Bin(a, l); " -> "; Bin(a2c, l)
Sleep

View file

@ -0,0 +1,15 @@
10 LET D = 1234567
20 DIM B(8)
30 LET B(0) = -D
40 LET B(1) = -D + 1
50 LET B(2) = -2
60 LET B(3) = -1
70 LET B(4) = 0
80 LET B(5) = 1
90 LET B(6) = 2
100 LET B(7) = D - 2
110 LET B(8) = D - 1
120 FOR I = 0 TO 8
130 PRINT B(I); "-> "; -B(I)
140 NEXT I
150 END

View file

@ -0,0 +1,10 @@
Public d As Integer = 1234567
Public b As Integer[] = [-d, -d + 1, -2, -1, 0, 1, 2, d - 2, d - 1]
Public Sub Main()
For i As Integer = 0 To b.Count - 1
Print b[i]; " -> "; -b[i] ' * -1
Next
End

View file

@ -0,0 +1,37 @@
include "bitwise" {search: "."}; # see above
# Arithmetically add 1 to the non-negative integer represented by the
# bit stream `stream`, in which the least significant bit is first.
def plusplus(stream):
foreach (stream, null) as $bit ({carry: 1};
if $bit == null
then if .carry == 1 then .emit = 1 else empty end
elif .carry == 0 then .emit = $bit
## .carry is now 1:
elif $bit == 0 then {carry: 0, emit: 1 }
else .emit = 0
end )
| .emit;
# input: a non-negative integer
# output: the bit array (with most-significant bit first and with length $width)
# corresponding to the twos-complement of the input integer, it being understood
# that all but the ($width-1) least significant bits of the binary representation of . are dropped.
def twosComplement($width):
def rpad($width): ($width - length) as $l | . + [range(0; $l) | 0];
if . < 0 then "input of twosComplement should be non-negative" | error
else [flipbits( [limit($width; bitwise)] | rpad($width) | .[] )]
| [limit($width; plusplus(.[]))]
| reverse
end;
def illustrate($width):
"decimal: \(.)",
"binary: \([bitwise] | reverse | join(""))",
"twos-complement(\($width)): \(twosComplement($width) | join(""))",
"";
( 3
| illustrate(8)),
(737894120670 # 0xABCDEABCDE9
| illustrate(64))

View file

@ -0,0 +1,14 @@
d(1234567).
b([-D, -D + 1, -2, -1, 0, 1, 2, D - 2, D - 1]) :-
d(D).
print_array([]).
print_array([H|T]) :-
NegH is -H,
format('~d -> ~d~n', [H, NegH]),
print_array(T).
main :-
b(B),
print_array(B).

View file

@ -0,0 +1,20 @@
Define d.l
d = 1234567
Dim b.l(8)
b(0) = -d
b(1) = -d + 1
b(2) = -2
b(3) = -1
b(4) = 0
b(5) = 1
b(6) = 2
b(7) = d - 2
b(8) = d - 1
OpenConsole()
For i = 0 To ArraySize(b()) - 1
PrintN(Str(b(i)) + " -> " + Str(-b(i)))
Next i
Input()
CloseConsole()

View file

@ -0,0 +1,17 @@
Dim d As Long
d = 1234567
Dim b(8) As Long
b(0) = -d
b(1) = -d + 1
b(2) = -2
b(3) = -1
b(4) = 0
b(5) = 1
b(6) = 2
b(7) = d - 2
b(8) = d - 1
For i = 0 To UBound(b)
Print b(i); " -> "; -b(i) ' * -1
Next i

View file

@ -0,0 +1,5 @@
fn main() {
let i = 1;
println!("i = {:#?}, -(i) = {:#?}, !(i) + 1 = {:#?}", i, -i, !i + 1);
return (); // i = 1, -(i) = -1, !(i) + 1 = -1
}

View file

@ -0,0 +1,22 @@
module main;
integer d;
integer b[0:8];
integer i;
initial begin
d = 1234567;
b[0] = -d;
b[1] = -d + 1;
b[2] = -2;
b[3] = -1;
b[4] = 0;
b[5] = 1;
b[6] = 2;
b[7] = d - 2;
b[8] = d - 1;
for (i = 0; i <= 8; i = i + 1) begin
$display("%0d -> %0d", b[i], -b[i]);
end
end
endmodule

View file

@ -0,0 +1,24 @@
PROGRAM "Two's complement"
VERSION "0.0000"
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
d = 1234567
DIM b[8]
b[0] = -d
b[1] = -d+1
b[2] = -2
b[3] = -1
b[4] = 0
b[5] = 1
b[6] = 2
b[7] = d-2
b[8] = d-1
FOR i = 0 TO UBOUND(b[])
PRINT b[i]; " -> "; -b[i]
NEXT i
END FUNCTION
END PROGRAM

View file

@ -0,0 +1,16 @@
d = 1234567
dim b(8)
b(0) = -d
b(1) = -d+1
b(2) = -2
b(3) = -1
b(4) = 0
b(5) = 1
b(6) = 2
b(7) = d-2
b(8) = d-1
for i = 0 to arraysize(b(), 1)
print b(i), " -> ", -b(i)
next i