September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
140
Task/Compound-data-type/ARM-Assembly/compound-data-type.arm
Normal file
140
Task/Compound-data-type/ARM-Assembly/compound-data-type.arm
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program structure.s */
|
||||
|
||||
/************************************/
|
||||
/* Constantes */
|
||||
/************************************/
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
|
||||
/*******************************************/
|
||||
/* Structures */
|
||||
/********************************************/
|
||||
.struct 0
|
||||
point_x: @ x coordinate
|
||||
.struct point_x + 4
|
||||
point_y: @ y coordinate
|
||||
.struct point_y + 4
|
||||
point_end: @ end structure point
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
sMessResult: .ascii "value x : "
|
||||
sMessValeur: .fill 11, 1, ' ' @ size => 11
|
||||
szCarriageReturn: .asciz "\n"
|
||||
|
||||
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
stPoint: .skip point_end @ reservation place in memory
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main: @ entry of program
|
||||
ldr r1,iAdrstPoint
|
||||
mov r0,#5 @ x value
|
||||
str r0,[r1,#point_x]
|
||||
mov r0,#10 @ y value
|
||||
str r0,[r1,#point_y]
|
||||
@ display value
|
||||
ldr r2,iAdrstPoint
|
||||
ldr r0,[r2,#point_x]
|
||||
ldr r1,iAdrsMessValeur
|
||||
bl conversion10 @ call conversion decimal
|
||||
ldr r0,iAdrsMessResult
|
||||
bl affichageMess @ display message
|
||||
|
||||
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc #0 @ perform the system call
|
||||
|
||||
iAdrsMessValeur: .int sMessValeur
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
iAdrsMessResult: .int sMessResult
|
||||
iAdrstPoint: .int stPoint
|
||||
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {r0,r1,r2,r7,lr} @ save registres
|
||||
mov r2,#0 @ counter length
|
||||
1: @ loop length calculation
|
||||
ldrb r1,[r0,r2] @ read octet start position + index
|
||||
cmp r1,#0 @ if 0 its over
|
||||
addne r2,r2,#1 @ else add 1 in the length
|
||||
bne 1b @ and loop
|
||||
@ so here r2 contains the length of the message
|
||||
mov r1,r0 @ address message in r1
|
||||
mov r0,#STDOUT @ code to write to the standard output Linux
|
||||
mov r7, #WRITE @ code call system "write"
|
||||
svc #0 @ call systeme
|
||||
pop {r0,r1,r2,r7,lr} @ restaur des 2 registres */
|
||||
bx lr @ return
|
||||
/******************************************************************/
|
||||
/* Converting a register to a decimal unsigned */
|
||||
/******************************************************************/
|
||||
/* r0 contains value and r1 address area */
|
||||
/* r0 return size of result (no zero final in area) */
|
||||
/* area size => 11 bytes */
|
||||
.equ LGZONECAL, 10
|
||||
conversion10:
|
||||
push {r1-r4,lr} @ save registers
|
||||
mov r3,r1
|
||||
mov r2,#LGZONECAL
|
||||
|
||||
1: @ start loop
|
||||
bl divisionpar10U @ unsigned r0 <- dividende. quotient ->r0 reste -> r1
|
||||
add r1,#48 @ digit
|
||||
strb r1,[r3,r2] @ store digit on area
|
||||
cmp r0,#0 @ stop if quotient = 0
|
||||
subne r2,#1 @ else previous position
|
||||
bne 1b @ and loop
|
||||
@ and move digit from left of area
|
||||
mov r4,#0
|
||||
2:
|
||||
ldrb r1,[r3,r2]
|
||||
strb r1,[r3,r4]
|
||||
add r2,#1
|
||||
add r4,#1
|
||||
cmp r2,#LGZONECAL
|
||||
ble 2b
|
||||
@ and move spaces in end on area
|
||||
mov r0,r4 @ result length
|
||||
mov r1,#' ' @ space
|
||||
3:
|
||||
strb r1,[r3,r4] @ store space in area
|
||||
add r4,#1 @ next position
|
||||
cmp r4,#LGZONECAL
|
||||
ble 3b @ loop if r4 <= area size
|
||||
|
||||
100:
|
||||
pop {r1-r4,lr} @ restaur registres
|
||||
bx lr @return
|
||||
|
||||
/***************************************************/
|
||||
/* division par 10 unsigned */
|
||||
/***************************************************/
|
||||
/* r0 dividende */
|
||||
/* r0 quotient */
|
||||
/* r1 remainder */
|
||||
divisionpar10U:
|
||||
push {r2,r3,r4, lr}
|
||||
mov r4,r0 @ save value
|
||||
ldr r3,iMagicNumber @ r3 <- magic_number raspberry 1 2
|
||||
umull r1, r2, r3, r0 @ r1<- Lower32Bits(r1*r0) r2<- Upper32Bits(r1*r0)
|
||||
mov r0, r2, LSR #3 @ r2 <- r2 >> shift 3
|
||||
add r2,r0,r0, lsl #2 @ r2 <- r0 * 5
|
||||
sub r1,r4,r2, lsl #1 @ r1 <- r4 - (r2 * 2) = r4 - (r0 * 10)
|
||||
pop {r2,r3,r4,lr}
|
||||
bx lr @ leave function
|
||||
iMagicNumber: .int 0xCCCCCCCD
|
||||
3
Task/Compound-data-type/COBOL/compound-data-type.cobol
Normal file
3
Task/Compound-data-type/COBOL/compound-data-type.cobol
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
01 Point.
|
||||
05 x pic 9(3).
|
||||
05 y pic 9(3).
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
struct Point
|
||||
{
|
||||
int prop x :: _x.
|
||||
prop int X;
|
||||
|
||||
int prop y :: _y.
|
||||
prop int Y;
|
||||
|
||||
constructor new(IntNumber x, IntNumber y)
|
||||
[
|
||||
_x := x.
|
||||
_y := y.
|
||||
]
|
||||
constructor new(int x, int y)
|
||||
{
|
||||
X := x;
|
||||
Y := y
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
Task/Compound-data-type/Prolog/compound-data-type-1.pro
Normal file
1
Task/Compound-data-type/Prolog/compound-data-type-1.pro
Normal file
|
|
@ -0,0 +1 @@
|
|||
point(10, 20).
|
||||
3
Task/Compound-data-type/Prolog/compound-data-type-2.pro
Normal file
3
Task/Compound-data-type/Prolog/compound-data-type-2.pro
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
?- point(X,Y).
|
||||
X = 10,
|
||||
Y = 20.
|
||||
1
Task/Compound-data-type/Prolog/compound-data-type-3.pro
Normal file
1
Task/Compound-data-type/Prolog/compound-data-type-3.pro
Normal file
|
|
@ -0,0 +1 @@
|
|||
person_location(person(name(N), age(A)), point(X, Y)).
|
||||
4
Task/Compound-data-type/VBA/compound-data-type.vba
Normal file
4
Task/Compound-data-type/VBA/compound-data-type.vba
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Type point
|
||||
x As Integer
|
||||
y As Integer
|
||||
End Type
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
Structure Simple_Point
|
||||
Structure Point
|
||||
Public X, Y As Integer
|
||||
End Structure
|
||||
|
|
|
|||
|
|
@ -1,22 +1,9 @@
|
|||
Structure Immutable_Point
|
||||
Private m_X As Integer
|
||||
Private m_Y As Integer
|
||||
Structure ImmutablePoint
|
||||
ReadOnly Property X As Integer
|
||||
ReadOnly Property Y As Integer
|
||||
|
||||
Public Sub New(ByVal x As Integer, ByVal y As Integer)
|
||||
m_X = x
|
||||
m_Y = y
|
||||
Public Sub New(x As Integer, y As Integer)
|
||||
Me.X = x
|
||||
Me.Y = y
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property X() As Integer
|
||||
Get
|
||||
Return m_X
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property Y() As Integer
|
||||
Get
|
||||
Return m_Y
|
||||
End Get
|
||||
End Property
|
||||
|
||||
End Structure
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue