#emit l.15 #emit INC pos #emit LOAD.pri pos #emit LOAD.S.alt cmdtext #emit LIDX #emit EQ.C.pri 20 #emit JZER 16 #emit JUMP 15 #emit l.16 #emit LOAD.S.alt cmdtext #emit LOAD.pri pos #emit IDXADDR
Run time error 22: "AMX not initialized (or doubly initialized)"
CODE 0 ; 0 ;program exit point halt 0 proc ; main ; line 1 break ; c ; line 2 break ; 10 push.c 0 call .Hello ;$exp zero.pri retn proc ; Hello ; line 6 break ; 30 ; line 7 break ; 34 ;$lcl pos fffffffc stack fffffffc zero.pri stor.s.pri fffffffc ;$exp ;$lcl cmdtext fffffff8 stack fffffffc zero.pri stor.s.pri fffffff8 ;$exp inc fffffffc load.pri fffffffc load.s.alt fffffff8 lidx eq.c.pri 14 jzer 10 jump f l. 10 load.s.alt fffffff8 load.pri fffffffc idxaddr ; line 18 break ; b4 const.pri 1 stack 8 retn DATA 0 ; 0 dump 6c 2e 31 35 0 STKSIZE 1000 |
new tmp;
do {
#emit INC pos
#emit LOAD.pri pos
#emit LOAD.S.alt cmdtext
#emit LIDX
#emit STOR.S.pri tmp
} while (20 != tmp);
#emit LOAD.S.alt cmdtext
#emit LOAD.pri pos
#emit IDXADDR
fatal error 104: invalid assembler instruction "jzer.rel"
static nullstr[] = ""; getproperty(0,cmdtext,cellmin,nullstr);
push.c f4 ;$par push.c 80000000 ;$par push.s 10 ;$par push.c 0 ;$par push.c 10 sysreq.c 2 ; getproperty
getproperty(.name = cmdtext);
const.pri 104 heap 4 movs 4 push.alt ;$par push.c 80000000 ;$par push.s 10 ;$par push.c 0 ;$par push.c 10 sysreq.c 2 ; getproperty
stock AsmError:AsmEmitJzerRel(ctx[AsmContext], offset) { return AsmEmitJumpInstruction(ctx, OP_JZER, offset); }
native getproperty(id=0, const name[]="", value=cellmin, string[]="");
getproperty(.name = "name", .value = 100);
#emit LCTRL 6 #emit ADD.C 16 // 2*4 = 8 bytes #emit STOR.pri addr //2*4 = 8 bytes if(cmdtext[++pos] == ' ') { #emit LOAD.pri addr #emit SCTRL 6 }
lable1: print("HI"); #emit JUMP lable1
goto label1;
And how is that different from the generally frowned upon
pawn Код:
|
#emit JZER lable
if(k == 0) goto lable;
#emit LOAD.S.pri k #emit JZER somewhere somewhere: JUMP lable
#emit LOAD.S.pri k #emit JZER lable
stock _INI_LOG(INI:handle, msg[], {Float, _}:...) { printf("ERR MSG %s",msg); static arg_count_bytes; static str[128],start_adr,end_adr; new File:LogFile = fopen(INI_LOG_FILE,io_append); #emit LOAD.S.pri 8 #emit CONST.alt 8 //2 STATIC ARGUMENTS ; 2*4 = 8 #emit SUB #emit STOR.pri arg_count_bytes if(arg_count_bytes) { #emit LCTRL 5 #emit CONST.alt msg #emit ADD #emit STOR.pri start_adr #emit LOAD.alt arg_count_bytes #emit ADD #emit STOR.pri end_adr do { #emit LOAD.I #emit PUSH.pri #emit LOAD.pri end_adr #emit CONST.alt 4 #emit SUB #emit STOR.pri end_adr }while(end_adr > start_adr); #emit PUSH.S msg #emit PUSH.C 128 #emit PUSH.ADR str #emit LOAD.pri arg_count_bytes #emit CONST.alt 12 #emit ADD #emit STOR.pri arg_count_bytes #emit PUSH.pri #emit SYSREQ.C format #emit LOAD.pri arg_count_bytes #emit CONST.alt 4 #emit ADD #emit XCHG #emit LCTRL 4 #emit ADD #emit SCTRL 4 if(LogFile) fwrite(LogFile,str); else { print("Could not open Log File ("#INI_LOG_FILE")"); print(str); } } else { if(LogFile) { fwrite(LogFile,str); fclose(LogFile); } else { print("Could not open Log File("#INI_LOG_FILE")"); print(str); } } }
[08:42:39] ERR MSG [INI]CreateINI:File already exists(%s) [08:42:39] ERR MSG [INI]Warning:Creating another instance of the same file(%s) [08:42:39] ERR MSG [INI]ReadString:Key(%s) not found in section ID %d [08:42:39] [debug] Run time error 6: "Invalid instruction" [08:42:39] [debug] Unknown opcode 0x24000000 at address 0x00000061 [08:42:39] [debug] AMX backtrace: [08:42:39] [debug] #0 00000061 in public OnFilterScriptInit () at H:\eXtended INI Processor\Server\pawno\include\eINI.inc:254 [08:42:39] Loaded 1 filterscripts.
[08:50:43] -4081998 ERR MSG [INI]CreateINI:File already exists(%s) [08:50:43] [debug] Server crashed while executing TestEINI.amx [08:50:43] [debug] AMX backtrace: [08:50:43] [debug] #0 native format () [00472b80] from samp-server.exe [08:50:43] [debug] #1 000001e0 in _INI_LOG (INI:handle=-4081998, msg[]=@0x0009563c "[INI]CreateINI:File already ex...", ... <1 argument>) at H:\eXtended INI Processor\Server\pawno\include\eINI.inc:277 [08:50:43] [debug] #2 0000095c in INI:eINI_CreateINI (fname[]=@0x0009a924 "NewFile.ini") at H:\eXtended INI Processor\Server\pawno\include\eINI.inc:483 [08:50:43] [debug] #3 00011888 in public OnFilterScriptInit () at H:\eXtended INI Processor\Server\filterscripts\TestEINI.pwn:44 [08:50:43] [debug] Native backtrace: [08:50:43] [debug] #0 00403334 in ?? () from samp-server.exe [08:50:43] [debug] #1 625658ca in ?? () from plugins\crashdetect.DLL [08:50:43] [debug] #2 6256774f in ?? () from plugins\crashdetect.DLL [08:50:43] [debug] #3 62560834 in ?? () from plugins\crashdetect.DLL [08:50:43] [debug] #4 6256591a in ?? () from plugins\crashdetect.DLL [08:50:43] [debug] #5 0046a918 in ?? () from samp-server.exe
#emit ADD #emit STOR.pri end_adr do <- LINE 277 { #emit LOAD.I #emit PUSH.pri
An item between square brackets indicates a memory access (relative to the data register, except for jump and call instructions) |
pri = *(data + address)
#include "a_samp"
main()
{
new
myVar = 41566421,
globalAddress;
#emit ADDR.pri myVar
#emit LOAD.I
#emit STOR.S.pri globalAddress
printf("0x%08x", globalAddress);
}
#include "a_samp"
main()
{
new
string[] = "Dutheil";
#emit ADDR.pri string
#emit PUSH.pri
#emit PUSH.C 4
#emit SYSREQ.C print
#emit ADDR.pri string
#emit ADD.C 12
#emit PUSH.pri
#emit PUSH 4
#emit SYSREQ.C print
#emit STACK 16 // fix the stack
}
#include "a_samp"
main()
{
new
string[] = "Dutheil";
#emit ADDR.pri string
#emit PUSH.pri
#emit PUSH.C 4
#emit SYSREQ.C print
#emit STACK 8 // fix the stack
#emit ADDR.pri string
#emit ADD.C 12
#emit PUSH.pri
#emit PUSH 4
#emit SYSREQ.C print
#emit STACK 8 // fix the stack
}
1. My first question is : there is any difference between a "data register" and a "data segment" ?
|
// amx.c
case OP_LOAD_I:
/* verify address */
if (pri>=hea && pri<stk || (ucell)pri>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
pri=_R(data,pri); // #define _R(base,addr) (* (cell *)((unsigned char*)(base)+(int)(addr)))
break;
3. Is it better to use the p-code STACK twice or once in such cases ?
|
So, I noticed something :
In LOAD.I, the variable data is used, but in LCTRL 1, this is hdr->dat. They don't store the same value, that's for sure. |
#include "a_samp"
forward CustomPublicFunction();
main()
{
CustomPublicFunction();
}
public CustomPublicFunction()
{
// get here the name of CustomPublicFunction
}
There's funcidx which returns the index, unless that's what you mean by "without index id"
|
#include "a_samp" forward CustomPublicFunction(); main() { CustomPublicFunction(); } public CustomPublicFunction() { print(GetCallbackName()); // will print "CustomPublicFunction" }