comparison doc/disas_examples/arm.atpcs_arm.disas @ 499:fc614cb865c6

- doc and disasexample additions specific to non-trivial C++ aggregates as return values (incl. fixes to doc and additional LSB specific PPC32 section)
author Tassilo Philipp
date Mon, 04 Apr 2022 15:50:52 +0200
parents cb19b2fe2422
children
comparison
equal deleted inserted replaced
498:fd9ba3a6d348 499:fc614cb865c6
828 828
829 ; ... snip, removed code of ctor and copy ctor ... 829 ; ... snip, removed code of ctor and copy ctor ...
830 830
831 831
832 832
833 ; ---------- C++ trivial and non-trivial aggrs as return values ---------->
834 ;
835 ; struct Trivial { int a; };
836 ; struct NonTrivial { int a; NonTrivial() : a(0) {} NonTrivial(const NonTrivial& rhs) : a(rhs.a) { } };
837 ;
838 ; extern "C" {
839 ; struct Trivial f1() { return Trivial(); }
840 ; }
841 ;
842 ; struct NonTrivial f2() { return NonTrivial(); }
843 ;
844 ; extern "C" {
845 ; void f()
846 ; {
847 ; int a=1;
848 ; a += 123;
849 ; struct Trivial t = f1();
850 ; a -= 123;
851 ; struct NonTrivial n = f2();
852 ; a -= 12;
853 ; }
854 ; }
855
856
857
858 ; output from debian-6.0.8-armel w/ gcc 4.4.5
859
860 00000000 <f1>:
861 0: e52db004 push {fp}
862 4: e28db000 add fp, sp, #0
863 8: e3a03000 mov r3, #0
864 c: e1a00003 mov r0, r3
865 10: e28bd000 add sp, fp, #0
866 14: e8bd0800 pop {fp}
867 18: e12fff1e bx lr
868
869 0000001c <_Z2f2v>:
870 1c: e92d4830 push {r4, r5, fp, lr}
871 20: e28db00c add fp, sp, #12
872 24: e1a04000 mov r4, r0
873 28: e1a03004 mov r3, r4
874 2c: e1a00003 mov r0, r3
875 30: ebfffffe bl 0 ; ctor
876 34: e1a00004 mov r0, r4 ; ptr to retval space -> r0
877 38: e1a00004 mov r0, r4
878 3c: e24bd00c sub sp, fp, #12
879 40: e8bd4830 pop {r4, r5, fp, lr}
880 44: e12fff1e bx lr
881
882 00000048 <f>:
883 48: e92d4800 push {fp, lr} ;
884 4c: e28db004 add fp, sp, #4 ;
885 50: e24dd010 sub sp, sp, #16 ;
886 54: e3a03001 mov r3, #1 ;
887 58: e50b3008 str r3, [fp, #-8] ;
888 5c: e51b3008 ldr r3, [fp, #-8] ;
889 60: e283307b add r3, r3, #123 ;
890 64: e50b3008 str r3, [fp, #-8] ;
891 68: ebfffffe bl 0 <f1> ; call f1()
892 6c: e1a03000 mov r3, r0 ; retval via r0, as small struct
893 70: e50b300c str r3, [fp, #-12] ;
894 74: e51b3008 ldr r3, [fp, #-8] ;
895 78: e243307b sub r3, r3, #123 ;
896 7c: e50b3008 str r3, [fp, #-8] ;
897 80: e24b3010 sub r3, fp, #16 ; space to hold non-triv retval -> eax ...
898 84: e1a00003 mov r0, r3 ; ... as hidden first arg (r0)
899 88: ebfffffe bl 1c <_Z2f2v> ; call f2()
900 8c: e51b3008 ldr r3, [fp, #-8] ;
901 90: e243300c sub r3, r3, #12 ;
902 94: e50b3008 str r3, [fp, #-8] ;
903 98: e24bd004 sub sp, fp, #4 ;
904 9c: e8bd4800 pop {fp, lr} ;
905 a0: e12fff1e bx lr ;
906
907
908
833 ; vim: ft=asm68k 909 ; vim: ft=asm68k
834 910