Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualTzarls

Posted 12 November 2012 - 12:31 AM

Ok. I made this little program:

#include <iostream>
void receivesFloat (float f)
{
	std::cout << "Received " << f <<".\n";
}
void receivesInt(int i)
{
	std::cout <<"Received " << i <<".\n";
}
float returnsFloat(void)
{
	return 17.65f;
}
int returnsInt(void)
{
	return 7;
}
int main()
{
	receivesFloat(3.14);
	receivesInt(1138);
	std::cout << "Funcion returned " << returnsFloat() <<".\n";
	std::cout << "Funcion returned " << returnsInt() <<".\n";
	return 0;
}

Placed some breakpoints in main() and in every one of the functions to get the disassembly - is that correct? I got this:

main:


0x8738 push {r3, r4, r11, lr}
0x873c add r11, sp, #12
0x8740 vldr s0, [pc, #132] ; 0x87cc <main()+148>
0x8744 bl 0x8658 <receivesFloat(float)>
0x8748 ldr r0, [pc, #128] ; 0x87d0 <main()+152>
0x874c bl 0x86a8 <receivesInt(int)>
0x8750 ldr r0, [pc, #124] ; 0x87d4 <main()+156>
0x8754 ldr r1, [pc, #124] ; 0x87d8 <main()+160>
0x8758 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x875c mov r3, r0
0x8760 mov r4, r3
0x8764 bl 0x86f8 <returnsFloat()>
0x8768 vmov.f32 s15, s0
0x876c mov r0, r4
0x8770 vmov.f32 s0, s15
0x8774 bl 0x85a0 <std::ostream::operator<<(float)>
0x8778 mov r3, r0
0x877c mov r0, r3
0x8780 ldr r1, [pc, #84] ; 0x87dc <main()+164>
0x8784 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8788 ldr r0, [pc, #68] ; 0x87d4 <main()+156>
0x878c ldr r1, [pc, #68] ; 0x87d8 <main()+160>
0x8790 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8794 mov r3, r0
0x8798 mov r4, r3
0x879c bl 0x871c <returnsInt()>
0x87a0 mov r3, r0
0x87a4 mov r0, r4
0x87a8 mov r1, r3
0x87ac bl 0x8540 <std::ostream::operator<<(int)>
0x87b0 mov r3, r0
0x87b4 mov r0, r3
0x87b8 ldr r1, [pc, #28] ; 0x87dc <main()+164>
0x87bc bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x87c0 mov r3, #0
0x87c4 mov r0, r3
0x87c8 pop {r3, r4, r11, pc}
0x87cc submi pc, r8, r3, asr #11
0x87d0 andeq r0, r0, r2, ror r4
0x87d4 andeq r0, r1, r0, lsr #21
0x87d8 andeq r8, r0, r0, ror #17
0x87dc ldrdeq r8, [r0], -r12

receivesFloat:


0x8658 push {r11, lr}
0x865c add r11, sp, #4
0x8660 sub sp, sp, #8
0x8664 vstr s0, [r11, #-8]
0x8668 ldr r0, [pc, #44] ; 0x869c <receivesFloat(float)+68>
0x866c ldr r1, [pc, #44] ; 0x86a0 <receivesFloat(float)+72>
0x8670 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8674 mov r3, r0
0x8678 mov r0, r3
0x867c vldr s0, [r11, #-8]
0x8680 bl 0x85a0 <std::ostream::operator<<(float)>
0x8684 mov r3, r0
0x8688 mov r0, r3
0x868c ldr r1, [pc, #16] ; 0x86a4 <receivesFloat(float)+76>
0x8690 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8694 sub sp, r11, #4
0x8698 pop {r11, pc}
0x869c andeq r0, r1, r0, lsr #21
0x86a0 ldrdeq r8, [r0], -r0
0x86a4 ldrdeq r8, [r0], -r12

receivesInt:


0x86a8 push {r11, lr}
0x86ac add r11, sp, #4
0x86b0 sub sp, sp, #8
0x86b4 str r0, [r11, #-8]
0x86b8 ldr r0, [pc, #44] ; 0x86ec <receivesInt(int)+68>
0x86bc ldr r1, [pc, #44] ; 0x86f0 <receivesInt(int)+72>
0x86c0 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x86c4 mov r3, r0
0x86c8 mov r0, r3
0x86cc ldr r1, [r11, #-8]
0x86d0 bl 0x8540 <std::ostream::operator<<(int)>
0x86d4 mov r3, r0
0x86d8 mov r0, r3
0x86dc ldr r1, [pc, #16] ; 0x86f4 <receivesInt(int)+76>
0x86e0 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x86e4 sub sp, r11, #4
0x86e8 pop {r11, pc}
0x86ec andeq r0, r1, r0, lsr #21
0x86f0 ldrdeq r8, [r0], -r0
0x86f4 ldrdeq r8, [r0], -r12

returnsFloat:


0x86f8 push {r11}  ; (str r11, [sp, #-4]!)
0x86fc add r11, sp, #0
0x8700 ldr r3, [pc, #16] ; 0x8718 <returnsFloat()+32>
0x8704 vmov s15, r3
0x8708 vmov.f32 s0, s15
0x870c add sp, r11, #0
0x8710 pop {r11}
0x8714 bx lr
0x8718 orrmi r3, sp, r3, lsr r3

returnsInt:


0x871c push {r11}  ; (str r11, [sp, #-4]!)
0x8720 add r11, sp, #0
0x8724 mov r3, #7
0x8728 mov r0, r3
0x872c add sp, r11, #0
0x8730 pop {r11}
0x8734 bx lr

Let me know if this is right and if I can do anything else to help.

#1Tzarls

Posted 12 November 2012 - 12:29 AM

Ok. I made this little program:

#include <iostream>
void receivesFloat (float f)
{
    std::cout << "Received " << f <<".\n";
}
void receivesInt(int i)
{
    std::cout <<"Received " << i <<".\n";
}
float returnsFloat(void)
{
    return 17.65f;
}
int returnsInt(void)
{
    return 7;
}
int main()
{
    receivesFloat(3.14);
    receivesInt(1138);
    std::cout << "Funcion returned " << returnsFloat() <<".\n";
    std::cout << "Funcion returned " << returnsInt() <<".\n";
    return 0;
}

Placed some breakpoints in main() and in every one of the functions to get the disassembly - is that correct? I got this:

main:


0x8738 push {r3, r4, r11, lr}
0x873c add r11, sp, #12
0x8740 vldr s0, [pc, #132] ; 0x87cc <main()+148>
0x8744 bl 0x8658 <receivesFloat(float)>
0x8748 ldr r0, [pc, #128] ; 0x87d0 <main()+152>
0x874c bl 0x86a8 <receivesInt(int)>
0x8750 ldr r0, [pc, #124] ; 0x87d4 <main()+156>
0x8754 ldr r1, [pc, #124] ; 0x87d8 <main()+160>
0x8758 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x875c mov r3, r0
0x8760 mov r4, r3
0x8764 bl 0x86f8 <returnsFloat()>
0x8768 vmov.f32 s15, s0
0x876c mov r0, r4
0x8770 vmov.f32 s0, s15
0x8774 bl 0x85a0 <std::ostream::operator<<(float)>
0x8778 mov r3, r0
0x877c mov r0, r3
0x8780 ldr r1, [pc, #84] ; 0x87dc <main()+164>
0x8784 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8788 ldr r0, [pc, #68] ; 0x87d4 <main()+156>
0x878c ldr r1, [pc, #68] ; 0x87d8 <main()+160>
0x8790 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8794 mov r3, r0
0x8798 mov r4, r3
0x879c bl 0x871c <returnsInt()>
0x87a0 mov r3, r0
0x87a4 mov r0, r4
0x87a8 mov r1, r3
0x87ac bl 0x8540 <std::ostream::operator<<(int)>
0x87b0 mov r3, r0
0x87b4 mov r0, r3
0x87b8 ldr r1, [pc, #28] ; 0x87dc <main()+164>
0x87bc bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x87c0 mov r3, #0
0x87c4 mov r0, r3
0x87c8 pop {r3, r4, r11, pc}
0x87cc submi pc, r8, r3, asr #11
0x87d0 andeq r0, r0, r2, ror r4
0x87d4 andeq r0, r1, r0, lsr #21
0x87d8 andeq r8, r0, r0, ror #17
0x87dc ldrdeq r8, [r0], -r12

receivesFloat:


0x8658 push {r11, lr}
0x865c add r11, sp, #4
0x8660 sub sp, sp, #8
0x8664 vstr s0, [r11, #-8]
0x8668 ldr r0, [pc, #44] ; 0x869c <receivesFloat(float)+68>
0x866c ldr r1, [pc, #44] ; 0x86a0 <receivesFloat(float)+72>
0x8670 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8674 mov r3, r0
0x8678 mov r0, r3
0x867c vldr s0, [r11, #-8]
0x8680 bl 0x85a0 <std::ostream::operator<<(float)>
0x8684 mov r3, r0
0x8688 mov r0, r3
0x868c ldr r1, [pc, #16] ; 0x86a4 <receivesFloat(float)+76>
0x8690 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x8694 sub sp, r11, #4
0x8698 pop {r11, pc}
0x869c andeq r0, r1, r0, lsr #21
0x86a0 ldrdeq r8, [r0], -r0
0x86a4 ldrdeq r8, [r0], -r12

receivesInt:


0x86a8 push {r11, lr}
0x86ac add r11, sp, #4
0x86b0 sub sp, sp, #8
0x86b4 str r0, [r11, #-8]
0x86b8 ldr r0, [pc, #44] ; 0x86ec <receivesInt(int)+68>
0x86bc ldr r1, [pc, #44] ; 0x86f0 <receivesInt(int)+72>
0x86c0 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x86c4 mov r3, r0
0x86c8 mov r0, r3
0x86cc ldr r1, [r11, #-8]
0x86d0 bl 0x8540 <std::ostream::operator<<(int)>
0x86d4 mov r3, r0
0x86d8 mov r0, r3
0x86dc ldr r1, [pc, #16] ; 0x86f4 <receivesInt(int)+76>
0x86e0 bl 0x8588 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
0x86e4 sub sp, r11, #4
0x86e8 pop {r11, pc}
0x86ec andeq r0, r1, r0, lsr #21
0x86f0 ldrdeq r8, [r0], -r0
0x86f4 ldrdeq r8, [r0], -r12

returnsFloat:


0x86f8 push {r11}  ; (str r11, [sp, #-4]!)
0x86fc add r11, sp, #0
0x8700 ldr r3, [pc, #16] ; 0x8718 <returnsFloat()+32>
0x8704 vmov s15, r3
0x8708 vmov.f32 s0, s15
0x870c add sp, r11, #0
0x8710 pop {r11}
0x8714 bx lr
0x8718 orrmi r3, sp, r3, lsr r3

returnsInt:


0x871c push {r11}  ; (str r11, [sp, #-4]!)
0x8720 add r11, sp, #0
0x8724 mov r3, #7
0x8728 mov r0, r3
0x872c add sp, r11, #0
0x8730 pop {r11}
0x8734 bx lr

Let me know if this is right and if you need anything else.

PARTNERS