user15563851
user15563851

Reputation:

Assembly (AT&T) read memory to register?

In assembly I am trying to add 32 bits from memory to 64 registers, this will load 64 bits:

add arr(,%rax,4), %rbx

So I tried:

add arr(,%rax,4), %rbx

which didn't work.

How can I solve this?

Upvotes: 1

Views: 338

Answers (1)

Yennefer
Yennefer

Reputation: 6234

You cannot perform the operation directly, but in two steps: First you need to zero extend your value into an additional register, and then you can use it for the addition.

Something like this should do the work:

    movl arr(,%rax,4), %edx
    add %rdx, %rbx

Upvotes: 2

Related Questions