I have a task – calculate 6 results of function (Y = (20 * x) /(5 * x2 – 8,5)) the x – start from 1 and each calculation must increas by 4 (1, 5, 9 ..).
I write some code but i dont understand how to made loop and put data to array. All operation must be on asm – loop and put to array, 1 iteration – 1 element in array
There is my code:
int main()
{
float REZ[6];
int x = 1;
int A =5;
int B=20;
float C = 8.5;
int D =2000;
int increment = 4;
float part;
float val;
_asm{
finit
fild x
fimul x
fimul A
fsub C
fstp part
fild D
fimul x
fdiv part
fstp val
}
}
My assembly times are long gone, but I’ll try. A loop in assembly is done by defining a label and jumping to this label. Depending on the loop, it is a conditional jump (after some comparison):
Pseudo assembly:
Look at X86 Assembly/Control Flow for details.
Or unconditional jump:
Another way to learn about assembly is looking at compiler output. See for example:
Tell gcc to stop at assembly output:
and look for the resulting
loop.s