In this case the second parameter onwards will be passed on the stack, the parameters are pushed from right to left i.e. after the call the leftmost parameter will be on the top of the stack. Here is an example:
extern int asm_func(unsigned char, unsigned char);The corresponding assembler routine is:
int c_func (unsigned char i, unsigned char j) reentrant
{
return asm_func(i,j);
}
int main()
{
return c_func(10,9);
}
.globl _asm_funcThe compiling and linking procedure remains the same, however note the extra entry & exit linkage required for the assembler code, _bp is the stack frame pointer and is used to compute the offset into the stack for parameters and local variables.
_asm_func:
push _bp
mov _bp,sp
mov r2,dpl
mov a,_bp
add a,#0xfd
mov r0,a
add a,#0xfc ;?
mov r1,a
mov a,@r0
add a,r2 ;?
mov dpl,a
mov dph,#0x00
mov sp,_bp
pop _bp
ret