• Butterfly
    Butterfly
    alfie
    Posts: 96 from 2005/3/25
    From: Italy
    The following is with EmulCall68k.

    Code:
    #include <proto/exec.h>
    #include <stdio.h>

    struct Library *RexxSysBase;

    int toupper(int c)
    {
    struct EmulCaos ec = {0};
    ULONG fun, res;

    fun = (ULONG)RexxSysBase-0x126;
    ec.caos_Un.Function = (APTR)fun;
    ec.reg_d0 = (ULONG)c;
    ec.reg_a6 = (ULONG)RexxSysBase;

    res = (*MyEmulHandle->EmulCall68k)(&ec);

    return (int)res;
    }

    int main(int argc,char **argv)
    {
    ULONG res;

    if (argc!=2)
    return 1;

    RexxSysBase = OpenLibrary("rexxsyslib.library",0);
    if (!RexxSysBase)
    return 1;

    res = toupper(argv[1][0]);
    printf("%c %cn",argv[1][0],res);

    CloseLibrary(RexxSysBase);

    return 0;
    }


    How to do the same using EmulCallQuick68k?

    P.S.
    I am asking this silly question(s), because this is the convoluted way I use to call some function, f.e. CVs2i:

    being the 68k asm:
    Code:
        _CVs2i:
    move.l d1,-(a7)
    move.l a1,-(a7)
    jsr _LVOCVs2i(a6)
    movea.l (a7)+,a1
    move.l d1,(a1)
    move.l (a7)+,d1
    rts


    I use a ridiculous:
    Code:
    static UWORD CVs2i_code[] =
    {
    0x2F01,
    0x2F09,
    0x4EAE, 0xFE26,
    0x225F,
    0x2281,
    0x221F,
    0x4E75
    };

    int
    CVs2i(struct RexxArg *ss,LONG *value,struct RxsLib *base)
    {
    REG_A0 = (ULONG)ss;
    REG_A1 = (ULONG)value;
    REG_A6 = (ULONG)base;
    return (int)(*MyEmulHandle->EmulCallDirect68k)(CVs2i_code);
    }


    which is too much :P

    [ Edited by alfie 04.06.2024 - 09:16 ]
  • »04.06.24 - 08:06
    Profile Visit Website