Any good assembly language tutorials?

Pages: 12
I am using windows 7 and i want to learn assembly, i downloaded this little compiler called Flat Assembly and i was wondering if anyone knew of any good tutorials, i looked on youtube and there werent any ones that really taught me anything so i guess video tutorials are out. Also is there any compiler that will allow me to use C++, C and assembly together?

Also is there any compiler that will allow me to use C++, C and assembly together?

I think GCC is an excellent choice for that.
If you're on Windows, go for Nuwen's MinGW distro.
ok so i installed it but what do i do now? was that a compiler?
Well any C++ compiler should let you do that:

In Visual C++ you can just write an .asm file and it will link it to your project.
Last edited on
ok i typed in asm{} in code blocks and it says

C:\Users\Chay Hawk\Desktop\assembly\main.cpp|3|error: expected '(' before '{' token|
C:\Users\Chay Hawk\Desktop\assembly\main.cpp|3|error: expected unqualified-id before '{' token|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|

#include <iostream>

using namespace std;

int main()

    return 0;



so i thought maybe it needed to go in a function but it still didnt work so what do i do?
Yes, it can only appear at block scope (inside a function or inside something else that's inside a function) - note the links below to the different compiler documentations.

(also, the standard form is with round parentheses, not curlies)
Last edited on
It has to go in a function.
ok so i cant write full assembly programs in those parenthesis right? from what i gathered from that link you can only write little snippets, also i got errors when i copy pasted that code:

C:\Users\CHAYHA~1\AppData\Local\Temp\ccgc4cOe.s|61|Error: bad register name `%rax'|
C:\Users\CHAYHA~1\AppData\Local\Temp\ccgc4cOe.s|62|Error: bad register name `%rdi'|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 1 seconds) ===|

also is there a difference between assembly languages? i dont want to find a tutorial site then learnb it to find out i learned something different or something like that, my pc has x86 architecture so i assume that means the 8086 assembly language. also what about a compiler? i know visual studio was mentioned but i really dont want to use that.
Yes, different CPU architectures have different assemblers. The code that you type in asm actually is compiled with your code.

C/++ compilers double as an assembler.

You can write full assembler programs in the parenthesis. I think CodeBlocks can compile .asm files but I never did it. Try it.
Last edited on
so i assume that means the 8086 assembly language.

Yes, you can then use the x86 assembly language. I don't know if you are using the term interchangeably, though '8086 assembly' refers to the initial instruction set of the 8086 microprocessor. New opcodes, registers and addressing modes have been added since then as new processors developed. x86 refers to all the instruction set as a whole, with the 'x' referring to the first of the last 3 digits denoting the name of the processor (80186, 80286 ect). Most programs use .386 for backwards compatibility purposes.

Visual c++ is shipped with the MASM assembler, and is assembled with your code upon using asm {}.

I am not aware of any tutorials at the moment. The way I learnt assembly was by studying the architecture of the CPU of my choice. Having even a brief overview of how everything works on hardware level can really enhance understanding. From then I didn't even need a tutorial, I just looked at the instruction set manual and experimented from then. Not the best way for everyone, it only helped me since I have a strong interest in computer/electrical engineering.
Last edited on
ok so basically assembly language is processor specific, i have an intel card and im going to get a new computer next month that has an Nvidia card so the assembly code would be different right? or the same?
Nvidia? What is the exact name of the card? Is the Nvidia card a mobile processor? If so, then it will be using the ARM architecture, you would need to use a different assembler.
Last edited on
im not sure here is the laptop and the specs and actually i got confused it does have an intel processor, Nvidia is the graphics card
Last edited on
Yes, so you would still use x86 assembly language. The graphics card is irrelevant in this case. Hope this helps.
Last edited on
ok so now im trying to use this with code blocks and it gives me these errors

||=== assembly, Debug ===|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|5|error: invalid suffix "h" on integer constant|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|9|error: invalid suffix "Dh" on integer constant|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|9|error: invalid suffix "Ah" on integer constant|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|9|error: invalid suffix "h" on integer constant|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|12|error: invalid digit "9" in octal constant|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|13|error: invalid suffix "h" on integer constant|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|16|error: invalid suffix "h" on integer constant|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\Assembly\main.cpp|5|error: expected string-literal before 'org'|
||=== Build finished: 8 errors, 0 warnings (0 minutes, 0 seconds) ===|

now i installed that mingw that catfish666 gave me earlier so do i have to actually configure it with code blocks or something? i just installe dit but didnt do anything with it.
I don't use code blocks so I am not the right person to ask.
Last edited on
Did you try adding a .asm file to the project like I instructed?
i dont know how to do that, i never done it before.
You should try using nasm instead for the assembler , it's open-source , cross platform and can output a variety of binary files.

And for the problem at hand , inline assembly is slightly different than normal assembly in that you need to very cautious about not messing with the registers that the compiler may be using for something else etc and the syntax is different for different compilers.
Here's a HOWTO,
Nasm :
Last edited on
By way of your question, @Ch1156, its because different assemblers use different syntax for the code. That is, MASM assembly code won't assemble in a NASM compiler and vice versa. Also, I think (though I'm not sure), that gcc uses a third syntax, or AT&T, rather than NASM or MASM, which is why are getting errors.
Pages: 12