Just reading in a C++ book that you can literally drop assembler into C++ by just using the asm keyword.
Does this mean, if one wanted to use Visual Studio to write assembler I could simply create a C++ main method and then drop assembler into that and execute it as a C++ program? The compiler would simply run the assembler-embedded C++ as if it was only an assembler program?
My question originates from a lack of a decent IDE for Assembler.
When you use a C++ compiler, it will add extra code to your program that is not in int main()
. If you ever decompile a simple hello world program, you will notice it begins execution far before int main()
, calling a few functions such as _set_app_type
and _getmainargs
and then eventually calls your int main()
. The most interesting thing to you would probably be the call to _getmainargs
as it gets the command line arguments for your program. If you were to compile your assembly with an assembler such as NASM, FASM or even GAS, it would not make calls to _getmainargs
and others so you as a programmer would have to implement your own way to get command line arguments which can be tricky for beginners.
As long as you specify your __asm
with the volatile
keyword, the compiler should not tinker with your assembly code and it will run (that specific code) as if it was an "
Assembler program".
If you are looking for an IDE for assembly, I can tell you I have been down the same path. I use FASM which is a great little IDE but there are plugins for Eclipse and even Visual Studio though I can't say I have had good experiences with them.
Edit: I'd like to add that if you are learning assembly, you are probably better off learning it with an assembler. The common uses of assembly are used when C++ or a higher language cannot be, therefore if you become dependent on a C++ compiler and inline assembly syntax it could likely cause confusion when you try to write raw assembly.