Archived

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

kamelbak

Help learning assembly

Recommended Posts

Hey all. I''ve realized that there aren''t many printed books and many .pdf''s on assembly. With all of this stuff, which do you think would be best for an intermediate C++ programmer looking to learn assembly? Any advice on assemblers? A friend of mine recommended FASM. What tutorials and assemblers do you think an ASM newbie like me should start out with? Thanks! kamelbak

Share this post


Link to post
Share on other sites
Hello,

Im assuming you want to learn assembly for x86''s
I suggest you use the inline assembler for Visual C++!!!!

int AddNumbers(int num1,int num2)
{
int result = 0;

_asm // <-- Tells compiler we are using assembly!!
{
mov eax,num1; // Store num1 in register ax
mov ebx,num2; // Store num2 in register bx
add eax,ebx; // Adds ax and bx, result is in ax.
mov result,eax; // Stores ax, in ''result''
}

return(result); // Returns the result!
}

Or something like that anyway - i feel this would be a nice easy way of getting used to assembly, and being able to mix it with C++ will make the transition easier for you.

here are some sites that you might find useful
http://www.azillionmonkeys.com/qed/asm.html#general
http://www.penguin.cz/~literakl/intel/intel.html

TRY THIS ONE FIRST - address was to long for the screen
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1258&lngWId=3

Share this post


Link to post
Share on other sites
I began learning 16-bit ASM a month ago. 16-bit ASM programming is fun because you will recognized how high-level programming experience with OOP especially C/C++ help you design and implement applications in ASM. Without high-level experience ASM can be confusing.

Now I want to learn 32-bit ASM!

Kuphryn

Share this post


Link to post
Share on other sites
Thanks you guys. I'll check out this places. Inline ASM sounds good. Say, what is the difference between 16 bit and 32 bit ASM? Any more compilers/tutorials? Thanks!

[edited by - kamelbak on October 3, 2002 9:28:32 PM]

Share this post


Link to post
Share on other sites
I recommend you use MASM.

Here's an on-line book for learning 16-bit x86 ASM.

By the way, there are bunch of books on assembly language you can get. Try this.

Hope this helps!

Edit: One of links didn't work.

[edited by - Gladiator on October 3, 2002 9:34:47 PM]

Share this post


Link to post
Share on other sites
Thanks. I think I''ll start 16 bit ASM, with either FASM or MASM. I was wondering though: I got a little bit into The Art of Assembly Language, but it seemed to be that it was mainly about some High Level Assembler. Is this to help you understand the basics of assembly or something? By the way, I think the Amazon link was the one that didn''t work.

Share this post


Link to post
Share on other sites
1:difference with 16 and 32 bit assembly
32 - using api, eax, ebx, ect
try do something like winows routine you will see differece
2:
try TurboAssembler32, NASM makes smaller files (4k Tasm=3k Nasm), but its really makes no difference when using some code packers like upx
3:
books:
art of assembly, Iczelion tutorials, some CrackMe and Cracks sources and as always FAQ
4:
forget about VC and other non-only-asm compilers:
-you lose knownlege about win/linux routine
-you lose knownlege about executable files, sections etc., and without that whats for learning asembler? - if game works slowly use rather other algorithm than code it in asmebler
5:
some boot sector trick = on floppy you have 512-65(fat12 header)=447 bytes for your bootloader, so try do it in c++
6:
really asm is nowadays for virus writes (polymorphism, some code meshes engines etc.), but really there is nothing better to delete FAT on somebodys computer, or on tousands computers, or on milions computers...

Share this post


Link to post
Share on other sites
Thanks, guys. I''ve pretty much narrowed tutorials down to Iczelion/Art of Assembly. I am going to go to Office Depot and buy some cheap, thin paper and start printing the first few chapters. If I like it, I''ll print more. I just can''t stand reading e-Books.

So the competition here is what assembler should I use? Is there really that much difference in the types of assemblers? Which should I get? NASM, MASM, FASM, or TASM? Thanks!

Share this post


Link to post
Share on other sites
I use NASM - it''s open source, has a powerful preprocessor, supports many output formats, and has minimal red-tape.
MASM is available with the MS DDK and has stupid directives/syntax.
AFAIK, TASM isn''t free, but it has somewhat nicer syntax than MASM; it can be fully MASM compatible if you want.
I have no experience with FASM.

You''ll probably also need a linker - I''d go with link.exe from VC++.

Moore52> NASM makes smaller files (4k Tasm=3k Nasm)
?!
What output format?

Share this post


Link to post
Share on other sites
quote:
I''ve now narrowed it down to TASM, NASM, and FASM


Although a lot of the code you''ll see uses MASM syntax, I''d recommend using NASM. I''m assuming that as a beginner you aren''t going to be linking your assembly code with MSVC or anything for a while to come, so there should be no issues with interoperability between other compilers for now.

When it does become an issue, you''ll find that MSVC supports custom build steps and that NASM will pretty much work with any of the major compilers you''ll be dealing with (thanks to the fact that it supports so many output formats.)

NASM is usually fairly quick to support new instructions because it''s an open source project still under development.

The main things I love about NASM are its simplicity and power. Someone mentioned that it doesn''t have the "red tape" that MASM has, and that''s a good point. Once you learn NASM-style syntax, you won''t be able to go back

Required directives are kept to a minimum and all are much more concise. There is no "offset" or "ptr" nonsense.

Just make sure to read the NASM manual and if you come across MASM syntax, put some time into figuring out how to get the code to work with NASM. It''s so worth it...

---
Bart

Share this post


Link to post
Share on other sites