Article View: borland.public.cppbuilder.language.basm
Article #40Re: floating point asm
From: 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
Technical Details
Message-ID:
<47888da3$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feeder6.cambrium.nl!feed.tweaknews.nl!news.astraweb.com!newsrouter-eu.astraweb.com!newsfeed2.ip.tiscali.net!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<46dfc4ba$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 107b11,2ff544b33be6fabc X-Google-Attributes: gid107b11,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Sat, 12 Jan 2008 02:50:33 -0700 From: Michael <zrax@comcast.net> User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.language.basm Subject: Re: floating point asm References: <46dfc4ba$1@newsgroups.borland.com> In-Reply-To: <46dfc4ba$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 76.113.93.105 Message-ID: <47888da3$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1200131491 76.113.93.105 (12 Jan 2008 01:51:31 -0700) Lines: 35 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder2.cambrium.nl!feeder6.cambrium.nl!feed.tweaknews.nl!news.astraweb.com!newsrouter-eu.astraweb.com!newsfeed2.ip.tiscali.net!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail