String append: Difference between revisions

Add task to ARM assembly Raspberry pi
(Add Neko)
(Add task to ARM assembly Raspberry pi)
Line 47:
123456789!
</pre>
 
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi}}
<lang ARM Assembly>
 
/* 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
 
</lang>
 
=={{header|AutoHotkey}}==