Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- .global main
- // r5 - capasity
- // r6 - ptr
- // r7 - size
- main:
- push {r5, r6, r7, lr}
- mov r5, #1
- mov r7, #0
- mov r6, #0
- b reallocation
- input:
- ldr r0, stdin_ptr
- ldr r0, [r0]
- bl fgetc
- cmp r0, #-1
- beq output
- strb r0, [r6, r7]
- add r7, #1
- cmp r7, r5
- blt input
- add r5, r5
- b reallocation
- reallocation:
- mov r0, r6
- mov r1, r5
- bl realloc
- mov r6, r0
- b input
- output:
- sub r7, #1
- ldrb r0, [r6, r7]
- ldr r1, stdout_ptr
- ldr r1, [r1]
- bl fputc
- cmp r7, #0
- bgt output
- b end_main
- end_main:
- mov r0, r6
- bl free
- pop {r5, r6, r7, lr}
- bx lr
- stdin_ptr:
- .word stdin
- stdout_ptr:
- .word stdout
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement