September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -0,0 +1,71 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program strConcat.s */
|
||||
|
||||
/* Constantes */
|
||||
.equ STDOUT, 1 @ Linux output console
|
||||
.equ EXIT, 1 @ Linux syscall
|
||||
.equ WRITE, 4 @ Linux syscall
|
||||
/* Initialized data */
|
||||
.data
|
||||
szMessFinal: .asciz "The final string is \n"
|
||||
|
||||
szString: .asciz "Hello "
|
||||
szString1: .asciz " the world. \n"
|
||||
|
||||
/* UnInitialized data */
|
||||
.bss
|
||||
szFinalString: .skip 255
|
||||
|
||||
/* code section */
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
@ load string
|
||||
ldr r1,iAdrszString
|
||||
ldr r2,iAdrszFinalString
|
||||
mov r4,#0
|
||||
1:
|
||||
ldrb r0,[r1,r4] @ load byte of string
|
||||
strb r0,[r2,r4]
|
||||
cmp r0,#0 @ compar with zero ?
|
||||
addne r4,#1
|
||||
bne 1b
|
||||
ldr r1,iAdrszString1
|
||||
mov r3,#0
|
||||
2:
|
||||
ldrb r0,[r1,r3] @ load byte of string 1
|
||||
strb r0,[r2,r4]
|
||||
cmp r0,#0 @ compar with zero ?
|
||||
addne r4,#1
|
||||
addne r3,#1
|
||||
bne 2b
|
||||
mov r0,r2 @ display final string
|
||||
bl affichageMess
|
||||
100: @ standard end of the program */
|
||||
mov r0, #0 @ return code
|
||||
mov r7, #EXIT @ request to exit program
|
||||
svc 0 @ perform the system call
|
||||
iAdrszString: .int szString
|
||||
iAdrszString1: .int szString1
|
||||
iAdrszFinalString: .int szFinalString
|
||||
iAdrszMessFinal: .int szMessFinal
|
||||
|
||||
/******************************************************************/
|
||||
/* display text with size calculation */
|
||||
/******************************************************************/
|
||||
/* r0 contains the address of the message */
|
||||
affichageMess:
|
||||
push {r0,r1,r2,r7,lr} @ save registers
|
||||
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
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
text s, v;
|
||||
|
||||
s = "Hello";
|
||||
o_text(s);
|
||||
o_newline();
|
||||
v = cat(s, ", World!");
|
||||
o_text(v);
|
||||
o_newline();
|
||||
o_(s, "\n");
|
||||
v = s + ", World!";
|
||||
o_(v, "\n");
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
10 LET s$="Hello"
|
||||
20 LET s$=s$+" World!"
|
||||
30 PRINT s$
|
||||
100 LET S$="Hello"
|
||||
110 LET S$=S$&" world!"
|
||||
120 PRINT S$
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
10 LET s$="Hello"
|
||||
20 LET s$=s$+" World!"
|
||||
30 PRINT s$
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
program =
|
||||
[
|
||||
var s := "Hello".
|
||||
var s2 := s + " literal".
|
||||
public program()
|
||||
{
|
||||
var s := "Hello";
|
||||
var s2 := s + " literal";
|
||||
|
||||
console writeLine:s.
|
||||
console writeLine:s2.
|
||||
console readChar.
|
||||
].
|
||||
console.writeLine:s;
|
||||
console.writeLine:s2;
|
||||
console.readChar()
|
||||
}
|
||||
|
|
|
|||
22
Task/String-concatenation/Neko/string-concatenation.neko
Normal file
22
Task/String-concatenation/Neko/string-concatenation.neko
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
String concatenation, in Neko
|
||||
Tectonics:
|
||||
nekoc string-concatenation.neko
|
||||
neko string-concatenation [addon]
|
||||
*/
|
||||
|
||||
var arg = $loader.args[0]
|
||||
var addon
|
||||
if arg != null addon = $string(arg)
|
||||
|
||||
var s = "abc"
|
||||
$print("s: ", s, "\n")
|
||||
|
||||
var c = s + "def"
|
||||
$print("c: ", c, "\n")
|
||||
|
||||
if arg != null {
|
||||
c += addon
|
||||
$print("addon: ", addon, "\n")
|
||||
$print("c: ", c, "\n")
|
||||
}
|
||||
|
|
@ -2,5 +2,4 @@ let s = "hello"
|
|||
let s1 = s ^ " literal"
|
||||
let () =
|
||||
print_endline (s ^ " literal");
|
||||
(* or Printf.printf "%s literal\n" s; *)
|
||||
print_endline s1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue