#emit Discussion
#14

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

Reply


Messages In This Thread
#emit Discussion - by Yashas - 20.06.2015, 18:47
Re: #emit Discussion - by ]Rafaellos[ - 20.06.2015, 19:08
Re: #emit Discussion - by Misiur - 20.06.2015, 21:18
Re: #emit Discussion - by Yashas - 21.06.2015, 04:38
Re: #emit Discussion - by Misiur - 21.06.2015, 07:50
Re: #emit Discussion - by Yashas - 21.06.2015, 08:48
Re: #emit Discussion - by PeterJane - 25.06.2015, 00:29
Re: #emit Discussion - by Yashas - 12.07.2015, 07:56
Re: #emit Discussion - by Vince - 12.07.2015, 10:46
Re: #emit Discussion - by Yashas - 12.07.2015, 10:54
Re: #emit Discussion - by Yashas - 31.08.2015, 15:46
Re : #emit Discussion - by Dutheil - 10.11.2015, 23:04
Re: #emit Discussion - by Yashas - 11.11.2015, 13:09
Re: #emit Discussion - by Dutheil - 18.07.2017, 14:26
Re: #emit Discussion - by Nero_3D - 18.07.2017, 23:47
Re: #emit Discussion - by Dutheil - 19.07.2017, 00:31
Re: #emit Discussion - by Nero_3D - 19.07.2017, 22:07
Re: #emit Discussion - by Dutheil - 29.12.2017, 14:45
Re: #emit Discussion - by Misiur - 29.12.2017, 15:24
Re: #emit Discussion - by Kaperstone - 29.12.2017, 15:49
Re: #emit Discussion - by Y_Less - 29.12.2017, 16:00
Re: #emit Discussion - by Dutheil - 29.12.2017, 19:56

Forum Jump:


Users browsing this thread: 1 Guest(s)