Hi Henry,
> How different is assembly on Linux and Windows?
Depends on how you look at it, I guess. You're talking to the same CPU, and it understands the same instructions (depending on CPU version - they're always adding new ones, but the old ones still work). Much assembly code - calculating "strlen", for example - doesn't care what OS it's running on. But when you have to interact with the OS, it requires a different sequence of instructions. And you *do* need to interact with the OS, if only to exit your program (a detail HLLs do for you - but it still needs to be done!)
Windows:
push 0 ; "exitcode" or "errorcode", zero usually means "no error"
call ExitProcess ; Windows provides this code
Linux:
mov ebx, 0 ; exitcode, as above
mov eax, 1 ; tell int 80h we want the "exit" function
int 80h ; Linux provides this code
Doing something like printing "hello world" or asking the user for his/her name would differ in a similar way, but moreso. When we get to GUI programming, the differences are even greater. In Windows, the GUI is part of the OS, in Linux, it's a separate program running as a "server". But you're still using the same instructions, and there are "parallels" as well as the differences.
> Assembly is the language that computer understands but in a more readable form,
> right?
Right. For certain values of "readable". :)
> I've been interested in game hacking and used program called Cheat Engine(on
> Windows) a lot. It has "auto assembler" function, can someone tell if it uses
> same code as nasm?
I'm not familiar with it. I doubt if it's the same, but it might be. Can you post a sample?
> What is assmebly good for? What do you use it for?
I personally only use it for "fun". It's "good for" CPU-specific things that C (being portable) doesn't know about. Not too much, these days, actually...
> Is it possible to include assembly in C++ code? (It's a bit different format
> propably)
Yes, a couple of different ways. Most compilers allow "inline assembly". The syntax differs wildly - mostly not too close to Nasm. :( Or you can write a separate module in assembly, assemble it to an .o or .obj file, and link it with C or C++ code that calls it. Michael was even showing me how to link asm code with Fortran! C++ is slightly more complicated in that it "decorates" (mutilates!) function names. You can either learn the naming scheme - which differs between compilers - even versions of the same compiler, I'm told - or you can prototype your function as extern "C" myfunc. The latter is obviously easier, although you might lose some of the advantages of C++(???).
This is probably the most "practical" way to use asm. I'm a "do it yourself" kind of guy, and I like all-asm, self-contained, no libraries, "pure asm". This obviously isn't suitable for "serious" projects (although it can be done!). But writing modules in asm - as few or as many as you like - and "tying them together" with C(++)... we can even get "portability" across Windows/Linux/BSD/MacOS(?)...
In fact, Dr. Paul Carter's tutorial depends on this - lets C deal with the OS, and presents examples as "asm_main", to be called from a C "driver". This allows the same code to run on Windows/Linux/BSD/???. It *does* need to be assembled into linkable object files in different formats, but Nasm's capable of that.
http://www.drpaulcarter.com/pcasmTake a look at it and see if it's something you're interested in.
Best,
Frank