Hi,
I am declaring the global variable outside a procedure. I want to know the register that is used by this global variable. VAR VAR1:INTEGER; attribute(name='VAR1');
When I tried to disassemble the object file, the global variables seems to be residing in the memory instead of a register.
80000130: 7005 moveq #5,%d0 80000132: 23c0 8000 21ec movel %d0,800021ec <VAR1>
Can you please let me know how to identify the register which is used by this variable.
Thanks, Rajat
I forgot to add I am trying to do this for 68k as target machine.
Regards,
Rajat
On Tue, May 20, 2014 at 5:41 PM, Rajat Singh rajat.000@gmail.com wrote:
Hi,
I am declaring the global variable outside a procedure. I want to know the register that is used by this global variable. VAR VAR1:INTEGER; attribute(name='VAR1');
When I tried to disassemble the object file, the global variables seems to be residing in the memory instead of a register.
80000130: 7005 moveq #5,%d0 80000132: 23c0 8000 21ec movel %d0,800021ec <VAR1>
Can you please let me know how to identify the register which is used by this variable.
Thanks, Rajat
Ok thanks.. One more question. Can I get the reference of global variable in terms of offset from some register like a5 ( for example like move.l 8(%a5),%d0) instead of direct memory address or variable name ? 80000130: 7005 moveq #5,%d0 80000132: 23c0 8000 21ec movel %d0,800021ec <VAR1>
move.l %d0,I move.l VAR1,I
Regards, Rajat
On Tue, May 20, 2014 at 7:03 PM, Rajat Singh rajat.000@gmail.com wrote:
I forgot to add I am trying to do this for 68k as target machine.
Regards,
Rajat
On Tue, May 20, 2014 at 5:41 PM, Rajat Singh rajat.000@gmail.com wrote:
Hi,
I am declaring the global variable outside a procedure. I want to know the register that is used by this global variable. VAR VAR1:INTEGER; attribute(name='VAR1');
When I tried to disassemble the object file, the global variables seems to be residing in the memory instead of a register.
80000130: 7005 moveq #5,%d0 80000132: 23c0 8000 21ec movel %d0,800021ec <VAR1>
Can you please let me know how to identify the register which is used by this variable.
Thanks, Rajat
Rajat Singh wrote:
One more question. Can I get the reference of global variable in terms of offset from some register like a5 ( for example like move.l 8(%a5),%d0) instead of direct memory address or variable name ? 80000130: 7005 moveq #5,%d0 80000132: 23c0 8000 21ec movel %d0,800021ec <VAR1>
move.l %d0,I move.l VAR1,I
What you mean by get? Gpc supports inline assemby, so you can compute offset using inline assembly. How variable are accessed is left to optimizer. You will get different code if you say request position independent code (-fpic flag) but that affect all code and has speed penalty. If your "variable" is something in memory that may move, then use pointer to access it.
Rajat Singh wrote:
I am declaring the global variable outside a procedure. I want to know the register that is used by this global variable. VAR VAR1:INTEGER; attribute(name='VAR1');
When I tried to disassemble the object file, the global variables seems to be residing in the memory instead of a register.
80000130: 7005 moveq #5,%d0 80000132: 23c0 8000 21ec movel %d0,800021ec <VAR1>
Can you please let me know how to identify the register which is used by this variable.
Global variables are normally allocated in memory. GNU C has an extension to allocate global variables in registers, but IIRC this is not supported by GPC. Why do you need information about registers? If you want to understand machine code generated by GPC then use something like
gpc -S -fverbose-asm file.pas
The -S option option generates assembly, '-fverbose-asm' adds extra comments which in particular explain which variables live in registers.