c++ - How do I move the result of a mul of two floats in x86 assembly? -
i trying multiply 2 floats, 1 comes float vector (address stored in ebx) , against value stored in ecx.
i have confirmed input values correct, however, if multiply 32 , 1, example, value in eax changes 00000000 , 1 in edx 105f0000. understanding of mul, happens because storing high order bits of result in edx , low order ones in edx. question is, how move result output variable (returnvalue) ? here code snippet in question:
addcolumnsiteration: cmp esi, 4 // if finished storing info jge nextcolumn // move next column mov eax, [ebx][esi * sizeof_int] // current column mul ecx // multiply tx add together [returnvalue][esi * sizeof_int], eax // add together info pointed @ eax running total inc esi // element x, y, z, or w of vec4 jmp addcolumnsiteration // go check our loop status
i aware if used x87 commands or sse instructions, orders of magnitude easier, constrains of problem require pure x86 assembly code. sorry if seems kinda basic, still learning idiosyncracies of assembly.
thank in advance help , have nice day
you’re multiplying representations of floating-point numbers integers, rather floating-point numbers themselves:
1.0 = 0x3f800000 32.0 = 0x42000000 0x3f800000 * 0x42000000 = 0x105f000000000000
to floating-point arithmetic, need 1 of following:
use x87. use sse. write own software multiplication separates encodings signbit, exponent, , significand, xors signbits sign bit of product, adds exponents , adjusts bias exponent of product, multiplies significands , rounds significand of product, assembles them produce result.obviously, first 2 options much simpler, sounds aren’t alternative reason or (though can’t imagine why not; x87 , sse are "pure x86 assembly code”, they’ve been part of isa long time now).
c++ assembly floating-point x86 multiplication
No comments:
Post a Comment