www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



c++ - DMC Compiler error in __asm section

↑ ↓ ← Glenn Lewis <nospam no.spam.net> writes:
Hi!  I've got code that looks like this:
__asm
{
	L4:		FCHS;
	L5:		FADD     ST(3),ST(0);
	L6:		FXCH     ST(1);
	L15:		FSUB     ST(0),ST(3);
}
and the DMC (v849) compiler reports the errors:
ad_high.cpp(101) : Error: Illegal type/size of operands for the
fadd instruction
ad_high.cpp(103) : Error: Illegal type/size of operands for the
fsub instruction
This compiles fine with Microsoft C++ Professional 6.0.
Any ideas what's wrong?
Thanks!
-- Glenn Lewis
Feb 20 2007
↑ ↓ Walter Bright <newshound digitalmars.com> writes:
Glenn Lewis wrote:
 Hi!  I've got code that looks like this:
 __asm
 {
 	L4:		FCHS;
 	L5:		FADD     ST(3),ST(0);
 	L6:		FXCH     ST(1);
 	L15:		FSUB     ST(0),ST(3);
 }
 and the DMC (v849) compiler reports the errors:
 ad_high.cpp(101) : Error: Illegal type/size of operands for the
 fadd instruction
 ad_high.cpp(103) : Error: Illegal type/size of operands for the
 fsub instruction
 This compiles fine with Microsoft C++ Professional 6.0.
 Any ideas what's wrong?

The ST(0) register value is implied, so just use: FADD ST(3); for example.
Feb 28 2007
→ Glenn Lewis <nospam nospam.net> writes:
OK, so I'm assuming that the ST(0) is implied as well in FSUB, to
give me:
FSUB ST(3);
Thanks.
-- Glenn
Feb 28 2007
Glenn Lewis <nospam nospam.net> writes:
Unfortunately, I'm still stuck... I'm told that this is compilable by any ANSI
Standard C compiler... maybe the company that generated this code is
wrong.  Here's what I tried:

        ruby -p -e "if ($_ =~ /FSUB/); $_.gsub!(/,ST\(0\)/, ''); end; if ($_ =~
/FADD/); $_.gsub!(/ST\(0\),/, ''); end" ad_close.cpp > tmp.cpp
        dmc -c tmp.cpp -o ad_close.obj
tmp.cpp:
        L4:             FSUB     ST(1);
        ^
tmp.cpp(91) : Warning 13: Illegal type/size of operands for the fsub instruction
        L5:             FADD     dword ptr [ESI+20];
        ^
tmp.cpp(92) : Warning 13: Illegal type/size of operands for the fsub instruction
        L9:             FMUL     dword ptr [ESI+200];
        ^
tmp.cpp(96) : Error: Illegal type/size of operands for the fadd instruction
        L12:            FADD     ST(1),ST(0);
        ^
tmp.cpp(99) : Warning 13: Illegal type/size of operands for the fadd instruction
        L13:            FSUB     dword ptr [ESI+16];
        ^
tmp.cpp(100) : Error: Illegal type/size of operands for the fadd instruction
        L15:            FDIV     dword ptr [ESI+176];
        ^
tmp.cpp(102) : Error: Illegal type/size of operands for the fdiv instruction
        L19:            FCOMI    ST(0),ST(2);
        ^
tmp.cpp(106) : Warning 13: Illegal type/size of operands for the fadd
instruction
        L20:            FCMOVNB  ST(0),ST(3);
        ^
tmp.cpp(107) : Error: Illegal type/size of operands for the fcomi instruction
        L23:            FADD     ST(1);
        ^
tmp.cpp(110) : Warning 13: Illegal type/size of operands for the fsub
instruction
        L24:            FADD     ST(0);
        ^
tmp.cpp(111) : Warning 13: Illegal type/size of operands for the fadd
instruction
        L25:            FCOMI    ST(0),ST(3);
        ^
tmp.cpp(112) : Warning 13: Illegal type/size of operands for the fadd
instruction
        L26:            FSUB     ST(0);
        ^
tmp.cpp(113) : Error: Illegal type/size of operands for the fcomi instruction

Unfortunately, the compiler spits out the line *after* the error, but you get
the general idea.
-- Glenn Lewis
Feb 28 2007
↑ ↓ → Walter Bright <newshound digitalmars.com> writes:
Glenn Lewis wrote:
 Unfortunately, I'm still stuck... I'm told that this is compilable by any ANSI
Standard C compiler... maybe the company that generated this code is
 wrong.

Whoever told you that was in error, Standard C doesn't specify inline assembler. Try this:
 __asm
 {
         L4:             FCHS
         L5:             FADD     ST,ST(3)
         L6:             FXCH     ST(1)
         L15:            FSUBR    ST(3),ST
 }

Mar 01 2007
Glenn Lewis <nospam nospam.net> writes:
Since I continue to get more and more errors with the __asm section
from DMC, and since it compiles fine with MSVC++6.0, is it possible
to go and ahead compile this code with MS Visual C++ 6.0 and then
link it into my D program?
I can't seem to get that to work either.
Thanks!
-- Glenn Lewis
Mar 01 2007
↑ ↓ → Walter Bright <newshound digitalmars.com> writes:
Glenn Lewis wrote:
 Since I continue to get more and more errors with the __asm section
 from DMC, and since it compiles fine with MSVC++6.0, is it possible
 to go and ahead compile this code with MS Visual C++ 6.0 and then
 link it into my D program?
 I can't seem to get that to work either.

The inline asm errors are all fixable, they are probably only one or two things going awry. Easier to address them one by one.
Mar 02 2007