Including Assembly Code in C++ Programs
Results 1 to 6 of 6

Thread: Including Assembly Code in C++ Programs

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    19

    Question Including Assembly Code in C++ Programs

    I'm using the free Borland compiler (version 5.5) and I want to use assembly language in my programs... But I can't find out how in the help files. And the tutorial I'm learning C++ with says that each compiler's command is different and goes on to a different topic. Can someone help me? Thanks.
    ~TOXIC-RAM

  2. #2
    The Iceman Cometh
    Join Date
    Aug 2001
    Posts
    1,209
    As far as I know, Borland C++ (at least Turbo C++ and the original Borland C++ (not too sure about C++ Builder), doesn't allow you to integrate assembly language into your programs. Many C/C++ compilers out there are just that, and do not include separate assemblers to handle asm. There are separate programs from Borland (including tasm) which will do assembly language, but I'm not sure if you can somehow incorporate tasm into a C++ program. If I'm wrong, someone please correct me.

    AJ

  3. #3
    Senior Member
    Join Date
    Aug 2001
    Posts
    356
    try doing something like this:
    Code:
    _asm	
    	{		wait
    			fnstcw	old_cw
    			wait
    			mov	ax, word ptr old_cw
    			or	ah, 0xc
    			mov	word ptr new_cw,ax
    			fldcw	new_cw
    	}
    that exact code is used in some source i have and i know it will compile in msvc++("_asm" is a reserved word). obviously you would want to replace the code inside with whatever asm you wanted. give it a shot, you might get lucky
    -8-

    There are 10 types of people in this world: those who understand binary, and those who dont.

  4. #4
    The Iceman Cometh
    Join Date
    Aug 2001
    Posts
    1,209
    8*B@LL, Microsoft Visual C++ 6.0 (post SP4 or SP5, I think) and VC++.NET includes the C++ preprocessor pack which includes the ability to compile assembly language from within C++ programs. Before the preprocessor pack was released (it was released as a separate download for users of versions prior to SP4/5) you were required to install a separate assembler (I prefer masm) and configure the compiler to allow you to use that as a separate directive when compiling your programs. In my experiences with Borland prodcuts (which I used to use when I first started programming C/C++ as well as Pascal and Assembly Language) there is no way to incorporate this type of asm segement into C++ and have it compile correctly.

    AJ

  5. #5
    Senior Member
    Join Date
    Aug 2001
    Posts
    356
    ah, well like i said, it was just a "shot in the dark" so-to-speak.
    -8-

    There are 10 types of people in this world: those who understand binary, and those who dont.

  6. #6
    Junior Member
    Join Date
    Jul 2002
    Posts
    19
    Hey 8*B@LL, I tried what you said (_asm thing) and the compiler recognized it! But it then tried to run "tasm32.exe" and couldn't find it... I'm going to try to find out if TASM is free or not. Do you know anything about it? Thanks everyone for the info.

    EDIT: Never mind I found the full package of TASM32... In case anyone who reads this wants to get TASM also... Here is the link to the page: http://www.axe.empexed.net/html/tools.html. There are also other tools like UltraEdit and a disassembler.
    ~TOXIC-RAM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •