Hi! I am new to assembly and i wanted to ask how difficult is to learn it. I am not an experienced programmer, i only know a little C, and i decided to learn assembly first and then continue with C. I hope i don't get a negative answer here!

Also, could anybody tell me some good tutorials? The truth is that i haven't searched google yet, although i know it can give some good results, because i wanted to know what you people recommend considering your own expirience.

And something else. Does assembly programming differs dramatically between Linux and Windows?

Thank you all in advance!
Posted on 2004-08-16 16:27:01 by patriziacharms993
It's not too hard to learn the basics of assembly, and win32 is very easy - I would suggest you start with http://www.madwizard.org/dl.php?file=tutors.win32asm . For programming windows, http://win32asm.cjb.net (Charles Petzold's "programming windows" is very good too, but not free).

I would suggest you learn C and Assembly at the same time, the two languages go along well. If you're stuck with a junk compiler, get the vc2003 toolkit from microsoft, it's one of the best x86 compilers and it's free - http://msdn.microsoft.com/visualc/vctoolkit2003/ .

The assembly itself doesn't really differ between win32 and linux, they're both 32bit protected mode operating systems. The way you interface with the OS is different though - with linux you're basically going to do libc/posix or syscalls, where windows has the rich win32 API.
Posted on 2004-08-16 16:50:31 by f0dder
Thank you for the reply!
The first link doesn't work though :(

I won't use the win32 API right? That's only for C.. Does assembly use it?

BTW Visual C++ Toolkit 2003 says that it is only for C/C++.. what about an assembly compiler?
Posted on 2004-08-17 07:05:26 by patriziacharms993
After searching this site a bit more i found some good tutorials :) Now i need a compiler, and to know that thing with the win32 API..
Posted on 2004-08-17 07:33:36 by patriziacharms993
Awww, the tutorials have went offline? The link worked, I think, less than a week ago :(

The Win32 API is, generally, what you use when programming windows (although Delphi and Borland C++ Builder have the VCL, .net languages have the .net framework, etc etc etc).

So, most programming languages have some "standard library", which means you can get at least a lot of work done without using the Win32 API. There's no unified standard library for assembly - sure there's a hodgepodge of stuff in the masm32 package, and HLA also has a library, etc... but you need the Win32 API to get stuff done.


BTW Visual C++ Toolkit 2003 says that it is only for C/C++.. what about an assembly compiler?

Yep, it's a C/C++ compiler (and one of the best for x86). As for an "assembly compiler" aka "assembler", there's a lot to choose from. MASM is probably the most wide spread and has most support, so it might be a good place to start. FASM (http://www.flatassembler.net) and GoASM (http://www.godevtool.com/) are also worth a look. You can get the MASM32 package at http://www.masm32.com/ .

When doing Win32 programming, you'll also need a Win32 reference. If you're on broadband, get the Platform SDK, http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm (you need internet explorer, otherwise some javascript will mess up). The contents of PSD (and more) can be searched online at http://msdn.microsoft.com/ .

If you're not on broadband, you might want to look for "win32.hlp" - I don't know where to get the best version of this, there's a couple floating around with different dates and filesizes, and at least one of them has a broken index making it just about unusable.
Posted on 2004-08-17 07:35:47 by f0dder
Oh, almost forgot: the Win32 API references (platform sdk, win32.hlp) are just that - references. Iczelion's tutorials (and Charles Petzold's Programming Windows) are better for learning the stuff (platform sdk is nicely indexed though)
Posted on 2004-08-17 07:37:29 by f0dder
>but you need the Win32 API to get stuff done.
you mean i will be able to call MsgBox and all of those functions in assembly? well, what if i want to program in console? i will not need the api?

also the platform sdk is very big! do you think it worths it to download it?


>Yep, it's a C/C++ compiler (and one of the best for x86)
what do you mean for x86? isn't it just fot c/c++?

thank you!
Posted on 2004-08-17 10:19:28 by patriziacharms993
Yes. Console as in 16bit dos or just console based? If it is 16bit dos, you would need to call the interrupts, while for 32bit console, you would need to call win32 api.

x86 is the "class" of cpu. P, PII, PIII, PIV, amd processors are all x86.
Posted on 2004-08-17 10:53:30 by roticv

you mean i will be able to call MsgBox and all of those functions in assembly?

Sure - that's part of the WIN32 API, and perfectly callable from assembly (and most other languages, for that matter).


well, what if i want to program in console? i will not need the api?

If you don't link with another library, yes. At the lowest level, all programs interface with the API (libc FILE* files end up with CreateFile/ReadFile/WriteFile/CloseHandle). On NT, you could use the NT native API, POSIX (if you want to be funky and not be able to do much), or syscalls. But you should generally stick to the WIN32 API...


also the platform sdk is very big! do you think it worths it to download it?

Yes, I think so. The information is better structured than win32.hlp, I also personally prefer htmlhelp to the old help format, and the information is more up-to-date. There's a whole bunch of examples too, although of course written in C. If you don't mind the old help format, you can get a long way with just win32.hlp... and you can always use online MSDN too. The download was worth it for me, though.


>Yep, it's a C/C++ compiler (and one of the best for x86)
what do you mean for x86? isn't it just fot c/c++?

x86 aka IA-32 aka "intel platforms"... What I mean is that it's one of the best C/C++ compilers for x86/IA32/callitwhatyouwant :)
Posted on 2004-08-17 10:55:04 by f0dder
oh thank you all very much! :)
So x86 are called all of the Intell proseccors right? That means that i won't be able to use the win32 x86 assembly i will learn on an Athlon machine?

If you don't link with another library, yes. At the lowest level, all programs interface with the API (libc FILE* files end up with CreateFile/ReadFile/WriteFile/CloseHandle). On NT, you could use the NT native API, POSIX (if you want to be funky and not be able to do much), or syscalls. But you should generally stick to the WIN32 API...

i don't get it :( i will program in a 32 bit console. Why would i need to use CreateFile and those other functions?
Posted on 2004-08-17 11:29:01 by patriziacharms993
how difficult is to learn it.


Not dificult in fact can be very easy to learn. I encourage that instead of learn x sintaxis of an assembler, first learn how a Xx86 computer work (in a eagle look... or some like that).

You will only make operations over memory: movement, comparations, general operations.

Also you can consider the registers memory without a address, but with a name.

Things that you should take care are (important things): take a look at the flags register and what things change the state of the register, see understand and imagine how the stack work, make operations in binary specially for understand for what mul need the double size of the operand. The memory ;), the memory of a programm how is organized.

About the FPU understand the format, we use a representation that have meaning for the FPU in general is one bit for sign, others for the exponent, and others for the mantissa, you should do some manula work specially with the called scientific notation in decimal, then do the same but with binary and the things called normalization is always move the point after the first significant 1 of the binary representation (and changind the exponent), the operations and the order of them require some practice and are done in the FPU registers (memory of the FPU with no address, but with a name).



Does assembly programming differs dramatically between Linux and Windows?


Yes, in fact for what f0dder say. When you enter to a diferent enviroment, you need know how to do things in the new enviroment, and see the diferences and equalities, for example you are in a unknow place and you whant to cut in the middle a page, there is no scissor, but you can use your hands for cut it. Yes the OS architecture, equal than the machine, in general the enviroment, impact what you do. You can find the Win32 programmers reference in the site of MinGW in the docs section (there are three diferents), also you can find one in the LCC site (that is refered in the NAGOA site IIRC, if not is the same, then you can find other there)



A comment, being you a "I am not an experienced programmer", you should see that for the machine there no exist diference between programms, even the OS, the thing is that you manipulate the memory for give you the meaning that you whant. Other thing, you should name the things like they are, or "las cosas como son" is some like 'the things like they are', that mean that you need diferentiate hll that the main point is abstract you from the machine and internals representations, and 'structured programming' that the point is have more organization and avoid spaguetti code. I know people that having suport in the language that they use for structured programming can make a mess of his programms because cant apply well or diferentiate the principles of structure in their programms, you should know that having one thing not mean that you understand that thing or even you can use it, but in a strange way or bad one.
Posted on 2004-08-17 11:42:22 by rea
ok thank you... i didn't understand all the things you said but i think i got your point :)
Posted on 2004-08-17 11:50:20 by patriziacharms993

That means that i won't be able to use the win32 x86 assembly i will learn on an Athlon machine?

Don't worry, you will - AMD copied the x86/IA32 architecture for the Athlon machines, so they are binary compatible.


i don't get it :( i will program in a 32 bit console. Why would i need to use CreateFile and those other functions?

I assume you want to actually do something with your programs? Like read and write files? :-)
Posted on 2004-08-17 11:55:41 by f0dder
hey thanks! but you use terminology i don't know :( What is AMD?
>I assume you want to actually do something with your programs? Like read and write files?
yes..but for simple console input output i will need anything from the api?

p.s Awww :( i didn't want to learn the api! Now i 'll have to learn 2 languages: the api and assembly :-( That is going to be hard..
Posted on 2004-08-17 12:10:10 by patriziacharms993
AMD, Advanced Micro Devices, http://www.amd.com , the guys who made the Athlon (etc).


yes..but for simple console input output i will need anything from the api?

Sure will, how else would you output anything?
You can either use the WriteConsole* functions, or the WriteFile with standard output.


p.s Awww :( i didn't want to learn the api! Now i 'll have to learn 2 languages: the api and assembly :-( That is going to be hard..

What else would you use, if not the API? There's no "write to screen" CPU instruction... also, you don't have to learn the entire API at once, just the tidbits you need.
Posted on 2004-08-17 12:16:21 by f0dder
Originally posted by f0dder

What else would you use, if not the API? There's no "write to screen" CPU instruction... also, you don't have to learn the entire API at once, just the tidbits you need.


Using in and out. :grin: Trying to code a driver is really a pain in the a**.
Posted on 2004-08-17 12:21:30 by roticv
AMD hehe I think in a game of words ;), but mean advanced micro devices.

Like roticv say, if you dont use the API and do a 16 bit console programm, you should instead learn the interrupts, nice.

That is because the enviroment, for example for C, they have normally the standar library, in fact the portability of the language remains in write the compiler for all the plataforms available, and port or rewrite the standar library, if you whant read some in C way, then you should use FILE *, open, close, seek, etc.


Yes, normally you will be covered by a enviroment, that you must lear how to use it, and the concepts. Also I say you, some things are still aplicable, if not completely, at less the principle, you still can open a file in others OS that you dont know with a function that they have for interact with the disck.



mmm, dont consider the API completely a language, best it consider like it say Application Programming INTERFACE, and that is the key point, mean that it will provide some concepts and ways to do things done. Because with a language, you normally can say any that you whant, and because this is a interface can be considered like a subset, and you can say things in a more easy way, but not all the things can be sayed with this subset. For example with this interface, you can say that you whant open a file, map to memory, and close the file. But you can not say with this interface all the things that you will do, for example add one to each byte. That is my explanation...

http://java.sun.com/docs/books/tutorial/java/concepts/interface.html
In English, an interface is a device or a system that unrelated entities use to interact. [...] but they call their interfaces protocols.


This is applicable to the win API, because when you whant to do operations over certain type of data, you should use the functions of the API that are designed for that, you should use the family of functions over the type, in some way can be considered a language, but more like some that impact the language in a way of protocols to follow or protocols to say what you whant.


Have a nice day or night.a yes, and "manula work" is manual work in the anterior post... ;)
Posted on 2004-08-17 12:39:07 by rea
ok thank you all!!! :) ( i hope i won't have a really hard time )
Posted on 2004-08-17 12:54:40 by patriziacharms993
bron,

You can obtain a copy of win32.hlp from:

http://flatassembler.net/docs/win32hlp.zip
Posted on 2004-08-18 04:56:15 by Vortex
thank you vortex! :)
Posted on 2004-08-18 05:23:27 by patriziacharms993