Scale factor in assembly ?

0 pratt 15 · February 11, 2015
Can anybody explain me why we use scale factor in asm programs (mainly in arrays ) & how to use them with examples .

Post a Reply


Oldest  Newest  Rating
+1 Tatrasiel R · February 21, 2015
I hope I understand your question well as from what I can show you it's used for figuring out a value effectively and simply.
Here is  a PDF that talks about this

let me try to come up with an example so we have some local variables in memory right? It could be an array just is would use pointers and such . This isn't the best example either.

12345678 : 00000480  <- Total that needs to be written at a rate index of 40
12345686 : 00000001  <-  index size / or something
12345694 : 00000000  <- Total Index End

mov eax, dword ptr ds:[12345678] ; this could be the pointer start or something that you want to be iterated through.
mov ecx ,  dword ptr ds:[12345686 ]
mov edx, [eax- ecx]
mov dword ptr ds:[12345694 ],edx ; Save the stopping point that we want to go to.
mov dword ptr ds:[12345678], edx ; save this in the total spot  

push edx
call paintfunction
cmp edx 0;
jz @_paintloop

Usually, I see this for when something is a certian size and the program needs to find where to start . So you can have a surface that starts at  700000 right? but the unlocked accessible part exists 500 bytes after that or something and if you were to start writing from the beginning you'd not see the first 500 bytes and that the image would be distorted.

I hope this answers your question. If you have an example, I can try to describe what this is doing but usually the compiler is trying to make function you gave work and keep it simple maybe not effective, but something that will work all of the time.
  • 1



Language that is commonly used in operating systems, compilers, and other low level programs.

Bucky Roberts Administrator