Juan Kou
Juan Kou

Reputation: 165

How to change a value stored in an address in x86?

I have a register whose content is an address. Now I want to change the value stored in that address, how can I do this in x86 assembly?

For example

mov $5, %r10

//r10 contains an address addr, location addr stores a value, now I want to set this value to be 5.

Upvotes: 2

Views: 4340

Answers (1)

Wintermute
Wintermute

Reputation: 44063

Since this appears to be AT&T syntax,

movb $5,(%r10)

to store a byte. The assembler won't be able to infer the size of $5, so you can't use mov but have to specify movb directly (or movl etc. if you mean something other than a byte).

Upvotes: 4

Related Questions