Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly immediate values

Tags:

x86

assembly

I am new to assembly language and a bit confused about what is considered an "immediate value" in AT&T syntax. Specifically, I understand that "$" is used to either represent an immediate value or an address and "%" is used to represent registers, but then I come to accessing elements of "arrays":

movl mem_location(%ebx,%ecx,4), %eax

Why doen't this number 4 have "$" before it, isn't it an immediate value?

Thank you for your time

like image 395
Franko Leon Tokalić Avatar asked Mar 16 '23 22:03

Franko Leon Tokalić


1 Answers

I think you misunderstand the meaning of immediate value. Immediate value means the value is included on the opcode. If it refers to memory (array) or registers, it is not immediate. As Jester points out, the 4 is actually a scale factor for memory addressing. This is not considered an immediate value.

An example of immediate value would be something like mov eax, 123.

Also note that immediate value is an assembly concept (it applies to a lot of architectures), not something specific to AT&T syntax.

like image 77
m0skit0 Avatar answered Mar 23 '23 02:03

m0skit0