Good evening. I often use NASM in VC ++ on x86 and am learning how to use MASM in x64.
Is there any way to specify where each argument goes and the return of an assembly function in such a way that the compiler manages to leave the data there in the fastest way? You also have to specify which registers will be used so that the compiler knows what data has been saved to make the best use of it?
For example, since there is no equivalent intrinsic function we may need to implement a function that applies the exact IDIV (64-bit integer division with assembly signal). It requires that the low magnitude part of the dividend / numerator be in RAX, the high in RDX and the divisor / denominator in any register or in a region of memory. At the end, the quotient is in EAX and the rest in EDX. We may therefore want to develop functions more or less like this (I put inutilities to exemplify):
void DivLongLongInt( long long NumLow , long long NumHigh , long long Den , long long *Quo , long long *Rem ){
__asm(
// Specify used register: [rax], Specify pre location: NumLow --> [rax]
reg(rax)=NumLow ,
// Specify used register: [rdx], Specify pre location: NumHigh --> [rdx]
reg(rdx)=NumHigh ,
// Specify required memory: memory64bits [den], Specify pre location: Den --> [den]
mem[64](den)=Den ,
// Specify used register: [st0], Specify pre location: Const(12.5) --> [st0]
reg(st0)=25*0.5 ,
// Specify used register: [bh]
reg(bh) ,
// Specify required memory: memory64bits [nothing]
mem[64](nothing) ,
// Specify used register: [st1]
reg(st1)
){
// Specify code
IDIV [den]
}(
// Specify pos location: [rax] --> *Quo
*Quo=reg(rax) ,
// Specify pos location: [rdx] --> *Rem
*Rem=reg(rdx)
) ;
}
Is it possible to do something at least next to it?
If there is no way to do this, it's a pity because it would certainly be a great way to implement high-level functions with assembly-level features. For me, it is a simple interface between C ++ and ASM that should already exist and enable assembly code to be embedded inline and at high level, practically as simple C ++ code.
Thanks for all the help.