Passing Parameters in 64 bit Assembly Function from C language. Which Register Receive These Parameter?

10,798

Solution 1

If I understand the first part of your question, using C in 16-bit mode is not really supported (since 16-bit mode uses segmentation to get past 16 bits of addressing).

Referring to the second part, that depends on the compiler, but IIRC both Windows and Unix will pass additional arguments on the stack (see http://en.wikipedia.org/wiki/X86_calling_conventions for more on argument passing).

Solution 2

64-bit UEFI uses the Windows convention.

The BIOS and DOS APIs are defined in assembly language.

Traditionally in 16-bit and 32-bit x86 all the arguments are stored on the stack.

Share:
10,798
user2365346
Author by

user2365346

Updated on June 04, 2022

Comments

  • user2365346
    user2365346 almost 2 years

    I want to pass a parameter to an assembly function from C.

    On a UNIX-like system, the first six parameters go into rdi, rsi, rdx, rcx, r8, and r9.

    On Windows, the first four parameters go into rcx, rdx, r8, and r9.

    Now, my question is: On the BIOS- or DOS programming level, which registers receive these parameters? If the number of parameter are more than 6, how do I write the assembly to handle these parameters?