Created
July 16, 2015 22:59
-
-
Save hikilaka/874a9497104c76cfc016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* array03.s.arm */ | |
.data | |
.balign 4 // array of 100 integers (4 bytes each) | |
a: .skip 400 | |
.balign 4 // struct of 1 char and 1 integer | |
s: .skip 8 // 8 bytes in total for padding (4-byte aligned) | |
.text | |
.global main | |
// r0 = step | |
// r1 = addr | |
main: | |
mov r0, #0 // step = 0 | |
ldr r1, addr_a // addr = &a | |
loop: | |
cmp r0, #100 // if step == 100 | |
beq end // branch to end | |
str r0, [r1, +r0, LSL #2] // *(addr + (step << 2)) = step | |
add r0, #1 // step += 1 | |
b loop | |
end: | |
bx lr // exit | |
addr_a: .word a | |
addr_s: .word s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a[100]; | |
struct si // not used, but included in ARM asm version | |
{ | |
char a; | |
int b; | |
}; | |
int main() | |
{ | |
int step; | |
for (step = 0; step < 100; step++) | |
{ | |
*(a + step) = step; | |
} | |
return step; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.arch armv6 | |
.eabi_attribute 27, 3 | |
.eabi_attribute 28, 1 | |
.fpu vfp | |
.eabi_attribute 20, 1 | |
.eabi_attribute 21, 1 | |
.eabi_attribute 23, 3 | |
.eabi_attribute 24, 1 | |
.eabi_attribute 25, 1 | |
.eabi_attribute 26, 2 | |
.eabi_attribute 30, 6 | |
.eabi_attribute 34, 1 | |
.eabi_attribute 18, 4 | |
.file "test.c" | |
.comm a,400,4 | |
.text | |
.align 2 | |
.global main | |
.type main, %function | |
main: | |
@ args = 0, pretend = 0, frame = 8 | |
@ frame_needed = 1, uses_anonymous_args = 0 | |
@ link register save eliminated. | |
str fp, [sp, #-4]! | |
add fp, sp, #0 | |
sub sp, sp, #12 | |
mov r3, #0 | |
str r3, [fp, #-8] | |
b .L2 | |
.L3: | |
ldr r3, [fp, #-8] | |
mov r2, r3, asl #2 | |
ldr r3, .L5 | |
add r3, r2, r3 | |
ldr r2, [fp, #-8] | |
str r2, [r3, #0] | |
ldr r3, [fp, #-8] | |
add r3, r3, #1 | |
str r3, [fp, #-8] | |
.L2: | |
ldr r3, [fp, #-8] | |
cmp r3, #99 | |
ble .L3 | |
ldr r3, [fp, #-8] | |
mov r0, r3 | |
add sp, fp, #0 | |
ldmfd sp!, {fp} | |
bx lr | |
.L6: | |
.align 2 | |
.L5: | |
.word a | |
.size main, .-main | |
.ident "GCC: (Debian 4.7.2-5+rpi1) 4.7.2" | |
.section .note.GNU-stack,"",%progbits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment