Question about assembly programming

Started by
3 comments, last by RobTheBloke 15 years, 11 months ago
Correct me if I'm wrong, but with assembly, you can just type it into any compiler such as one for C++ or C#, right?
-----------------------------------------"With the mind, anything is possible"
Advertisement
No. Assembly language has a specialized compiler just like any other language, although compilers for Assembly are more often referred to as assemblers.

A popular choice is NASM.
Some C/C++ compilers accept inline assembly, but the syntax varies from compiler to compiler.
Firstly a small correction: you don't type into your compiler, you type into a text-editor (which is probably part of an IDE, or Integrated Development Environment). Your compiler may in some cases (it varies from language to language and even for different compilers for the same language) generate assembly from a higher level language (such as C) before passing it on to an assembler to generate machine-code/an executable. If you'd like to learn a bit more about this process, have a search for resources on "build process" or "program compilation/assembly".

Now, what you're talking about is generally referred to as inline assembly, the idea being that you'll probably write most of your program in your higher level language (C, C++, whatever) of choice but have a few sections written in assembly for speed or efficiency reasons (or perhaps just because you're trying it out for educational purposes). This is supported differently by different compilers (and isn't always possible), and you'll need to check the documentation of whatever you're using to see if and how it's supported. If you tell us which tool(s) you're using we may be able to offer more advice.


If you just want to write programs using pure assembly you could try a tool such as MASM or NASM.

Does that help?

- Jason Astle-Adams

Quote:Original post by jbadams
If you just want to write programs using pure assembly you could try a tool such as MASM or NASM.


alternatively use the compiler intrinsics instead.

This topic is closed to new replies.

Advertisement