I have 3 questions.
In the PDF "Implementor’s Guide", let's take LOAD.pri : pri = PRI = [address]
It is mentioned :
Quote:
An item between square brackets indicates a memory access (relative to the data register, except for jump and call instructions)
|
So, his code in C is :
PHP код:
pri = *(data + address)
1. My first question is : there is any difference between a "data register" and a "data segment" ?
2. My second question is based on the tests I made.
I know when I declare a variable, her value is stored in memory, but we don't have acces to it easily, because I thought that it was only necessary to rely on the semantics.
Example : If I declare a variable named "myVar" with the value 41566421 and I want to get her address in the memory :
PHP код:
#include "a_samp"
main()
{
new
myVar = 41566421,
globalAddress;
#emit ADDR.pri myVar
#emit LOAD.I
#emit STOR.S.pri globalAddress
printf("0x%08x", globalAddress);
}
It prints me : 0x027A40D5
Edit : Logic, 0x027A40D5 in decimal is 41566421... my bad
But the real address is among these :
If there is a difference in my first question, what data is use in the p-code LOAD.I ?
Otherwise : why it doesn't print me the good address ?
I looked the code in y_amx, and I see a semi-constant "AMX_REAL_DATA" initializes with some manipulations.
3. Is it better to use the p-code STACK twice or once in such cases ? :
PHP код:
#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
}
or ? :
PHP код:
#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
}