gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Addressing question

#47028 - ProblemBaby - Mon Jul 04, 2005 1:29 am

Ive to variables and I want them to have same location in memory how do I write that in asm.

Code:

.global Var1
Var1:
.zero 64


Now I want Var2 to have the same address as Var1

#47036 - poslundc - Mon Jul 04, 2005 5:40 am

You can stack your labels if you so desire:

Code:
.global     Var1, Var2
Var1:
Var2:
.zero     64


In this case, Var1 and Var2 are equivalent.

Also, note the following:

Code:
Var1:
.zero     64
Var2:
.word     Var1


Now if you load Var2, you'll get a pointer to Var1.

Dan.

#47044 - ProblemBaby - Mon Jul 04, 2005 1:12 pm

Nice! Thanks