User input/Text: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|REBOL}}: Remove vanity tags) |
(add program to arm assembly) |
||
Line 84: | Line 84: | ||
<lang APL>str←⍞ |
<lang APL>str←⍞ |
||
int←⎕</lang> |
int←⎕</lang> |
||
=={{header|ARM Assembly}}== |
|||
{{works with|as|Raspberry Pi}} |
|||
<lang ARM Assembly> |
|||
/* ARM assembly Raspberry PI */ |
|||
/* program inputText.s */ |
|||
/* Constantes */ |
|||
.equ BUFFERSIZE, 100 |
|||
.equ STDIN, 0 @ Linux input console |
|||
.equ STDOUT, 1 @ Linux output console |
|||
.equ EXIT, 1 @ Linux syscall |
|||
.equ READ, 3 @ Linux syscall |
|||
.equ WRITE, 4 @ Linux syscall |
|||
/* Initialized data */ |
|||
.data |
|||
szMessDeb: .asciz "Enter text : \n" |
|||
szCarriageReturn: .asciz "\n" |
|||
/* UnInitialized data */ |
|||
.bss |
|||
sBuffer: .skip BUFFERSIZE |
|||
/* code section */ |
|||
.text |
|||
.global main |
|||
main: /* entry of program */ |
|||
push {fp,lr} /* saves 2 registers */ |
|||
ldr r0,iAdrszMessDeb |
|||
bl affichageMess |
|||
mov r0,#STDIN @ Linux input console |
|||
ldr r1,iAdrsBuffer @ buffer address |
|||
mov r2,#BUFFERSIZE @ buffer size |
|||
mov r7, #READ @ request to read datas |
|||
swi 0 @ call system |
|||
ldr r1,iAdrsBuffer @ buffer address |
|||
mov r2,#0 @ end of string |
|||
strb r2,[r1,r0] @ store byte at the end of input string (r0 contains number of characters) |
|||
ldr r0,iAdrsBuffer @ buffer address |
|||
bl affichageMess |
|||
ldr r0,iAdrszCarriageReturn |
|||
bl affichageMess |
|||
100: /* standard end of the program */ |
|||
mov r0, #0 @ return code |
|||
pop {fp,lr} @restaur 2 registers |
|||
mov r7, #EXIT @ request to exit program |
|||
swi 0 @ perform the system call |
|||
iAdrszMessDeb: .int szMessDeb |
|||
iAdrsBuffer: .int sBuffer |
|||
iAdrszCarriageReturn: .int szCarriageReturn |
|||
/******************************************************************/ |
|||
/* display text with size calculation */ |
|||
/******************************************************************/ |
|||
/* r0 contains the address of the message */ |
|||
affichageMess: |
|||
push {fp,lr} /* save registres */ |
|||
push {r0,r1,r2,r7} /* save others 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" */ |
|||
swi #0 /* call systeme */ |
|||
pop {r0,r1,r2,r7} /* restaur others registers */ |
|||
pop {fp,lr} /* restaur des 2 registres */ |
|||
bx lr /* return */ |
|||
</lang> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |