V
V
Vi2016-12-11 17:04:20
assembler
Vi, 2016-12-11 17:04:20

How does this assembler code work?

this code is working but

mov eax,0
do:
  mov edx,48
  add edx,eax
  mov dword [temp+eax],edx
  inc eax
  cmp eax,10
  jne do

confuses the line
mov dword [temp+eax], edx
I can't figure out how it adds the value of eax every time it changes in one mov command?
tell me how it turns out, what kind of magic is this

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
15432, 2016-12-11
@15432

In C, this looks something like
int temp[10];
int i ;
for ( i = 0; i != 10; ++i)
{
temp[i] = i + 48;
//Not sure, maybe even *(int*)((char*)temp + i) = i + 48
}
The only doubt about +eax... To index dword, it seems like you need to multiply by 4 more
In any case, eax is modified only in inc command

C
CityCat4, 2016-12-12
@CityCat4

The mov command only moves data. In this case - will place the value of EDX at the address equal to the sum of the address of the temp area and EAX. The recording point is moved in the inc command - and here is the magic :) I don’t see the temp description, but I have to move inc by the length of the type description, as far as I remember ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question