The whole story.

I am a 16 years old kid from Sweden who would like to learn programming in the assembly language. I have been programming since I was 10 (luckily my generation had the oppertunity to play around in QBASIC at young age, so I easly learned how to "think" in code). I have worked with lots of languages, including Basic, Pascal, C / C++ but non of them are really my style. I want to do the real thing - I want to learn assembly.

I can tell you right now, I am not one of those annoying punks who wants to learn how to "create a computer game", I want increased knowledge in my computer, therefor I think ASM is the ideal choice.

Okey then, here are my questions:
First of all, do you think it's a good or bad idea to start directly with 32 bit ASM programming, without knowing too much about 16 bit ASM programming?
I do have one of the later versions of TASM somewhere, so I guess that one will do the trick for 16 bits applications. Whattabout 32 bit programming? What do I need? win32asm? masm32? I know there are a nice 32 bit tutorial at this forum. Do you know of any 16 bit one?

... I think you get the deal. Decide if 16 or 32 bit ASM programming are the way to go for a beginner, then what tools and guides I need.

Sincerely,
Psionicist
Posted on 2002-03-03 17:22:44 by Psionicist
I'd start with MASM32, later when you're more advanced you can step onto any assembler you like. But with MASM32 you get more support early one and an easier learning curve IMO.

Forget 16 bit. Go for 32 if you focus on windows. you can apply (almost) anything you learn in 32 bit mode to 16 bit mode except for the addressing. It's just not worth it anymore.

If you have the money buy a book like Petzold's "programming windows (5th or 6th edition) in c++", this will give you a clear insight in how to program windows using just the lowest forms of APIs (that is if you don't already have that knowledge)

Next visit http://win32asm.cjb.net, for more tutorials on the same thing but then in asm :)

Also get the latest Intel reference manuals, the URL Is on the board here somewhere in 'Main', I don't have it handy here right now.
Posted on 2002-03-03 17:39:11 by Hiroshimator
Here's a site that will help you with the basics of ASM - http://webster.cs.ucr.edu/ this tutorial might answer most of your questions. Just read a couple of pages on the 16 bit section then go directly to win32asm programming. Then follow what Hiro said. :)
Posted on 2002-03-03 17:47:41 by stryker
Thanks for you reply :)

I'm downloading MASM right now. This leads to one additional question...

What are win32asm?

This tutorial assumes that the reader knows how to use MASM. If you're not familiar with MASM, download win32asm.exe and study the text inside the package before going on with the tutorial. Good. You're now ready. Let's go!


Sincerely,
Psionicist
Posted on 2002-03-03 17:48:45 by Psionicist
win32asm is windows programming using assembly. You can download win32asm.exe at Iczelions site http://win32asm.cjb.net - first tutorial
Posted on 2002-03-03 17:49:46 by stryker

Here's a site that will help you with the basics of ASM - http://webster.cs.ucr.edu/ this tutorial might answer most of your questions. Just read a couple of pages on the 16 bit section then go directly to win32asm programming. Then follow what Hiro said. :)


Already bookmarked!

I downloaded that Art of Assembly book. Oh my that thing is HUGE! 1500 pages of something you don't really understand is scarry sometimes :)
Posted on 2002-03-03 17:51:30 by Psionicist
Dang, download problems. I have to download MASM again (tomorrow).

Do anyone have an URL to that Intel reference document?
Posted on 2002-03-03 18:06:55 by Psionicist
I think it's important to have some basic working knowledge of 16 bit code. Stryker's link above to Art of Assembly is some of the best intro info available. I think the 16 bit version is better to get you started. The 32 bit version is OK, but I wouldn't spend too much time with his HLA right now. It's "too different" and may confuse things, IMHO. Once you've digested AOA16, then I think you'll be ready for MASM32.

Many things are easier under the 32 bit flat model. For example no memory segmentation to worry about, so you don't need to know much about the segment registers. But I think it's still good to know what they are, and why ther're there. We also rarely use interrupts in this environment, so you don't need to spend much time with that topic.

Since you do have experience with other languages, by all means download MASM32, and take a look at the samples and tutorial source. You may find it easier than you think! But at the same time, spend a little time with AOA. :)

PS - One more thing. MASM32 includes everything you need to get you started with windows programming. But you will need some other stuff to really get going. You should get to know the MSDN site if you don't already. It has a tons of info, including the latest API and RESOURCE references. Sadly, most is written for the C programmer, but is usually easily "translated" to assem. You may also want to get WIN32.HLP and RC.HLP. They're older files, but they do contain good basis API and resource info. MSDN has the same, more updated info, but the .HLP files make a good quick reference, IMHO. You may also wish to consider a debugger. Very handy when learning assembly language, I think. OLYDBG is free, and many here like it. I use WINDBG, but may switch soon. :)
Posted on 2002-03-03 18:09:58 by S/390
http://developer.intel.com/design/pentium4/manuals/ there are 3 volumes to it.

edit()
You might also be interested with the platform SDK try searching MS's website.
Posted on 2002-03-03 18:10:42 by stryker
Psionicist,

The guys have given you some good advice here, Randy Hyde 16 bit AOA is good value as long as you stay away from the DOS specific stuff, segment addressing and so on. MASM32 is probably the easiest way to get into 32 bit assembler and a lot of guys here understand MASM well so you can get some help with it.

Just keep this in mind, 32 bit assembler is both easier to write and a lot more powerful as well. You have a heap of system functions you can use and you can work with large amounts of memory with no problems.

For documentation, the Intel manuals are the best for the architecture and instructions, WIN32.HLP is probably the fastest way to get used to thew API functions and you can use MSDN CDs or online for the later stuff.

Regards,

hutch@movsd.com
Posted on 2002-03-03 19:56:00 by hutch--
Start with 32bit programming, you can always learn 16bit later if
you feel the need. 32bit is simpler, and a hell of a lot less scary.
If you're on broadband (I know a lot of you darn swedes have
fast and cheap lines ;)), you might want to download the PlatformSDK
from microsoft (somewhere at http://msdn.microsoft.com , shouldn't
be too hard to find), it's the best and most up to date API reference.

www.madwizard.org has some tutorial stuff that looks OK.

Other than that... read, google, disassemble your highlevel apps,
run your highlevel apps through a asm-level debugger (olly), and
study what happens. (Wait with the disasm+debug until you have
an okay idea of the basic stuff.)
Posted on 2002-03-03 20:04:43 by f0dder
Considering the trend of your programming, (from Qbasic to C++ and now onto assembly language), I guessing its the details that fascinate you, so here's my two cents.

If you want to end up writing practical application for windows, you probably won't directly use most of the information I suggest you find, but it will take a lot of the mystery out of what your OS is doing.

Before bothering youself too much with actually asm coding, take a little time to learn about your hardware. Start with the general architecture of the PC. Even an older book will give you a good start, and you should be able to find one cheap. Try to get a grasp of memory addressing (real mode and protected), and familiarize yourself with interupts and dealing with BIOS. You could probably get a good idea of how DOS functions in a matter of hours, and understanding DOS helps understand why Microsoft structured Windows the way it did. (and understanding UNIX explains the rest.)

Next, delve into the 386 and later proccesors. Check out intel's site for documents. Get a good understanding of both real mode and protected mode. Most people will tell you that win32 isn't a segmented memory model, but it helps to recognize that although you probably won't mess with segments in your code, protected mode operations are ALL about segmentation. (When that lovely general protection fault window pops up, it easy to spot a problem with the segment registers)

Now tackle assembler. Read both of Hyde's AoA's. Write a few simple programs in his HLA, compile them to masm32 code, and disect the output.
Read a few tuts on win32 in C as an intro to dealing with the API, because most of win32asm programing is merely passing parameters to API functions.
Read Iczelion's tuts. Find a Win32 API help file.
Study executable file formats.
From there, I think you'll no where to go. Along the way, check out info on Alan Turing and Von Newman to understand why these machines are the way they are. If you have the time, read up on Boolean logic, George Cantor and set theory, the Viena Circle, and Godel. If you're looking for inspiration, Douglas Hofstadler is a sure bet, and anyone from the Santa Fe Institute should get you excited, especially John Holland. It's my assertion that only assembly language programmers can fully appreciate these guy's ideas.

And if your just doing this for fun....use nasm. :)
Posted on 2002-03-04 05:29:10 by Canite
Thanks for all replies! :)

I think I have SoftICE somewhere, but I better get the latest version because I haven't used that one for some years. I do have Visual Studio 6 Enterprise ed. and the MSDN libraries, I guess I can use some of the tools there? IIRC there are some version of the Platform SDK included, and I can hopefully update it trough the msdn network.

Re hardware, I do know things about hardware. I don't really know how every single detail works except for the important things (the BIOS, IRQs and so on), but I can "build" a computer (so to say), configure it correctly, troubleshoot it, optimize it then overclock it as much as possible (that is keeping a 100% stable level). I will however read more about it as you recommended.

Most of you agrees I should read some of the material on 16 bit programming, then start directly with 32 bit programming. Then I will!

I will also get the following tools and documents:
- MASM32
- win32asm.exe package
- The two AoA books
- The three Intel architechture reference documents
- Platform SDK
- SoftICE
- API reference. I found a large zip at borland. I hope it will do the trick :)

Is there anything else I need? Maybe a text editor?

Sincerely,
Psionicist
Posted on 2002-03-04 07:38:51 by Psionicist


[...]
Is there anything else I need? Maybe a text editor?
[...]



Nope, we all program with



C:\>echo mov ecx, eax >> myprog.asm


:grin:
Posted on 2002-03-04 07:50:51 by bazik


[...] I am a 16 years old kid [...]
[...] I think I have SoftICE somewhere [...]
[...] I do have Visual Studio 6 Enterprise ed. and the MSDN libraries [...]



Seems like you have rich parents, eh? ;)
Posted on 2002-03-04 07:54:58 by bazik
C:\>echo mov ecx, eax >> myprog.asm

Shhhhhhhhhhhh, thats a secret like programming in HEX. :grin:

Regards,

hutch@movsd.com
Posted on 2002-03-04 08:02:51 by hutch--
Bah! That doesn't scare me (I know what you are talking about, that is) :)
Posted on 2002-03-04 08:44:22 by Psionicist
The masm32 package includes Hutch's Quick Editor. Some seem to dislike it, but it does the job. It's small and simple, which means you'll spend less time learning about your editor and more time learning about programming.
Posted on 2002-03-04 12:54:05 by Canite
common advice:

learning WinAPI and asm (also C in my case) at the same time could be no joy. if you want to learn asm commands as opposed to WinAPI, start a project with only invoke ExitProcess function at the end and write all asm you want to learn before it. Then analyse what's happening and output in a debbuger (I use to start Olly from Radasm usertools menu, later I can shutdown it with alt-x, recompile and start again in one click - very handy) or in a message box. Very simple advice (I think it was Thomas who posted it), but it got me going again when I felt lost in API details and abbandoned my first project after a week or so.
Posted on 2002-03-04 15:13:53 by ramzez