must_save |= is_x86_reg_saved(pp->arg[i].reg);
}
- fprintf(f, ".global _%s\n", sym_in);
- fprintf(f, "_%s:\n", sym_in);
+ fprintf(f, ".global %s%s\n", pp->is_fastcall ? "@" : "_", sym_in);
+ fprintf(f, "%s%s:\n", pp->is_fastcall ? "@" : "_", sym_in);
- if (pp->argc_reg == 0) {
+ if (pp->argc_reg == 0 || pp->is_fastcall) {
+ fprintf(f, "\t# %s\n",
+ pp->is_fastcall ? "__fastcall" :
+ (pp->is_stdcall ? "__stdcall" : "__cdecl"));
fprintf(f, "\tjmp %s\n\n", sym_out);
return;
}
{
int sarg_ofs = 1; // stack offset to args, in DWORDs
int saved_regs = 0;
+ int c_is_stdcall;
int argc_repush;
int stack_args;
int ret64;
ret64 = strstr(pp->ret_type.name, "int64") != NULL;
- fprintf(f, "# %s", pp->is_stdcall ? "__stdcall" : "__cdecl");
+ fprintf(f, "# %s",
+ pp->is_fastcall ? "__fastcall" :
+ (pp->is_stdcall ? "__stdcall" : "__cdecl"));
if (ret64)
fprintf(f, " ret64");
fprintf(f, "\n.global %s\n", sym);
fprintf(f, "%s:\n", sym);
- if (pp->argc_reg == 0) {
- //fprintf(f, "\tjmp _%s\n\n", sym);
- fprintf(f, "\tjmp _%s", sym);
- if (pp->is_stdcall && pp->argc > 0)
+ if ((pp->argc_reg == 0 || pp->is_fastcall)
+ && !IS(pp->name, "storm_491")) // wants edx save :(
+ {
+ fprintf(f, "\tjmp %s%s",
+ pp->is_fastcall ? "@" : "_", sym);
+ if (pp->is_stdcall)
fprintf(f, "@%d", pp->argc * 4);
fprintf(f, "\n\n");
return;
}
+ c_is_stdcall = (pp->argc_reg == 0 && pp->is_stdcall);
+
// at least sc sub_47B150 needs edx to be preserved
// int64 returns use edx:eax - no edx save
// we use ecx also as scratch
sarg_ofs++;
}
- // no worries about calling conventions - always __cdecl
- fprintf(f, "\n\tcall _%s\n\n", sym);
+ fprintf(f, "\n\tcall _%s", sym);
+ if (c_is_stdcall)
+ fprintf(f, "@%d", pp->argc_stack * 4);
+ fprintf(f, "\n\n");
- if (sarg_ofs > saved_regs + 1)
+ if (!c_is_stdcall && sarg_ofs > saved_regs + 1)
fprintf(f, "\tadd $%d,%%esp\n",
(sarg_ofs - (saved_regs + 1)) * 4);