delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/02/04:07:35

From: csgcty AT singnet DOT com DOT sg
Date: Sat, 2 Aug 1997 16:06:06 +0800 (SST)
Message-Id: <199708020806.QAA25712@wisteria.singnet.com.sg>
Mime-Version: 1.0
To: djgpp AT delorie DOT com
Subject: NASM question

Hello !

I am not sure if this is the appropriate forum for a NASM question, but I am
usng it together with djgpp...so here is the question :

I was trying out the FPU instructions (just FLD, FMUL and FST/FSTP). It
appeared that everything worked fine when I used FST but when I used FSTP,
the result went wrong. The code appears below.

Also, it appears that I can't use FMUL without operands in NASM. 

I would greatly appreciate any assistance.
Thanks in advance.

Chan Tze Yi
csgcty AT singnet DOT com DOT sg

PS : Please reply by email because I no longer subscribe to the mailing list.

***start of asm file***
[BITS 32]

[GLOBAL _fp]

[SECTION .text]

;extern float fp(float a,float b)
fp_a equ 8
fp_b equ 12

_fp:
    push ebp
    mov ebp,esp

    fld dword [ebp+fp_a]
    fmul dword [ebp+fp_b]
    fstp dword [result] <------ this is the line
    fwait               <------ is this necessary ?

    mov eax,[result]
    shrd edx,eax,16

    mov esp,ebp
    pop ebp
    ret

[SECTION .data]

result dd 0.0


***start of cpp file***
#include <stdio.h>

extern "C" float fp(float a,float b);

void main()
{   float a=1,b;
	while(a!=0)
    {	scanf("%f %f",&a,&b);
	 	printf("%f\n",fp(a,b));
   	}
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019