[Help]: Invalid instruction, with #emit
#1

Why this code has generation invalid instruction?

pawn Код:
#include a_samp


stock Func(q)
{
    return printf("Hello World: %d", q);
}


main()
{

    printf("NON");
   
    #emit LCTRL         6
    #emit ADD.C         12
   
    #emit PUSH.C        564 // FISRT PARAMETER
    #emit PUSH.C        12
    #emit PUSH.PRI
    #emit CONST.PRI     Func
    #emit SCTRL         6

    printf("NAIN");
}

Out
pawn Код:
[02:06:38] NON
[02:06:38] Hello World: 564
[02:06:38] Script[gamemodes/test.amx]: Run time error 6: "Invalid instruction"
[02:06:38] Number of vehicle models: 0
[02:06:39] --- Server Shutting Down.
Reply
#2

pawn Код:
main()
{
    printf("NON");

    // gets the cip behind this
    #emit LCTRL         6
    // we add 4 bytes for each instruction "ADD.C", "44", "PUSH.C", ...
    // we got 11 instructions to get behind sctrl 6 (11 * 4 = 44)
    #emit ADD.C         44

    #emit PUSH.C        564
    // only one parameter, 4 bytes
    #emit PUSH.C        4
    #emit PUSH.PRI
    #emit CONST.PRI     Func
    #emit SCTRL         6

    printf("NAIN");
}
The Invalid instruction mostly came from returning to the position where 564 is saved, 12 bytes behind your lctrl 6
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)