Inline assembly question

Dibyendu Majumdar d.majumdar at gmail.com
Sun Nov 12 12:12:04 UTC 2017


On Sunday, 12 November 2017 at 12:00:00 UTC, Basile B. wrote:
> On Sunday, 12 November 2017 at 11:01:39 UTC, Dibyendu Majumdar 
> wrote:
>> [...]
>> The assembly code uses static allocation of registers, but 
>> because of the differences in how registers are used in Win64 
>> versus Unix X64 - different registers are assigned depending 
>> on the architecture. dynasm makes this easy to do using 
>> macros; e.g. below.
>> [...]
>> With above in place, the code can use the mnemonics to refer 
>> to the registers rather than the registers themselves. This 
>> allows the assembly code to be coded once for both 
>> architectures.
>
> I see...the problem is not the input parameters but functions 
> calls **inside** iasm, right ?

Not sure I understand the question. Once the defines are there I 
can write following:

   | // Call luaF_close
   | mov CARG1, L                               // arg1 = L
   | mov CARG2, BASE                            // arg2 = base
   | call extern luaF_close                     // call luaF_close

As you can see above, CARG1, L, CARG2, BASE are all mnemonics 
that map to registers. However this is only defined in one place.

Regards
Dibyendu


More information about the Digitalmars-d-learn mailing list