Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
120
Task/String-prepend/ARM-Assembly/string-prepend.arm
Normal file
120
Task/String-prepend/ARM-Assembly/string-prepend.arm
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program preend.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 NBCARLIBEL, 45
|
||||
.equ BUFFERSIZE, 100
|
||||
/*******************************************/
|
||||
/* 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"
|
||||
szMessString: .asciz "British Museum.\n"
|
||||
szStringStart: .asciz "The rosetta stone is at "
|
||||
szMessErrSize: .asciz "Buffer error size too small.\n"
|
||||
|
||||
/*******************************************/
|
||||
/* UnInitialized data */
|
||||
/*******************************************/
|
||||
.bss
|
||||
sBuffer: .skip BUFFERSIZE
|
||||
.align 4
|
||||
|
||||
/*******************************************/
|
||||
/* code section */
|
||||
/*******************************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr r0,iAdrszMessDebutPgm
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrszMessString
|
||||
ldr r1,iAdrszStringStart
|
||||
ldr r2,iAdrsBuffer
|
||||
mov r3,#BUFFERSIZE
|
||||
bl prepend // preend string1 to string2
|
||||
cmp r0,#-1
|
||||
beq 100f
|
||||
ldr r0,iAdrszMessString
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrsBuffer
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrszMessFinOK
|
||||
bl affichageMess
|
||||
|
||||
100: @ standard end of the program
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc 0 @ perform system call
|
||||
iAdrszMessDebutPgm: .int szMessDebutPgm
|
||||
iAdrszMessFinOK: .int szMessFinOK
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
iAdrszMessString: .int szMessString
|
||||
iAdrszStringStart: .int szStringStart
|
||||
iAdrsBuffer: .int sBuffer
|
||||
|
||||
/**************************************************/
|
||||
/* preend two strings */
|
||||
/**************************************************/
|
||||
/* r0 contains the address of the string1 */
|
||||
/* r1 contains the address of the string2 */
|
||||
/* r2 contains buffer */
|
||||
/* r3 contains buffer size */
|
||||
prepend:
|
||||
push {r4-r6,fp,lr}
|
||||
mov r4,#0 // counter byte string 2
|
||||
mov r5,#0 // result byte counter
|
||||
1: // copy string 2 in result area
|
||||
ldrb r6,[r1,r4]
|
||||
cmp r6,#0
|
||||
beq 2f
|
||||
strb r6,[r2,r5]
|
||||
add r4,r4,#1 // increment indice
|
||||
add r5,r5,#1 // increment indice
|
||||
cmp r5,r3
|
||||
bge 99f // error size
|
||||
|
||||
b 1b // and loop
|
||||
2:
|
||||
mov r4,#0 // counter byte string1
|
||||
3:
|
||||
ldrb r6,[r0,r4]
|
||||
strb r6,[r2,r5]
|
||||
cmp r6,#0
|
||||
beq 4f
|
||||
add r4,r4,#1 // increment indice
|
||||
add r5,r5,#1 // increment indice
|
||||
cmp r5,r3
|
||||
bge 99f // error size
|
||||
b 3b // and loop
|
||||
4:
|
||||
mov r0,r5
|
||||
b 100f
|
||||
99:
|
||||
ldr r0,iAdrszMessErrSize
|
||||
bl affichageMess
|
||||
mov r0,#-1 // error
|
||||
100:
|
||||
pop {r4-r6,fp,pc}
|
||||
iAdrszMessErrSize: .int szMessErrSize
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
.include "../affichage.inc"
|
||||
8
Task/String-prepend/Ada/string-prepend.adb
Normal file
8
Task/String-prepend/Ada/string-prepend.adb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
with Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
|
||||
|
||||
procedure Prepend_String is
|
||||
S: Unbounded_String := To_Unbounded_String("World!");
|
||||
begin
|
||||
S := "Hello " & S;-- this is the operation to prepend "Hello " to S.
|
||||
Ada.Text_IO.Put_Line(To_String(S));
|
||||
end Prepend_String;
|
||||
25
Task/String-prepend/COBOL/string-prepend-1.cob
Normal file
25
Task/String-prepend/COBOL/string-prepend-1.cob
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
identification division.
|
||||
program-id. prepend.
|
||||
data division.
|
||||
working-storage section.
|
||||
1 str pic x(30) value "World!".
|
||||
1 binary.
|
||||
2 len pic 9(4) value 0.
|
||||
2 scratch pic 9(4) value 0.
|
||||
procedure division.
|
||||
begin.
|
||||
perform rev-sub-str
|
||||
move function reverse ("Hello ") to str (len + 1:)
|
||||
perform rev-sub-str
|
||||
display str
|
||||
stop run
|
||||
.
|
||||
|
||||
rev-sub-str.
|
||||
move 0 to len scratch
|
||||
inspect function reverse (str)
|
||||
tallying scratch for leading spaces
|
||||
len for characters after space
|
||||
move function reverse (str (1:len)) to str
|
||||
.
|
||||
end program prepend.
|
||||
12
Task/String-prepend/COBOL/string-prepend-2.cob
Normal file
12
Task/String-prepend/COBOL/string-prepend-2.cob
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
>>SOURCE FREE
|
||||
PROGRAM-ID. prepend.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 str PIC X(30) VALUE "world!".
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
MOVE FUNCTION CONCATENATE("Hello, ", str) TO str
|
||||
DISPLAY str
|
||||
.
|
||||
END PROGRAM prepend.
|
||||
3
Task/String-prepend/Emacs-Lisp/string-prepend-1.el
Normal file
3
Task/String-prepend/Emacs-Lisp/string-prepend-1.el
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(defvar str "bar")
|
||||
(setq str (concat "foo" str))
|
||||
str ;=> "foobar"
|
||||
5
Task/String-prepend/Emacs-Lisp/string-prepend-2.el
Normal file
5
Task/String-prepend/Emacs-Lisp/string-prepend-2.el
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(require 'cl-lib)
|
||||
|
||||
(defvar str "bar")
|
||||
(cl-callf2 concat "foo" str)
|
||||
str ;=> "foobar"
|
||||
8
Task/String-prepend/Emacs-Lisp/string-prepend-3.el
Normal file
8
Task/String-prepend/Emacs-Lisp/string-prepend-3.el
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(let ((buf (get-buffer-create "*foo*")))
|
||||
(with-current-buffer buf
|
||||
(insert "bar"))
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-min))
|
||||
(insert "foo")
|
||||
(buffer-string)))
|
||||
;; => "foobar"
|
||||
2
Task/String-prepend/Gleam/string-prepend.gleam
Normal file
2
Task/String-prepend/Gleam/string-prepend.gleam
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let s = "world"
|
||||
"Hello " <> s
|
||||
3
Task/String-prepend/Pluto/string-prepend.pluto
Normal file
3
Task/String-prepend/Pluto/string-prepend.pluto
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
local s = "Code"
|
||||
s = "Rosetta " .. s
|
||||
print(s)
|
||||
3
Task/String-prepend/PowerShell/string-prepend.ps1
Normal file
3
Task/String-prepend/PowerShell/string-prepend.ps1
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$str = "World!"
|
||||
$str = "Hello, " + $str
|
||||
$str
|
||||
114
Task/String-prepend/RISC-V-Assembly/string-prepend.asm
Normal file
114
Task/String-prepend/RISC-V-Assembly/string-prepend.asm
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
# riscv assembly raspberry pico2 rp2350
|
||||
# program preendstring.s
|
||||
# connexion putty com3
|
||||
/*********************************************/
|
||||
/* CONSTANTES */
|
||||
/********************************************/
|
||||
/* for this file see risc-v task include a file */
|
||||
.include "../../constantesRiscv.inc"
|
||||
.equ BUFFERSIZE, 100
|
||||
/*******************************************/
|
||||
/* INITIALED DATAS */
|
||||
/*******************************************/
|
||||
.data
|
||||
szMessStart: .asciz "Program riscv start.\r\n"
|
||||
szMessEndOk: .asciz "Program riscv end OK.\r\n"
|
||||
szCariageReturn: .asciz "\r\n"
|
||||
|
||||
szMessErrorString: .asciz "Error buffer size."
|
||||
szString: .asciz "British Museum."
|
||||
szStringPreend: .asciz "The rosetta stone is at "
|
||||
|
||||
.align 2
|
||||
/*******************************************/
|
||||
/* UNINITIALED DATA */
|
||||
/*******************************************/
|
||||
.bss
|
||||
sBuffer: .skip BUFFERSIZE
|
||||
.align 2
|
||||
|
||||
/**********************************************/
|
||||
/* SECTION CODE */
|
||||
/**********************************************/
|
||||
.text
|
||||
.global main
|
||||
|
||||
main:
|
||||
call stdio_init_all # général init
|
||||
1: # start loop connexion
|
||||
li a0,0 # raz argument register
|
||||
call tud_cdc_n_connected # waiting for USB connection
|
||||
beqz a0,1b # return code = zero ?
|
||||
|
||||
la a0,szMessStart # message address
|
||||
call writeString # display message
|
||||
|
||||
la a0,szString
|
||||
call writeString # display message
|
||||
la a0,szCariageReturn
|
||||
call writeString
|
||||
|
||||
la a0,szString # address string 1
|
||||
la a1,szStringPreend # address string 2
|
||||
la a2,sBuffer # result buffer
|
||||
li a3,BUFFERSIZE
|
||||
call preendString #
|
||||
|
||||
la a0,sBuffer # result buffer
|
||||
call writeString # display message
|
||||
la a0,szCariageReturn
|
||||
call writeString
|
||||
|
||||
la a0,szMessEndOk # message address
|
||||
call writeString # display message
|
||||
call getchar
|
||||
100: # final loop
|
||||
j 100b
|
||||
/***************************************************/
|
||||
/* search string at beguining */
|
||||
/***************************************************/
|
||||
# a0 contains string
|
||||
# a1 contains search string
|
||||
# a0 returns 1 if find or 0 if not or -1 if error
|
||||
preendString:
|
||||
addi sp, sp, -4 # reserve stack
|
||||
sw ra, 0(sp) # save registers @ save registers
|
||||
li t1,0 # init counter
|
||||
li t2,0
|
||||
1: # copy string2 to result
|
||||
add t0,a1,t1 # compute byte address
|
||||
lbu t3,(t0) # load byte string
|
||||
beqz t3,2f # zero final
|
||||
add t0,a2,t1 # compute byte address result
|
||||
sb t3,(t0) # store byte
|
||||
addi t1,t1,1
|
||||
bge t1,a3,99f
|
||||
j 1b
|
||||
2: # copy string 1 to result
|
||||
add t0,a0,t2 # compute byte address
|
||||
lbu t3,(t0) # load byte string
|
||||
add t0,a2,t1 # compute byte address result
|
||||
sb t3,(t0) # store byte
|
||||
beqz t3,3f # zero final
|
||||
addi t2,t2,1
|
||||
addi t1,t1,1
|
||||
bge t1,a3,99f
|
||||
j 2b
|
||||
3:
|
||||
mv a0,t1 # return total length
|
||||
j 100f
|
||||
|
||||
99: # error
|
||||
la a0,szMessErrorString
|
||||
call writeString # display message
|
||||
li a0,-1 # error
|
||||
100:
|
||||
lw ra, 0(sp)
|
||||
addi sp, sp, 4
|
||||
ret
|
||||
|
||||
/************************************/
|
||||
/* file include Fonctions */
|
||||
/***********************************/
|
||||
/* for this file see risc-v task include a file */
|
||||
.include "../../includeFunctions.s"
|
||||
3
Task/String-prepend/VBScript/string-prepend.vbs
Normal file
3
Task/String-prepend/VBScript/string-prepend.vbs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s = "bar"
|
||||
s = "foo" & s
|
||||
WScript.Echo s
|
||||
Loading…
Add table
Add a link
Reference in a new issue