danielhc
danielhc

Reputation: 479

x86 Assembler: shl and other instructions

I'm trying to understand some assembler code inside a loop. The loop runs from 1 to 255 and does the following inside the loop:

mov    eax,DWORD PTR [ebp-0x4]
shl    eax,0x2
add    eax,DWORD PTR [ebp+0x8]
mov    DWORD PTR [eax],0x0

Here the DWORD PTR [ebp-0x4] refers to the number going from 1 to 255.

Can someone figure out what is going on here? Thanks.

Upvotes: 1

Views: 2518

Answers (1)

Paul R
Paul R

Reputation: 212959

It's just zeroing an array apparently:

mov    eax,DWORD PTR [ebp-0x4] ; load index
shl    eax,0x2                 ; multiply index by 4 to get byte offset
add    eax,DWORD PTR [ebp+0x8] ; add byte offset to array base address
mov    DWORD PTR [eax],0x0     ; zero value at array[index]

Upvotes: 5

Related Questions