FictionTools/z88dk/src/sccz80/codegen.c
/* Push an argument for a function pointer call */
Push an argument for a function pointer call
Push an argument for a function pointer call
int push_function_argument_fnptr(Kind expr, Type *type, int push_sdccchar, int is_last_argument)
{
    if (expr == KIND_LONG || expr == KIND_CPTR || ( c_fp_size == 4 && expr == KIND_DOUBLE)) {
        if ( !is_last_argument ) {
            swap(); 
            swapstk(); 
            zpushde(); 
        }
        return 4;
    } else if (expr == KIND_DOUBLE) {
        dpush_under(KIND_INT);
        mainpop();
        return c_fp_size;
    } else if (expr == KIND_STRUCT ) {
        swap();    
        ol("pop\tbc");	
        vconst(-type->size);
        ol("add\thl,sp");
        ol("ld\tsp,hl");
        ol("push\tbc");
        Zsp -= type->size;
        swap();
        outfmt("\tld\tbc,%d\n",type->size);
        ol("ldir");
        mainpop();
        return type->size;
    } 
    if ( !is_last_argument ) {
        if ( IS_GBZ80() ) {
            ol("ld\td,h");
            ol("ld\te,l");
            ol("pop\thl");
            ol("push\tde");
        } else {
            swapstk();
        }
    }
    return 2;
}
int push_function_argument_fnptr ( Kind expr , Type * type , int push_sdccchar , int is_last_argument ) { if ( expr == KIND_LONG || expr == KIND_CPTR || ( c_fp_size == 4 && expr == KIND_DOUBLE ) ) { if ( ! is_last_argument ) { swap ( ) ; swapstk ( ) ; zpushde ( ) ; } return 4 ; } else if ( expr == KIND_DOUBLE ) { dpush_under ( KIND_INT ) ; mainpop ( ) ; return c_fp_size ; } else if ( expr == KIND_STRUCT ) { swap ( ) ; ol ( " \t " ) ; vconst ( - type -> size ) ; ol ( " \t " ) ; ol ( " \t " ) ; ol ( " \t " ) ; Zsp -= type -> size ; swap ( ) ; outfmt ( " \t \t \n " , type -> size ) ; ol ( " " ) ; mainpop ( ) ; return type -> size ; } if ( ! is_last_argument ) { if ( IS_GBZ80 ( ) ) { ol ( " \t " ) ; ol ( " \t " ) ; ol ( " \t " ) ; ol ( " \t " ) ; } else { swapstk ( ) ; } } return 2 ; }
Push an argument for a function pointer call
Push an argument for a function pointer call
/* MSW -> hl */ /* MSW -> stack, addr -> hl */ /* LSW -> stack, addr = hl */ // 13 bytes // de = address of struct // return address