Advertisement Jump to content


This topic is now archived and is closed to further replies.


asm tutorials

This topic is 5335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I was wondering if anybody happened to know of an excelent asm beginner tutorial, I have no asm experiance just c++ and java.

Share this post

Link to post
Share on other sites
This is a pretty good place to learn assembly, although I haven''t used it too much so I can''t comment that much. This should get you started though.

Share this post

Link to post
Share on other sites
Iczelion's Win32 tutorials are helpful, but a little biased toward masm32. Read vol 1 of the IA-32 manual on the intel site. The whole thing's one continuous tutorial. Buying a book (I think Assembly Lang step-by-step is great) is probably the best method to teach yourself the basics (memory models, commonly-used general purpose instructions, how to use a debugger, how to use a certain assembler (said book is nasm16), how to program for linux and dos, the history of x86 architecture, terminology, how a processor works kind of stuff, etc.).

edit: Here are some links from my bookmarks:

These links are very valuable b/c they'll save you countless hours trying to find them! So copy them to a text file or bookmark them.

Further advice: You'll get frustrated a lot (I still am, I just started as well), with your ide, assembler, and linker, and maybe even discouraged, but don't give up, there are a lot of aspects I've found I like better than VC++ programming. That's while i'm still sticking with it. Right now I got my first win32 window up and am starting a simple opengl program. I'm about to start scanning through vol 2 of the IA-32 manual, b/c it's really helpful! You learn a lot reading that. You may encounter the exact same problems I've had the past few weeks, if you plan to use a free package. Me, I'm using nasmw (started with nasm16 with book), alink, and nagoa ide (only nagoa b/c I can't get the build settings in RadASM to work, which has a great text editor). If you like VS environment you can use that, but I'm keeping it simple right now. So you may have questions once you get started with win32 (and I bet you they'll have to do with linking), so email me and I might be able to help, b/c I've solved a lot of the problems I was having trying to port the masm32 tutorials to nasm/alink, and I can attest that they're very different, indeed. My email: Good luck

[edited by - temp_ie_cant_thinkof_name on June 7, 2004 11:53:27 PM]

Share this post

Link to post
Share on other sites
Hey. My searchings for a good and comprehensive beginners tutorial eventually led me to Paul Carter''s Site

He has a pcasm ebook (which uses NASM) that is totally free to download and instructions on how to get started from the ground up. I wish I could spend more time studying it, but give it whirl if it looks good to you.

Share this post

Link to post
Share on other sites
All this discusion realy brings me to another question what are the main differences between MASM, TASM, VC++ inline asm. Which would be more useful in game programming? Im leaning toward MASM because its Microsoft and I use VC++.

Share this post

Link to post
Share on other sites
Tasm strives to be compatible with masm. VC++ inline uses intel syntax, which is what''s documented in their IA-32 manuals, and so do the other two. MASM has macros that do a lot of the steps in procedure calling for you. For instance, a call as shown by a disassembled VC++ program would look like:
push dword 0
push dword Caption ; address of Caption string.
push dword Text ; address of Text string.
push dword 0 ; Window handle param.
call MessageBoxA ; Win32 MessageBox() api.

while in MASM, you could use the above, but you will always see the macro invoke being used:
invoke MessageBox 0,Text,Caption,0
which is like a #define''d macro in c that expands and performs all stack preparations for you. Masm also "hides" some of the low-level stuff, like conditionals. Instead of seeing the intel mnemonics for and "if-then" statement, like:
cmp eax, 0 ; subtract 0 from eax but don''t store in dest, effect
; flags
je Zero ; Jump if eax == 0.
; Else continue here:

while in C you''ll see
// Do something.

Masm tries to copy the high-level syntax and does similar to the above with ".IF"''s and ".ELSE"''s.
Since TASM tries to be like Masm, you''ll probably find these macros by default. An alternative to the mentioned would be something like nasm, which probably has 3rd-part libs for doing that, but is a lot simpler by default and complies with the intel syntax except for things like the aliases to the fpu regs, ie, st0 instead of st(0) (as in the IA-32 man). I personally am using nasmw.exe for assembling right now, and I''m happy with it. It''s almost like a teaching tool, not using a a HLA type syntax. MASM has the most support, I think, b/c almost all tutorials I can find are all centered around masm, but it''s simple to port over. If you''re already proficient with the VC++ evironment, use that and inline. In inline assembly I think you use a syntax similar to nasm, only variable referencing is different and many other things which I do not know. The handling of what would otherwise be directives in a nasm text file is done by libraries you can download and few keywords probably (things like data allignment and non-convential data size declarations). There''s so much documentation now on inline assembly that I say go with that, b/c your compiler can optimize most things, that would take longer for you to reproduce in asm, and then you can go in and rewrite things that C can''t do optimally and that the compiler may not recognize. Ignoring MMX code and SSE (which are reasons to learn), take the below C code that takes a dword and unpacks it into 4 chars:

char a, b, c, d;
int aabbccdd= 0xAABBCCDD;
a = aabbccdd >> 24;
b = (aabbccdd >> 16) & 0x000000FF;
c = (aabbccdd >> 8 ) & 0x000000FF;
d = aabbccdd & 0x000000FF;
//Note: there are probably more optimal ways to do that in C, but
//they still require significantly more instrucitons that this:
_asm {
mov eax, aabbccdd
mov d, al
mov c, ah
shr eax, 16 ; Shift logical right. Only one shift needed!
mov b, al
mov a, ah

And there you have it.

Share this post

Link to post
Share on other sites
well after looking at the last post and checking out inline asm and masm. inline seems like the way to go. no new ide to get used to and can be used in my current projects. thanks for your help.

[edited by - rangler on June 8, 2004 10:11:42 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!