TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Russ Parks
date: 1996-01-27 12:46:04
subject: CSet++ and Asm

I've come across a problem combining CSet++ 2.0 and assembly language,
and hope someone here might be familiar with the idea (already checked
C_ECHO).

  The problem is accessing storage from ASM. The FSTCW requires writing a
16-bit word, but every time I try it, I get an access violation/page fault.
The problem isn't in the function declaration or anything like that,
because a simple FLD1 returns 1.0...just as it should, without any
exceptions raised.

  Is there some trick to declaring storage? The two words (in the DATA32
segment) below are only going to be used by other routines in the ASM file,
and not visible from C++ at all (no extern declarations or anything). I've
declared the segments in exactly the same way as the ASM output from the C
compiler. FWIW, I've tried declaring the two words in BSS and CONST32
segments, but still get the same SYS3175 exception...


  Here's the .ASM file (I'm using MASM 5.1)

        .386
        .387

CODE32  SEGMENT PARA USE32 PUBLIC 'CODE'
CODE32  ENDS

DATA32  SEGMENT PARA USE32 PUBLIC 'DATA'
        TempCw  DW  0                   ;Temp storage for use with the
        OldCw   DW  0                   ;80x87 control word
DATA32  ENDS

        ASSUME CS:CODE32, DS:DATA32

CODE32  SEGMENT

        PUBLIC  FPOWER__FrT1    ;A mangled name, of course :-)
FPOWER__FrT1    PROC

        fstcw   OldCw   ;This causes SYS3175 (acc. violation or page fault)

        fld1            ;A harmless instruction. It works right, too :)

        ret
FPOWER__FrT1    ENDP
CODE32  ENDS
END

  And the C source (though the function call works)...


#include 
#define PI  3.141592654
typedef long double extended;
extern extended FPOWER(extended num, extended pow);
main(int argc, char *argv[], char *envp[])
{
extended a, b, c;

    a = 2.0;
    b = 3.0;
    c = FPOWER(a, b);
    printf("%Lf ** %Lf = %Lf\n", a, b, c);
}


Thanx!,
Russ

..."Aw mom, you act like I'm not even wearing a bungee cord!"
--- EZQuote 4.0
* Origin: Linux: The choice of a GNU generation (1:170/200.12)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 170/200 400 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.