Complete the following code segment which does a memory compare between a and b. The memory compare must be done in a function called memcmp, which is called from the main function. The following must be done:
- Set up proper stack frame including frame macro for both main and memcmp functions
- a and b must be passed by register from main to memcmp function
- memory compare occurs from left to right.
- The difference between the first non-equal values must be passed back to main through appropriate register.
- If the strings are equal, -1 must be returned in RAX.
- Appropriate string compare opcode must be used.
segment .data
a db "Final Exam!"
b db "Final Exan!"
segment .text
global main ; Tell linker about main
global memcmp
memcmp:
frame 2,0,2 ;set up the frame macro
sub rsp, frame_size
main:
frame ;set up the frame macro
sub rsp, frame_size
This is all that I have so far, I am a bit stuck on the 2nd part of the instructions. How do I pass a and b from main to the memcmp function?