Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

assembly - gas: too many memory reference

When compiling the following instruction:

movl 4(%ebp), 8(%ebp)

I got: too many memory reference.

What's wrong with it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The number before the parenthesis is a byte offset (which causes a memory reference to occur), and you cannot have two of them with movl. You need to move the value temporarily to a register first.

movl 4(%ebp), %ecx
movl %ecx, 8(%ebp)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...