Arrays, Floats and doubles on inline ASM?
hi,
I'm trying to figure out how to use array and floats with asm
for example
int nOp1 = 10;
int nOp2 = 2;
Code:
int nOp1 = 10;
int nOp2 = 5;
__asm mov eax, nOp1;
__asm add eax, nOp2;
in this case the result of eax = 15
Code:
float fOp1 = 10.5f;
float fOp2 = 3.07f;
__asm mov eax, fOp1;
__asm add eax, fOp2;
in this case the result of eax = -4.3434515e-038
next problem i have i using array structures (stored in vector)
Code:
pCodes.push_back( OpCode( OC_MOV, a ) );
pCodes.push_back( OpCode( OC_ADD, b ) );
pCodes.push_back( OpCode( OC_MOVR, r ) );
to store the execution of the opcode (r = a + b)
Code:
pOC = pCodes[nCode];
__asm mov eax, pOC.Data
this part of code is working
Code:
__asm mov eax, pCodes[nCode];.Data
this ain't :
warning C4537: 'nCode' : '.' applied to non-UDT type
error C2410: 'Data' : ambiguous member name in 'second operand'
Re: Arrays, Floats and doubles on inline ASM?
Quote:
Originally posted by Nigh™a®e
hi,
I'm trying to figure out how to use array and floats with asm
for example
int nOp1 = 10;
int nOp2 = 2;
Code:
int nOp1 = 10;
int nOp2 = 5;
__asm mov eax, nOp1;
__asm add eax, nOp2;
in this case the result of eax = 15
Code:
float fOp1 = 10.5f;
float fOp2 = 3.07f;
__asm mov eax, fOp1;
__asm add eax, fOp2;
in this case the result of eax = -4.3434515e-038
next problem i have i using array structures (stored in vector)
Code:
pCodes.push_back( OpCode( OC_MOV, a ) );
pCodes.push_back( OpCode( OC_ADD, b ) );
pCodes.push_back( OpCode( OC_MOVR, r ) );
to store the execution of the opcode (r = a + b)
Code:
pOC = pCodes[nCode];
__asm mov eax, pOC.Data
this part of code is working
Code:
__asm mov eax, pCodes[nCode];.Data
this ain't :
warning C4537: 'nCode' : '.' applied to non-UDT type
error C2410: 'Data' : ambiguous member name in 'second operand'
The problem your having with doing floating point numbers is because your talking to the wrong processor / unit. When doing calculations for floating point numbers, you have to use the FPU (Floating Point Unit).
You can't work with arrays the C++ way in ASM. You have to do it the ASM way, IE: you use offsets to move through the array.