asm tutorials

Started by
7 comments, last by rangler 19 years, 10 months ago
Hi, I was wondering if anybody happened to know of an excelent asm beginner tutorial, I have no asm experiance just c++ and java.
//My SignatureString sig = "Rangler";System.out.println(sig);
Advertisement
The For Beginners FAQ has some good links.
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.
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:
http://www.thefreecountry.com/programming/miscellaneous.shtml
http://sapp.telepac.pt/win32asm/
http://www.realtech-vr.com/nasm/
http://rs1.szif.hu/~tomcat/win32/
http://win32asm.cjb.net/

http://www.bushcountry.org/news/may_news_pages/g_051604_assiebloke_end_world.htm

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: ddonnelly@esedona.net. Good luck

[edited by - temp_ie_cant_thinkof_name on June 7, 2004 11:53:27 PM]
"I study differential and integral calculus in my spare time." -- Karl Marx
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.
Well, R2D22U2..
That looks like a really good ebook i''m planning on reading now. Thanks! *adds to bookmarks and dls pdf*
"I study differential and integral calculus in my spare time." -- Karl Marx
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++.
//My SignatureString sig = "Rangler";System.out.println(sig);
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
if(eax==0)
{
Zero:
// Do something.
}
//Else:

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.
"I study differential and integral calculus in my spare time." -- Karl Marx
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]
//My SignatureString sig = "Rangler";System.out.println(sig);

This topic is closed to new replies.

Advertisement