Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void foo(unsigned int x) {
- *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&x);
- }
- int main() {
- foo(1);
- while(1);
- }
- .align 2
- .global foo
- .type foo, %function
- foo:
- @ Function supports interworking.
- @ args = 0, pretend = 0, frame = 8
- @ frame_needed = 0, uses_anonymous_args = 0
- @ link register save eliminated.
- sub sp, sp, #8
- str r0, [sp, #4] @ 3. Store the argument on the stack
- mov r3, #67108864
- add r3, r3, #212
- add r2, sp, #4 @ 4. Address of the stack variable
- str r2, [r3, #0] @ 5. Store the address at 0x40000d4
- add sp, sp, #8
- bx lr
- .size foo, .-foo
- .align 2
- .global main
- .type main, %function
- main:
- @ Function supports interworking.
- @ args = 0, pretend = 0, frame = 0
- @ frame_needed = 0, uses_anonymous_args = 0
- stmfd sp!, {r4, lr}
- mov r0, #1 @ 1. Pass the argument in register 0
- bl foo @ 2. Call function foo
- .L4:
- b .L4
- .size main, .-main
- .ident "GCC: (GNU) 4.4.0 20080820 (experimental)"
- .align 2
- .global foo
- .type foo, %function
- foo:
- @ Function supports interworking.
- @ args = 0, pretend = 0, frame = 8
- @ frame_needed = 0, uses_anonymous_args = 0
- @ link register save eliminated.
- sub sp, sp, #8
- mov r2, #67108864
- add r3, sp, #4 @ 3. Address of *something* on the stack
- str r3, [r2, #212] @ 4. Store the address at 0x40000d4
- add sp, sp, #8
- bx lr
- .size foo, .-foo
- .align 2
- .global main
- .type main, %function
- main:
- @ Function supports interworking.
- @ args = 0, pretend = 0, frame = 0
- @ frame_needed = 0, uses_anonymous_args = 0
- stmfd sp!, {r4, lr}
- mov r0, #1 @ 1. Pass the argument in register 0
- bl foo @ 2. Call function foo
- .L4:
- b .L4
- .size main, .-main
- .ident "GCC: (GNU) 4.4.0 20080820 (experimental)"
- void foo(unsigned int x) {
- volatile unsigned int* ptr = (unsigned int*)(0x4000000 + 0xd4);
- *ptr = (unsigned int)(&x);
- }
- int main() {
- foo(1);
- while(1);
- }
- void foo(unsigned int *x) {
- volatile unsigned int* ptr = (unsigned int*)(0x4000000 + 0xd4);
- *ptr = (unsigned int)(x);
- }
- int main() {
- int x = 1;
- foo(&x);
- while(1);
- }
- void foo(unsigned int x) {
- volatile int y = x;
- *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&y);
- }
- void foo(unsigned int x)
- {
- volatile unsigned int* pArg = &x;
- *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)pArg;
- }
- void foo(unsigned int x)
- {
- volatile unsigned int* pArg = &x;
- *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)pArg;
- }
- *(volatile unsigned int *)0x12345 = someuintvariable;
- *(volatile unsigned int *)0x12345 = 0x12;
- .globl PUT32
- PUT32:
- str r1,[r0]
- bx lr
- PUT32(0x12345,0x12);
- // Warning: untested code.
- void foo(unsigned int x) {
- static volatile unsigned int color = x; // "static" so it's not on the stack
- volatile unsigned int** dma_register =
- (volatile unsigned int**)(0x4000000 + 0xd4);
- *dma_register = &color;
- }
- int main() {
- foo(1);
- while(1);
- }
Add Comment
Please, Sign In to add comment