I recently fell into an interest of learning assembly language.
The best way i guess is to learn by messing around with simple variables and "Hello World" type programs.
I tried a website tutorial that asked me to download an assembler/linker called FASM. I must have been doing something wrong because the tutorial seemed to make absolutely no sense to me and it got me nowhere.
Can anyone offer any advice, references, tutorials, suggestions? I really want to learn introductory level Assembly language.
To really "get" assembly, you'll need to learn the concepts behind how the system works.
Concepts that you should know (in no particular order, and most likely incomplete), include:
Control Structures - how do we control the flow of our program?
Memory - how is data stored?
Pointers - how do we access memory locations?
Registers - how do we actually perform calculations on values in our program?
Stacks - what do we keep on the stack, how is it arranged, and how do we access it?
After you have a solid understanding of minimally the above topics, it's time to start pulling your hair out experimenting.
You'll also have to pick a target architecture to learn - I'd recommend x86.
Most programming languages make the "Hello world!" project as their starting project, however Assembly is an exception. To print "Hello world!" to the screen you need to know about registers, segment addressing, interrupts. Also basic instructions for assigning values to registers. In other words, a lot of work before actually printing something.
Actually, what you do and what you don't need to know pretty much depends on what system you're working on. E.g. on our uni we worked with microcontrollers with displays that I believe were memory mapped.
I think hello world is actually pretty easy in most situations - all you need to know is how to declare a string, how to set up the string output system call, and how to terminate a program. Although yes, it includes assigning values to registers.
As a general advice: choose your platform, as Luc Lieber rightfully said.
Assembly is the language of the CPU, and each CPU architecture (sparc, mips, ppc, arm, x86, itanium, various microcontrollers) is completely different, only a few very generic architectural concepts are common.
Even within a given architecture, there may be major different options (16-bit realmode vs. 32-bit protmode vs x86_64, for example) and additional commands available (x86 just keeps rolling out those SSEs).
Besides the platform, choose the environment. You could be writing
* a freestanding program (bootloader/OS kernel), which has to do everything by directly accessing the hardware.
* kernel mode OS drivers or driver components, in which case you can access internal functions of the OS kernel to interact with it
* a usermode application that relies on the normal OS system calls to access hardware
* a module that is a part of a C or some other higher language project, in which case the C (or other language) standard library as well as all the other libraries linked with the project, are avaiable: you can printf() straight from assembly.
As a linux fan, I think linux assembly is pretty easy, and you can enjoy the convenience of all of its POSIX-style system calls without even linking the C library.
@BHXSpecter: you need to link against the C runtime so that there is something that calls your _main, and you need to link against the C library so that there is a _printf for you to call... on second thought, gcc's linker should have done that for you. Just rename _main to main and _printf to printf.
On Linux, it's easy to skip the whole C business and have an assembly-only program.