View text
| Info | |
|---|---|
| Author | Obscura |
| Date added | 2003-03-16 |
| Last modified | 2003-03-16 |
Assembly Lesson 1: Introduction
This lesson is meant to be an introduction for people who want to start programming or reverse engineering in ASM.
1. What do you need to work with ASM?
2. What is ASM?
3. Advantages and Disadvantages of ASM?
Let's start.
1. What do you need to work with ASM?
These and following lessons are not meant for people that want easy to understand stuff, infact ASM can sometimes be hard to grasp. If you still want to learn this is what you MUST know or have:
- A Brain.
- Knowledge of Binary and Hexadecimal (those are the number systems used in ASM).
- The will to learn.
- An Assembler (see list below).
List of Assemblers:
debug.exe - This is in every Windows package. I don't recommend using this as this is very very hard to use.
NASM - Looks like debug.exe but makes your life a little bit easier.
TASM - Borland Turbo Assembler. I use this 1 to write Real-Mode 16 bit DOS programs, this is a reasonable assembler.
MASM - Microsoft Assembler. This is my main Assembler, I use this for all 32 bit assembling. It is the best Assembler in my opinion, Only disadvantage is that it doesnt assemble DOS programs. (see TASM for that)
VC++ - Visual C++. Sounds weird as this is a C++ package, but it has so called Inline Assembly if your a C++ coder you will like this feature.
2. What is ASM?
ASM (Assembly) is simply programming instructions that your processor can read. Although not all processors use the same instructions, the one you are using will probably use the one we will be discussing. It is the Intel x86 Instruction Set. Intel, AMD and many others use this set, so if you are running Windows or Linux don't worry about this not working, because it will :).
3. Advantages and Disadvantages of ASM?
Assembly is in many ways just a programming language, with the difference that the processor actually reads this language. If you ever programmed in another language (VB, C, C++ etc...) you actually programmed in ASM. The program you write (VB, C, C++ etc...) in is a compiler, what it does is read the code you wrote convert it to ASM, Assemble it and Link it. Assembling it will create an Intermediate file, it contains code thats not ASM nor Machine code. The Linking process converts the intermediate file into real machine code. The compilers of the languages mentioned and of other languages have 1 mayor disadvantage. Although making it easy for you to read code, when compiling it has to convert to real ASM meaning it has to generate code from the language code. Which in some languages lead to very over sized code, which would lead to a great loss of speed (noticable in VB). I must say though that C and C++ convert into ASM almost perfectly, but will still be beaten by pure ASM coded programs.
Another big disadvantage of coding in a high level language like the ones mentioned earlier is that they make files rather big. In C++ you create 100kb files while in ASM you create 2 kb files.
This is a big big difference.
Ofcourse there are disadvantages to ASM, 1 big disadvantage is the amount code is needed for the doing of small things. Example...:
C++:
char strHello[] = "Hello World!";
main()
{
printf(%s, strHello);
}
---------------------------------------------------------------------------------------
ASM:
.model small
.DATA
strHello db 'Hello World', 0dh, 0ah, '$'
.CODE
start:
mov dx, offset strHello
mov ah, 09h
int 21h
exit:
mov ah, 4ch
int 21h
END
I am not explaining this code yet. But it shows the difference between needed code.
Well thats basicly it for this introduction, I will go into the real Assembly in the next lesson.
Have fun!