How to use Assembler/BAL in C++?

This is a discussion on How to use Assembler/BAL in C++? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Does anyone know how I can get code that I write in Assembler (also called: System 370, PC 370, Mainframe ...

  1. #1
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    How to use Assembler/BAL in C++?

    Does anyone know how I can get code that I write in Assembler (also called: System 370, PC 370, Mainframe Assembler, Basic Assembler Language (BAL), and others) to be used in C++. I was thinking of assembling it into .OBJ code, and adding it into an object module library, but then how do I manage USING that code once it's in a c++ program?<br><br><hr>
    Sean Mackrory<br>sean_mackrory@hotmail.com

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Well, assembly commands can be done by inline assembly, which assumes you can make your compiler do it.

    To do it the way you're suggesting, by compiling an OBJ, works as well. You must make subroutines (aka functions) that follow the C calling conventions (all parameters pushed onto the stack, last param first, result in eax, you may not change ebp, ebx, or any of the segment registers).

    Then, in the C file or a header, declare an extern function (extern "C" if using C++), and link the OBJ.

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    Crap.....

    Uh oh.... that's not the assembler I learned.... Is this the same as Mainframe assembler (if you're familiar with Bill Qualls PC370 system, this would help).

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    You need to know the calling conventions of the system you're using. This obviously isn't for an x86 application, so I can't help much, but the theory you have is sound -- you just need to know how parameters are passed and what rules your assembly functions must follow.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21