开发者

x86 and dereferencing labels

I'd like to load the address of the second value below into a register.

Here is my code in Unix syntax:

.data
Lz7:
    .long 24
    .long 34
    .long 80
    .long 108
    .long 101
    .long 97
    .long 115
    .long 101
    .long 32
    .long 105
    .long 110
        ...etc...

I'm trying to 开发者_StackOverflowuse this code:

movl Lz7, %eax /* %g14 */ 
movl $4, %ebx /* %g15 */ 
addl %ebx /* %g15 */ , %eax /* %g16 */  

But gcc complains about a bus error at runtime. In GDB, I can see that GCC is translating the label Lz7 into the hex value 0x2068, which seems too small. I've also tried 4(Lz7) but GCC complains. How can I determine the location of the bus error in the program? If this code is incorrect, what should I write instead?


You need to use the 'leal' instruction to get the effective address, like this:

leal Lz7, %eax
addl $4, %eax
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜