From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,b21ae2574b9acb6b X-Google-Attributes: gid1164f8,public From: lueck@gurgi.zk3.dec.com (Greg Lueck Development Environment) Subject: Re: loading data addresses on Alpha Date: 1996/05/07 Message-ID: <4mnecs$j5f@lead.zk3.dec.com>#1/1 X-Deja-AN: 153510135 distribution: world references: organization: Digital Equipment Corporation reply-to: lueck@zk3.dec.com (Greg Lueck Development Environment) newsgroups: comp.sys.dec The compiler load addresses from a table of address literals. The $gp register is reserved to point at this table, so a typical address load looks like this: ldq $rx, disp($gp) where "disp" is the appropriate displacement to reference the desired element in the table. The compilers also generate code to set up the $gp register upon entry to a procedure. You'll notice at the start of each procedure there is code like this: ldah $gp, disp1($pv) lda $gp, disp2($gp) This sets the $gp register by adding a 32-bit constant to the $pv register. The calling standard on Digital Unix Alpha dictates that $pv be set to the address of the called procedure. Therefore, there is a limitation that the address literal table be within a 32-bit offset from every procedure that uses it. Since it sounds like you are in your own environment, you can either choose to use this mechanism or choose another that is more appropriate to your needs. For instance, if address loads are uncommon, you can avoid reserving a register and generate code like this to load an address: br $rx, 0 ; Branch to next instruction, $rx set to ; address following branch ldah $rx, disp1($rx) ldq $rx, disp2($rx) This loads an address from a table that is indexed by adding a 32-bit displacement to the current PC. Note, the whole sequence uses only one register. Another option is to load addresses like this: br $rx, L1 ; $rx set to address following branch L1: ldq $rx, 0($rx) However, this is rather messy because it mixes text and data together. Also, you need to get the alignment of the branch instruction right or the address load will be unaligned. Hope this helps. -- ------------------------------------------------------------------------------- Greg Lueck Currently contracting at Digital Doan & Associates, Ltd. lueck@zk3.dec.com Opinions expressed herein are my own. ------------------------------------------------------------------------------- -- ------------------------------------------------------------------------------- Greg Lueck Currently contracting at Digital Doan & Associates, Ltd. lueck@zk3.dec.com