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?
Yes, it can only appear at block scope (inside a function or inside something else that's inside a function) http://en.cppreference.com/w/cpp/language/asm - note the links below to the different compiler documentations.
(also, the standard form is with round parentheses, not curlies)
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.
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.
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.
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.
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, http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
Nasm : http://nasm.us
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.