Thread View: borland.public.cppbuilder.language.basm
2 messages
2 total messages
Started by Spine
Wed, 05 Sep 2007 13:37
floating point asm
Author: Spine
Date: Wed, 05 Sep 2007 13:37
Date: Wed, 05 Sep 2007 13:37
26 lines
1411 bytes
1411 bytes
Hi,
I am just trying a bit around using assembler, and run into problems.
just multiplying integers a and b to res as result. this works fine.
int a = 2,b = 3,res;
for (int i=0;i<100;i++) {
__asm{
mov eax, a
mov ecx, b
mul ecx
mov res, eax
} }
then why does this not work? that is, it works fine for 4 iterations or so,
then it comes up with illegal flaoting point operation. even if I only have
"fld d_a" it throws the error.
double d_a = 1.1, d_b = 1.2, d_res;
for (int i=0;i<100;i++) {
__asm{
fld d_a
fmul d_b
fst d_res
} }
Sipke
Re: floating point asm
Author: Michael
Date: Sat, 12 Jan 2008 09:50
Date: Sat, 12 Jan 2008 09:50
35 lines
1995 bytes
1995 bytes
Spine wrote:
> Hi,
>
> I am just trying a bit around using assembler, and run into problems.
>
> just multiplying integers a and b to res as result. this works fine.
> int a = 2,b = 3,res;
> for (int i=0;i<100;i++) {
> __asm{
> mov eax, a
> mov ecx, b
> mul ecx
> mov res, eax
> } }
>
> then why does this not work? that is, it works fine for 4 iterations or so,
> then it comes up with illegal flaoting point operation. even if I only have
> "fld d_a" it throws the error.
> double d_a = 1.1, d_b = 1.2, d_res;
> for (int i=0;i<100;i++) {
> __asm{
> fld d_a
> fmul d_b
> fst d_res
> } }
>
> Sipke
Remember that x86 floating point assembler works on a stack, and stacks
can overflow. The code you have is pushing values onto the floating
point stack, but never popping them back off. Try changing the "fst" to
an "fstp", and see if it works.
- Michael
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads