TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: WOUTER DANES
from: PAUL MADDOX
date: 1997-03-16 16:09:00
subject: C++

Hi.
WD> could you please tell me how to do inline assembler in watcom 
WD> c++? (don't know the syntax... it's asm {} in bc.. but wc 
WD> 10.6 doesn't know asm{}..) thanks... 
This is from a FAQ I found on Compuserve. It's called WATCOM.FAQ.
----
Q. How do I use inline assembly? Why doesn't my old Borland C/C++ program
   compile correctly with asm { }?
 
A. Inline assembly is quite different in WATCOM C/C++ than in other
   compilers. The "asm {}" construct is in the ANSI standard, but may
   (according to the standard) simply treat it as comment, which WATCOM
   does.
    The mechanism for inline assembly in WCC++ is using the #pragma aux.
   The advantage is that registers are defined for input and output, and
   the compiler will optimize the code generated (something Borland and MSC
   don't do). Here is an example:
 
unsigned short int10(short,short,short,short);
 
#pragma aux int10 =             \
    "int 10H"                   \
    parm [ax] [bx] [cx] [dx]    \
    value[ax];
 
OR:
 
unsigned char GetRow(void);
 
#pragma aux GetRow =            \
    "mov ax,0300H"              \
    "mov bh,0"                  \
    "int 10H"                   \
    modify [ax bx cx dx]        \
    value [dh];
 
    Now, you need only use it like a function within your program!
---
I hope this has been some help. This isn't /quite/ as convienient
as asm{}, but it works. And that's good enough for me.
TTFN - Paul.
 --- cPoint 2.17         
---------------
* Origin: Nowhere, man. (paul.maddox@zetnet.co.uk) (2:250/102.23)

SOURCE: echomail via exec-pc

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™.