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