开发者

x86 Assembler: shl and other instructions

开发者 https://www.devze.com 2023-03-06 06:18 出处:网络
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:

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 PT开发者_如何学运维R [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.


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]
0

精彩评论

暂无评论...
验证码 换一张
取 消