this code, which is for the mergeChar function in
/changearray/ifstructures/loopbyFour/example1_2_9f.c
https://github.com/bshambaugh/changearray/blob/master/ifstructures/loopbyFour/mergeCharsFuncation/codingUnit_com/test_final/Copy5useCallocMult4.c
https://www.geeksforgeeks.org/how-to-return-multiple-values-from-a-function-in-c-or-cpp/
Try with function:
http://vertstudios.com/blog/malloc-functions-returning-pointers/
https://overiq.com/c-programming-101/array-of-strings-in-c/
----------------------------
edit:
C Pointer Tutorial
https://www.youtube.com/watch?v=IkyWCOUY8V4
(includes mention of how to pass pointer to function)
----------------------------------------------------------------------------------------
https://www.eskimo.com/~scs/cclass/int/sx9b.html
http://phyweb.physics.nus.edu.sg/~phywjs/CZ1102/lecture20/tsld014.htm
https://stackoverflow.com/questions/1733881/c-correctly-freeing-memory-of-a-multi-dimensional-array
https://joequery.me/notes/double-pointers-c/
--------------
https://www.recurse.com/blog/7-understanding-c-by-learning-assembly [Understanding C by learning assembly]
http://cs.ecs.baylor.edu/~donahoo/tools/valgrind/messages.html [Excerpt from Valgrind documentation]
https://valgrind.org/docs/manual/quick-start.html [The Valgrind Quick Start Guide]
Dump of assembler code for function main:
0x00005555555547f2 <+0>: push %rbp
0x00005555555547f3 <+1>: mov %rsp,%rbp
=> 0x00005555555547f6 <+4>: mov $0x1,%edi
0x00005555555547fb <+9>: callq 0x555555554660 <malloc@plt>
0x0000555555554800 <+14>: mov %rax,0x200821(%rip) # 0x555555755028 <A>
0x0000555555554807 <+21>: mov $0x1,%edi
0x000055555555480c <+26>: callq 0x555555554660 <malloc@plt>
0x0000555555554811 <+31>: mov %rax,0x200800(%rip) # 0x555555755018 <B>
0x0000555555554818 <+38>: mov 0x200809(%rip),%rax # 0x555555755028 <A>
0x000055555555481f <+45>: movb $0x62,(%rax)
0x0000555555554822 <+48>: mov 0x2007ef(%rip),%rax # 0x555555755018 <B>
0x0000555555554829 <+55>: movb $0x61,(%rax)
0x000055555555482c <+58>: mov 0x2007f5(%rip),%rax # 0x555555755028 <A>
0x0000555555554833 <+65>: mov %rax,%rsi
0x0000555555554836 <+68>: lea 0x1c4(%rip),%rdi # 0x555555554a01
0x000055555555483d <+75>: mov $0x0,%eax
0x0000555555554842 <+80>: callq 0x555555554650 <printf@plt>
0x0000555555554847 <+85>: mov 0x2007ca(%rip),%rax # 0x555555755018 <B>
0x000055555555484e <+92>: mov %rax,%rsi
0x0000555555554851 <+95>: lea 0x1bd(%rip),%rdi # 0x555555554a15
0x0000555555554858 <+102>: mov $0x0,%eax
0x000055555555485d <+107>: callq 0x555555554650 <printf@plt>
0x0000555555554862 <+112>: mov 0x2007bf(%rip),%rax # 0x555555755028 <A>
0x0000555555554869 <+119>: movzbl (%rax),%eax
0x000055555555486c <+122>: mov %al,0x2007ae(%rip) # 0x555555755020 <words>
0x0000555555554872 <+128>: movb $0x0,0x2007a8(%rip) # 0x555555755021 <words+1>
0x0000555555554879 <+135>: mov 0x200798(%rip),%rax # 0x555555755018 <B>
0x0000555555554880 <+142>: movzbl (%rax),%eax
0x0000555555554883 <+145>: mov %al,0x200799(%rip) # 0x555555755022
0x0000555555554889 <+151>: movb $0x0,0x200793(%rip) # 0x555555755023
0x0000555555554890 <+158>: lea 0x192(%rip),%rdi # 0x555555554a29
0x0000555555554897 <+165>: callq 0x555555554630 <puts@plt>
0x000055555555489c <+170>: lea 0x20077d(%rip),%rsi # 0x555555755020 <words>
0x00005555555548a3 <+177>: lea 0x19d(%rip),%rdi # 0x555555554a47
0x00005555555548aa <+184>: mov $0x0,%eax
0x00005555555548af <+189>: callq 0x555555554650 <printf@plt>
0x00005555555548b4 <+194>: lea 0x200767(%rip),%rsi # 0x555555755022
0x00005555555548bb <+201>: lea 0x19e(%rip),%rdi # 0x555555554a60
0x00005555555548c2 <+208>: mov $0x0,%eax
0x00005555555548c7 <+213>: callq 0x555555554650 <printf@plt>
0x00005555555548cc <+218>: mov 0x200745(%rip),%rax # 0x555555755018 <B>
0x00005555555548d3 <+225>: movzbl (%rax),%eax
0x00005555555548d6 <+228>: movsbl %al,%edx
0x00005555555548d9 <+231>: mov 0x200748(%rip),%rax # 0x555555755028 <A>
0x00005555555548e0 <+238>: movzbl (%rax),%eax
0x00005555555548e3 <+241>: movsbl %al,%eax
0x00005555555548e6 <+244>: mov %edx,%esi
0x00005555555548e8 <+246>: mov %eax,%edi
0x00005555555548ea <+248>: callq 0x55555555478a <mergeChars>
0x00005555555548ef <+253>: mov 0x200732(%rip),%rax # 0x555555755028 <A>
0x00005555555548f6 <+260>: mov %rax,%rdi
0x00005555555548f9 <+263>: callq 0x555555554620 <free@plt>
0x00005555555548fe <+268>: mov 0x200713(%rip),%rax # 0x555555755018 <B>
0x0000555555554905 <+275>: mov %rax,%rdi
0x0000555555554908 <+278>: callq 0x555555554620 <free@plt>
0x000055555555490d <+283>: lea 0x165(%rip),%rdi # 0x555555554a79
0x0000555555554914 <+290>: callq 0x555555554630 <puts@plt>
0x0000555555554919 <+295>: lea 0x200700(%rip),%rsi # 0x555555755020 <words>
0x0000555555554920 <+302>: lea 0x120(%rip),%rdi # 0x555555554a47
0x0000555555554927 <+309>: mov $0x0,%eax
0x000055555555492c <+314>: callq 0x555555554650 <printf@plt>
0x0000555555554931 <+319>: lea 0x2006ea(%rip),%rsi # 0x555555755022
0x0000555555554938 <+326>: lea 0x121(%rip),%rdi # 0x555555554a60
0x000055555555493f <+333>: mov $0x0,%eax
0x0000555555554944 <+338>: callq 0x555555554650 <printf@plt>
0x0000555555554949 <+343>: lea 0x143(%rip),%rdi # 0x555555554a93
0x0000555555554950 <+350>: callq 0x555555554630 <puts@plt>
0x0000555555554955 <+355>: mov $0x0,%eax
0x000055555555495a <+360>: pop %rbp
0x000055555555495b <+361>: retq
End of assembler dump.
No comments:
Post a Comment