In C++ you can return a user-defined type by value. In x86-64 ASM return by value is implemented by moving the return value to RAX and popping the stored previous value of RIP into RIP to return to the caller. How can a struct or really any type of array that is larger than RAX be returned by value?
how is a struct returned by value, in terms of assembly language, if that struct is too large to fit in a register?
720 Views Asked by John Fisher At
1
There are 1 best solutions below
Related Questions in ASSEMBLY
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- How to call a C language function from x86 assembly code?
- Binary Bomb Phase 2 - Decoding Assembly
- AVR Assembly Clock Cycle
- Understanding the differences between mov and lea instructions in x86 assembly
- ARM Assembly code is not executing in Vitis IDE
- Which version of ARM does the M1 chip run on?
- Why would %rbp not be equal to the value of %rsp, which is 0x28?
- Move immediate 8-bit value into RSI, RDI, RSP or RBP
- Unable to run get .exe file from assembly NASM
- DOSbox automatically freezes and crashes without any prompt warnings
- Load function written in amd64 assembly into memory and call it
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- running an imf file using dosbox in parallel to a game
Related Questions in X86-64
- What is causing the store latency in this program?
- Move immediate 8-bit value into RSI, RDI, RSP or RBP
- What is Win32 x86-64 CONTEXT::VectorRegister for?
- Why does MSVC never return struct in RAX for member-functions?
- How to change UP (direction) flag in x86 assembly to 1?
- docker inspect splunkImage Container ID: Warining: cannot create \"/opt/splunk/var/log/splunk
- Infinite loop while trying to print numbers 1 to 10 in assembly x86 64 bits
- Get the address and size of a loaded shared object on memory from C
- What a reason for C2148 or similar errors on another compilers?
- In a Linux signal handler, will x86 extended state always be in XSAVE format, or can it be in XSAVEC format as well?
- ASM register-variable from existing register-value in clang
- Smallest possible 64-bit MASM GUI application not working correctly
- How do I fix the jsonobject architecture problem I am having in PyCharm CE when the terminal says the package is installed?
- x86 Assembly: handling exponent 1 in power calculation
- How to navigate to the structure definition for the target architecture when cross-compiling on Ubuntu with VS Code?
Related Questions in CALLING-CONVENTION
- Why does MSVC never return struct in RAX for member-functions?
- Ensuring x64 compliance of custom ASM-function in clang-cl
- Calling Rust functions from inline assembly and calling conventions
- assembly code have a mistake Run-Time Check Failure
- Force GCC to return floats in integer registers
- Preventing Arm Neon d8-d15 spilling in a function
- Type-traits for handling structs in Windows x64 calling convention
- How to avoid infinite loops in a function call in assembly?
- internal registers, difference between temporary and argument-registers
- How do callee-saved registers work? Who should push the original value onto the stack?
- ROP - The use of the jmp esp
- x86-64 size of parameters pushed on stack
- Where is the "%d\n" format string stored and how does GCC pass it to printf on x86-64?
- x86 Assembly subroutines - understanding how to return local var struct using only 1 register
- Retrieve arguments 5 & 6 from a C++ function call in masm proc
Related Questions in ABI
- Copy constructors and const& versus the ARM ABI
- Reason for (win) x64-calling convention restrictions in epilogues
- How to generate multi hop swap path with ethers.js?
- Managing Relocation Order Dependencies in ELF Shared Libraries
- Differences in .s assembly between GCC and mingw: How to compile QBE output on windows?
- Where is the order in which ELF relocations are applied specified?
- Is there a database of C function signatures?
- How to mark a C++ type as not "trivially_copyable", while keeping it "trivial for the purposes of calls" in the Itanium C++ ABI?
- Win32 Wide-Character String Alignment Requirements
- Compatibility rules to follow if we want to modify a function definition in a shared library used by our program
- Aarch64 is there a Red Zone on Linux, If so 16 or 128 bytes?
- Binary compatibility libraries same compiler and compiler version, different OS version
- Getting Mangled C++ symbols from uncalled functions
- How to install pytorch=1.0 and why pytorch installing command no longer work
- What distribution has the best cross compatibility on Amazon AWS Graviton?
Related Questions in RETURN-BY-VALUE
- Does an implementation that returns fundamental types by value using registers do "temporary materialization"?
- best strategy for ensuring no copies in return by value
- how is a struct returned by value, in terms of assembly language, if that struct is too large to fit in a register?
- Is 1-arg overload of variadic template function useful? Should it used a magic && reference? Is Copy-Elision taking place in this case?
- Why does a function or method have to return a reference in order to be chained?
- C++ copy constructor activation in return-by-vlaue
- Why can copy elision not optimise all copy operations?
- Why doesn't the copy constructor work when I return an automatic variable from function?
- What is the meaning of assigning to return value of getter taking this pointer by value?
- Difference in Copy Elision for Trivial vs. Non-trivial Types
- Returning by value vs rvalue reference
- ctypes wrapper for function returning by value objects of a C++ class with destructor
- c++ : Whats difference in "catching reference in value" vs "catching value in value" during function return?
- ionic 3 typescript : passing object between pages by value
- Reference to r-value ( address of r-value )
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The SYSV x86_64 calling conventions (used by everyone except Microsoft) allow structures of up to 16 bytes and INTEGER classification to be returned in the RAX/RDX register pair, while those of SSE classification and up to 32 bytes can be returned in the XMM0/XMM1 register pair.
The classification of a struct depends on the types of the fields in the struct, but basically integer and pointer types will be INTEGER while float and double will be SSE.
Larger structs will get MEMORY classification, so will require an extra hidden argument (passed in RDI, so prepended to the existing arguments) specifying a pointer to memory that the return value will be written to. This pointer will be returned in RAX.
This is all detailed in the SYSV x86_64 ABI doc