25
Author: Alvaro J. Gene Alias: Socket_0x03 Website: www.teraexe.com Email: [email protected] © Copyright 2012. Alvaro J. Gene. All rights reserved The Easiest Way to Learn ASM Version 1.0

The Easiest Way to Learn ASM by Socket 0x03

  • Upload
    orus

  • View
    24

  • Download
    1

Embed Size (px)

DESCRIPTION

-

Citation preview

Page 1: The Easiest Way to Learn ASM by Socket 0x03

Author: Alvaro J. Gene

Alias: Socket_0x03

Website: www.teraexe.com

Email: [email protected]

© Copyright 2012. Alvaro J. Gene. All rights reserved

The Easiest Way to Learn ASM Version 1.0

Page 2: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

1

Table of Contents

Exercise 1: Show Message ............................................................................................................................. 3

Show Message: Source Code .................................................................................................................................................. 3

Theory: Specifying an Instruction Set .................................................................................................................................. 4

Exercise 2: Buttons ......................................................................................................................................... 6

Exercise 2: Buttons ................................................................................................................................................................. 6

Buttons: Source Code ......................................................................................................................................................... 6

Exercise 3: Icons ............................................................................................................................................. 7

Exercise 3: Icons ..................................................................................................................................................................... 7

Icons: Source Code ............................................................................................................................................................. 7

Exercise 4: Multiple Windows ...................................................................................................................... 9

Multiple Windows .................................................................................................................................................................. 9

Source code ....................................................................................................................................................................... 9

Exercise 5: Reading the Content of a File .................................................................................................... 9

Reading the Content of a File ................................................................................................................................................. 9

Source Code ..................................................................................................................................................................... 11

Theory: Number System .............................................................................................................................. 15

Number System: Binary, Decimals, and Hexadecimals .......................................................................................................... 15

Computer Memory ........................................................................................................................................................... 23

Theory: The CPU ......................................................................................................................................... 24

The CPU (Central Processing Unit) ........................................................................................................................................ 24

Microprocessor ................................................................................................................................................................ 24

Page 3: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

2

INTRODUCTION

This tutorial has been created to provide information about ASM; in other words, this paper provides

information about assembly language. As you can see, the Easiest Way to Learn ASM is an introduction to

assembler, so I am going to cover only a few topics about this computer programming language. First, I will

develop five applications using assembler codes; then, I will focus on the theory of this language.

Page 4: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

3

Writing Applications

Exercise One: Show Message Practice: • Run your Application:

o First, you have to install MASM32; then, you have to open MASM32 Editor.

o Copy the source code that is in blue; then, paste that source code into MASM32 Editor.

.386

.model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib .data Teraexe_ExerciseOne db "The Easiest Way to Learn ASM by Alvaro J. Gene (Socket_0x03)", 0 .code start: invoke MessageBox, NULL, addr Teraexe_ExerciseOne, addr Teraexe_ExerciseOne, MB_OK invoke ExitProcess, 0 end start

o Click on File, Save As, and save your application in this way: C:\masm32\bin\ExerciseOne.asm

o Click on Project, Assemble & Link, and you will see something similar to this:

Page 5: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

4

o Then, click on Project, Run program.

Result:

Theory: • The 386 Directive (.386):

o Specifying an Instruction set: At the beginning of an application, a coder has to type .386 to

specify that he/she is going to use the 386 instruction set.

o Function: The 386 assembler directive is very important on a source code because it tells to our

assembler to recognize 80x86 instructions, which means that our program can be read by those

computers that are using an x86 processor.

o Compatibility: Even though an individual can use other assembler directives (.486/.586) that can

be read by other processors, we will use the .386 assembler directive because this directive is

compatible with the majority of processors and computers.

• The Model Directive (.model flat, stdcall):

o Specifying memory model: You can use the model directive (.model) to specify the memory

model of your application.

• Setting a Case-Sensitive Option to Labels (option casemap :none):

o Labels: In computer science and assembly language, labels are those words/numbers within the

source code of an application. Those words/numbers can be a location, a destination of a jump,

or other instructions.

o When you want to set a case-sensitive option to your labels, you can type option casemap :none.

Setting a case-sensitive option to your labels will be effective to make a difference between one

and other label; for example, if you are including the word Teraexe in your source code, that

word will be different than teraexe because there is a little difference between one T and the

other t.

Page 6: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

5

• The include Directive (include \masm32\include\windows.inc, kernel32.inc…):

o You can use the include directive when you want to include files inside of your applications.

o Including windows.inc: This file contains all those constants that your program will use to run in

win32.

• The includelib Directive (includelib \masm32\lib\kernel32.lib, includelib \masm32\lib\user32.lib):

o The includelib directive is different than include because you can use this directive to include

different kinds of libraries to your computer application.

• The data Directive (.data):

o A programmer can use the data directive to specify that he/she is going to include data in the

next lines of his/her source code; in other words, a programmer is telling to his/her program that

the next lines are related to data. There are other directives that a programmer can use in

assembly language, such as .text, .code, .word, and others. When a coder wants to specify the

starting point of something like data, he/she can use the directives. Usually, those directives will

start with a point.

• The DB Directive (Define Byte):

o The DB directive is an abbreviation for define byte. In the previous exercise, we used the DB

directive because "The Easiest Way to Learn ASM by Alvaro J. Gene (Socket_0x03)" is an array

of bytes; in other words, each letter/symbol represents a byte. As you can see, the .data directive

can be used by a programmer to declare bytes (DB) and/or words (DW), so a coder has to use

.data before using DB/DW. In addition to the array of bytes, a programmer has to include a NUL

character (0) at the end of a message.

• The code Directive (.code):

o A coder can use the .code directive to specify that he/she is going to include codes in the next

lines of his/her source code. After typing the .code directive, a programmer has to type .start: to

specify that he/she will start typing his/her code; then, a coder has to type end start at the end of

his/her codes to specify that his/her code is completed.

Page 7: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

6

• The invoke Directive – Part 1 (invoke MessageBox):

o When you want to call a function or a parameter in assembler language, you can use the invoke

directive. In the previous exercise, we invoked a MessageBox. Then, we used “addr” to pass the

address “ExerciseOne” to our MessageBox.

• The invoke Directive – Part 2 (invoke ExitProcess):

o A programmer can use this function to close an application.

Exercise Two: Buttons

Practice (Source Code): If you want to compile and run the next source code, you have to follow the same

instructions that you can find in the first exercise.

.386 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc includelib \masm32\lib\kernel32.lib include \masm32\include\user32.inc includelib \masm32\lib\user32.lib .data Teraexe_ExerciseTwo db "The Easiest Way to Learn ASM by Alvaro J. Gene (Socket_0x03)", 0 .code start: invoke MessageBox, NULL, addr Teraexe_ExerciseTwo, addr Teraexe_ExerciseTwo, MB_YESNOCANCEL invoke ExitProcess,NULL end start

Result:

Page 8: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

7

Theory:

• Buttons ( MB_YESNOCANCEL ):

o Buttons: There are a great variety of buttons that a programmer can use in assembler

language. Some of those buttons are:

Exercise Three: Icons

Practice (Source Code): If you want to compile and run the next source code, you have to follow the same

instructions that you can find in the first exercise.

.386

.model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc includelib \masm32\lib\kernel32.lib include \masm32\include\user32.inc includelib \masm32\lib\user32.lib .data Teraexe_ExerciseThree db "The Easiest Way to Learn ASM by Alvaro J. Gene (Socket_0x03)", 0 .code start: invoke MessageBox, NULL, addr Teraexe_ExerciseThree, addr Teraexe_ExerciseThree, MB_ICONQUESTION invoke ExitProcess,NULL end start

Buttons Meaning MB_OK OK

MB_HELP Help MB_YESNO Yes and No

MB_OKCANCEL OK and Cancel MB_RETRYCANCEL Retry and Cancel MB_YESNOCANCEL Yes, No, and Cancel

MB_ABORTRETRYIGNORE Abort, Retry, and Ignore MB_CANCELTRYCONTINUE Cancel, Try Again, and Continue

Page 9: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

8

Result:

Theory:

• Icons ( MB_ICONQUESTION ):

o Icons: There are a great variety of buttons that a programmer can use in assembler language.

Some of those buttons are:

� MB_ICONWARNING:

� MB_ICONINFORMATION:

Page 10: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

9

� MB_ICONERROR:

Exercise Four: Multiple Windows

Practice (Source Code): If you want to compile and run the next source code, you have to follow the same

instructions that you can find in the first exercise.

.386

.model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\user32.lib .data Teraexe_WindowsOne db "The Easiest Way to Learn ASM by Alvaro J. Gene (Socket_0x03) - First Window", 0 Teraexe_WindowsTwo db "The Easiest Way to Learn ASM by Alvaro J. Gene (Socket_0x03) - Second Window", 0 .code start: invoke MessageBox, NULL, addr Teraexe_WindowsOne, addr Teraexe_WindowsOne, MB_OKCANCEL invoke MessageBox, NULL, addr Teraexe_WindowsTwo, addr Teraexe_WindowsTwo, MB_OK invoke ExitProcess, 0

end start

Page 11: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

10

• Result:

o First Window:

o Second Window:

Exercise Five: Reading the Content of a File

• Practice (Source Code):

o First, you have to create a text file (abc.txt) and include this information:

The Easiest Way to Learn ASM by Alvaro J. Gene (Socket_0x03)

***Exercise Five: Opening a Text File***

o Second, you have to put your file in this directory/way: C:\abc.txt

o Third, you have to follow the same instructions that you followed in the first exercise if you want

to compile and run the next source code. Notice that the next source code in on the next page.

Page 12: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

11

.386

.model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib .data Teraexe_ExerciseFive db "c:\abc.txt", 0 Teraexe_HandleFile HANDLE ? Teraexe_HandleMemory HANDLE ? Teraexe_PointerMemory DWORD ? Teraexe_RMS DWORD ? .const MEMORYSIZE equ 2323 .code start: invoke CreateFile, addr Teraexe_ExerciseFive, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, 0 mov Teraexe_HandleFile, eax invoke LocalAlloc, GMEM_ZEROINIT, MEMORYSIZE mov Teraexe_HandleMemory, eax invoke LocalLock, Teraexe_HandleMemory mov Teraexe_PointerMemory, eax invoke ReadFile, Teraexe_HandleFile, Teraexe_PointerMemory, MEMORYSIZE, addr Teraexe_RMS, 0 invoke MessageBox, 0, Teraexe_PointerMemory, addr Teraexe_ExerciseFive, MB_CANCELTRYCONTINUE invoke CloseHandle, Teraexe_HandleFile invoke LocalFree, Teraexe_HandleMemory invoke LocalUnlock, Teraexe_PointerMemory invoke ExitProcess, 0 end start

Page 13: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

12

Result:

Theory:

• The Data Directive (.data) and Five Variables: A programmer can use the data directive when he/she

wants to include data inside of a computer application; furthermore, a coder can use the data

directive to declare different kinds of variables related to data or information. In the previous source

code, we declared five variables that can be classified in:

� Teraexe_ExerciseFive

� Teraexe_HandleFile

� Teraexe_HandleMemory

� Teraexe_PointerMemory

� Teraexe_RMS

o The Teraexe_ExerciseFive Variable (Teraexe_ExerciseFive db “c:\abc.txt, 0”): This variable

is very important in the source code of our application because we can use it to specify a

directory or location related to the file that we want to open. In this variable, we specified a

directory (“c:\abc.txt”) because we want to read the content of a file that is located in that

directory. If you want to read a text file that is located in other directory, you can modify the

directory (“c:\abc.txt”) of this variable.

o The Teraexe_HandleFile Variable (Teraexe_HandleFile HANDLE ?): This variable works

like a “handle file” in our program. If you want to understand its function, you have to know

what is a handle file:

� Handle: When a coder is developing the source code of an application, he/she can

include a handle that will be effective to work or deal with something else, such as a

file. This handle will work like a resource to a file, a window, or other object.

� Handle File: The Handle file is a handle that is working like a resource to a file.

Page 14: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

13

o The Teraexe_HandleMemory Variable (Teraexe_HandleMemory HANDLE ?): This is a

handle memory; in other words, this variable is a handle that is working like a resource to a

memory.

o The Teraexe_PointerMemory Variable (Teraexe_PointerMemory DWORD ?): This variable

works like a “pointer memory”; in other words, a pointer that points to a block of memory.

o The Teraexe_RMS Variable (Teraexe_RMS): This variable is effective to read the memory

size when we are invoking ReadFile and using MEMORISIZE

• The Constant Directive (.const): A programmer can use the constant directive when he/she wants to

start a constant data segment. Like other memory directives (.data, .code), the constant directive

(.const) has to be used after the model directive (.model). Notice that we are including this directive

(.model) in the second line of the previous source code.

o Memory Allocation (MEMORYSIZE equ 2323): A programmer can use this instruction to

specify how much memory he/she wants to allocate. Notice that a coder has to use this

instruction after including the constant directive (.const).

• Creating/Opening Files (invoke CreateFile): A coder can use the CreateFile instruction when he/she

wants to create or open a file. In the previous source code, we used this instruction to open a text

file, which is known as the abc.txt file.

o GENERIC_READ: After invoking the CreateFile function, a programmer can use the

GENERIC_READ instruction to read a file.

o OPEN_EXISTING: After invoking the CreateFile function, a coder has to include this

instruction to open a file. If a coder does not include this instruction, the application will fail.

o FILE_ATTRIBUTE_READONLY: When a coder wants to read the content of a text file,

he/she has to use this instruction to specify that he/she is going to read the content of a file.

Page 15: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

14

• Allocating Memory (invoke LocalAlloc): A programmer can use this function (LocalAlloc) when

he/she wants to allocate a block of memory. The process to allocate memory and store data can be

divided in four: LocalAlloc, LocalLock, LocalFree, and LocalUnlock. Invoking LocalAlloc is the

first step of those four. As you can see, in the previous source code I am invoking the other three

instructions after using LocalAlloc.

• Locking Memory (invoke LocalLock): After allocating a block of memory using the LocalAlloc

function, a coder can use the LocalLock instruction to lock or close a memory block.

• Reading File (invoke ReadFile): A coder can use the ReadFile instruction when he/she wants to read

a file. In the previous source code, we used this instruction to read the abc.txt file.

• Closing a Text File (invoke CloseHandle): A coder can use the CloseHandle instruction when he/she

wants to close a file; in this case, we are using this function to close a text file.

• Freeing a Block of Memory (invoke LocalFree): After allocating a block of memory, you can use the

LocalFree function to free a block of memory

• Unlocking a Block of Memory (invoke LocalUnlock): After locking a block of memory using the

LocalLock instruction, you can use the LocalUnlock function to unlock a block of memory.

• The MOV Instruction (mov Teraexe… eax): A programmer can use this mnemonic instruction when

he/she wants to copy data or information from one location to another location. In the previous

source code, we used the MOV instruction three times to move data to the EAX register.

Page 16: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

15

Theory

Number System: Binary, Decimals, & Hexadecimals

In a computer, all the information is stored in a binary form; in other words, all data is stored in 0 and 1.

In this paper, you can learn about different kinds of number systems, which is important to know how the

information in a computer flows.

• Binary Numerical System: Also known as base-2 number system. The binary numerical system is

composed of two numbers, which are “0” and “1.” When you want to say a binary number, you

have to read digit by digit. For example, if you want to pronounce 1000, you have to say: one,

zero, zero, zero. Notice that you do not have to say one-thousand because that is wrong when you

are reading a binary number.

• Decimal Numeral System: Also known as base-10 numeral system or denary. The decimal

numeral system includes ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

• Hexadecimal Numeral System: Also known as base-16 numeral system or hex. The hexadecimal

numeral system includes sixteen symbols, which are 0 through 9 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) and A

through F (A, B, C, D, E, F).

• Counting and Representing Binary Numbers:

Binary Numbers Decimal Numbers Hexadecimals

0 0 1 1 10 2 11 3

100 4 101 5 110 6 111 7 1000 8 1001 9 1010 10 A 1011 11 B 1100 12 C 1101 13 D 1110 14 E 1111 15 F

10000 16 10

Page 17: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

16

• Converting Binary to Decimal:

1110002 = 1x2^5 + 1x2^4 + 1x2^3 + 0x2^2 + 0x2^1 + 0x2^0 = 16 + 2 + 1 = 5610

Note: Notice that 111000 is the binary number, and 56 is the decimal number.

• Converting Decimal to Hexadecimal:

Example One:

Decimal Number: 5610

• First, divide the decimal by sixteen =========================� 56/16 = 3.5

• Second, multiply the remainder (0.5) by sixteen: ===============� 0.5*16 = 8

• Third, divide the result that is in step one (3) by sixteen ==========� 3/16 = 0.1875

• Fourth, multiply the remainder (0.1875) by sixteen ==============� 0.1875*16 = 3

• Fifth, divide the result (3) by sixteen =========================� 3/16 = 0.1875

Note: If the remainder is 0 or the same number than the third step, we have to

stop because we have the result, which is 3816. Notice that we know the result

because we obtained the remainders 8 in the second step and 3 in the fourth

step. Finally, we know that the decimal 56 is 38 in hexadecimal.

Example Two:

Decimal Number: 12410

1. 124/16 = 7.75

2. 0.75*16 = 12

3. 7/16 = 0.4375

4. 0.4375*16 = 7

Result: 7C16

Note: Notice that in hexadecimal, 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F,

16 = 10…

Page 18: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

17

• Converting Hexadecimal to Decimal:

Example One:

Hexadecimal Number: 7C16

7C = Cx(16^0) + 7x(16^1)

= 12x(16^0) + 7x(16^1) � Notice that C = 12

= 12 + 112

= 124

Result: 12410

Example Two:

Hexadecimal Number: 302116

3021 = 1x(16^0) + 2x(16^1) + 0x(16^2) + 3x(16^3)

= 1 + 32 + 0 + 12288

= 12321

Result: 1232110

• Converting Decimal to Binary:

Decimal Number: 5610

56/2 = 28 r 0

28/2 = 14 r 0

14/2 = 7 r 0

7/2 = 3 r 1

3/2 = 1 r 1

1/2 = 0 r 1

Result: 1110002

Page 19: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

18

BCD (Binary Coded Decimal)

• BCD Digits: The BCD is one of the ways that a computer can use to encode a decimal number; in

this case, each decimal digit is represented in four bits of zero and one.

Decimal

Digit BCD

0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001

• Variations of BCD: Some variations of BCD can be classified in packed and unpacked:

o 16 bits encoded in packed BCD:

� Binary Value: 00100011 00100011

� 00100011 00100011

� 0010 0011 0010 0011

� 2 3 2 3

� Decimal Value: 2323

o 32 bits encoded in unpacked BCD:

� Binary Value: 00000010 00000011 00001001 00000111

� 00000010 00000011 00001001 00000111

� 2 3 9 7

� Decimal Value: 2397

Page 20: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

19

ASCII (American Standard Code for Information Interchange)

• ASCII: The American Standard Code for Information Interchange (ASCII) is one of the ways that

a computer can use to encode a great variety of characters; for instance, the ASCII is a way to

encode alphabetic characters, numbers, punctuation marks, and those kinds of symbols that an

individual can use in an English keyboard.

ASCII Table – Part 1

Binary Number Decimal Number Hexadecimal Number Name/Symbol 0000 0000 0 00 Null Character - ^@ 0000 0001 1 01 Start of Header - ^A 0000 0010 2 02 Start of Text - ^B 0000 0011 3 03 End of Text - ^C 0000 0100 4 04 End of Transmission - ^D 0000 0101 5 05 Enquiry - ^E 0000 0110 6 06 Acknowledgment ^F 0000 0111 7 07 Bell - ^G 0000 1000 8 08 Backspace - ^H 0000 1001 9 09 Horizontal Tab - ^I 0000 1010 10 0A Line Feed - ^J 0000 1011 11 0B Vertical Tab - ^K 0000 1100 12 0C Form Feed - ^L 0000 1101 13 0D Carriage Return - ^M 0000 1110 14 0E Shift Out - ^N 0000 1111 15 0F Shift In - ^O 0001 0000 16 10 Data Link Escape - ^P 0001 0001 17 11 Device Control 1 - ^Q 0001 0010 18 12 Device Control 2 - ^R 0001 0011 19 13 Device Control 3 - ^S 0001 0100 20 14 Device Control 4 - ^T 0001 0101 21 15 Negative Acknowledgement - ^U 0001 0110 22 16 Synchronous idle - ^V 0001 0111 23 17 End of Transmission Block - ^W 0001 1000 24 18 Cancel - ^X 0001 1001 25 19 End of Medium - ^Y 0001 1010 26 1A Substitute - ^Z 0001 1011 27 1B Escape - ^[ 0001 1100 28 1C File Separator - ^\ 0001 1101 29 1D Group Separator - ^] 0001 1110 30 1E Record Separator - ^^ 0001 1111 31 1F Unit Separator - ^_

Page 21: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

20

ASCII Table – Part 2

Binary Number Decimal Number Hexadecimal Number Name/Symbol 0010 0000 32 20

0010 0001 33 21 ! 0010 0010 34 22 “ 0010 0011 35 23 # 0010 0100 36 24 $ 0010 0101 37 25 % 0010 0110 38 26 & 0010 0111 39 27 ‘ 0010 1000 40 28 ( 0010 1001 41 29 ) 0010 1010 42 2A * 0010 1011 43 2B + 0010 1100 44 2C , 0010 1101 45 2D - 0010 1110 46 2E . 0010 1111 47 2F / 0011 0000 48 30 0 0011 0001 49 31 1 0011 0010 50 32 2 0011 0011 51 33 3 0011 0100 52 34 4 0011 0101 53 35 5 0011 0110 54 36 6 0011 0111 55 37 7 0011 1000 56 38 8 0011 1001 57 39 9 0011 1010 58 3A : 0011 1011 59 3B ; 0011 1100 60 3C < 0011 1101 61 3D = 0011 1110 62 3E > 0011 1111 63 3F ?

Page 22: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

21

ASCII Table – Part 3

Binary Number Decimal Number Hexadecimal Number Name/Symbol 0100 0000 64 40 @ 0100 0001 65 41 A 0100 0010 66 42 B 0100 0011 67 43 C 0100 0100 68 44 D 0100 0101 69 45 E 0100 0110 70 46 F 0100 0111 71 47 G 0100 1000 72 48 H 0100 1001 73 49 I 0100 1010 74 4A J 0100 1011 75 4B K 0100 1100 76 4C L 0100 1101 77 4D M 0100 1110 78 4E N 0100 1111 79 4F O 0101 0000 80 50 P 0101 0001 81 51 Q 0101 0010 82 52 R 0101 0011 83 53 S 0101 0100 84 54 T 0101 0101 85 55 U 0101 0110 86 56 V 0101 0111 87 57 W 0101 1000 88 58 X 0101 1001 89 59 Y 0101 1010 90 5A Z 0101 1011 91 5B [ 0101 1100 92 5C \ 0101 1101 93 5D ] 0101 1110 94 5E ^ 0101 1111 95 5F _

Page 23: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

22

ASCII Table – Part 4

Binary Number Decimal Number Hexadecimal Number Name/Symbol 0110 0000 96 60 ` 0110 0001 97 61 a 0110 0010 98 62 b 0110 0011 99 63 c 0110 0100 100 64 d 0110 0101 101 65 e 0110 0110 102 66 f 0110 0111 103 67 g 0110 1000 104 68 h 0110 1001 105 69 i 0110 1010 106 6A j 0110 1011 107 6B k 0110 1100 108 6C l 0110 1101 109 6D m 0110 1110 110 6E n 0110 1111 111 6F o 0111 0000 112 70 p 0111 0001 113 71 q 0111 0010 114 72 r 0111 0011 115 73 s 0111 0100 116 74 t 0111 0101 117 75 u 0111 0110 118 76 v 0111 0111 119 77 w 0111 1000 120 78 x 0111 1001 121 79 y 0111 1010 122 7A z 0111 1011 123 7B { 0111 1100 124 7C | 0111 1101 125 7D } 0111 1110 126 7E ~ 0111 1111 127 7F Delete - ^?

Page 24: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

23

Computer Memory

• Computer Memory: The computer memory is the data or information storage inside of a PC. The

minimum unit of information is a bit, which can be represented either 0 or 1. In addition, eight bits

of 0 and 1 can form a byte; furthermore, eight bits or a byte can make an individual character,

which can be a letter (A), a number (3), or a symbol (&). Knowing this basic information about

computer memory, you will notice that a word like “memory” has six bytes. Another example is

the Teraexe word, which is a word of seven bytes. If you want to know how many bytes are in a

word or a group of words, you can use a text document on Windows operating system and follow

those instructions: First, you have to create a text document and type a word like computer.

Second, you have to type “Control+S” to save your changes. Finally, you have to close your text

document and see its properties. If you want to see its properties, you have to make a right-click on

your text document and select properties.

• Measurement Units of Computer Memory:

Name Value Bit 0 or 1

Byte 8 bits Kilobyte 1024 bytes Megabyte 1024 kilobytes Gigabyte 1024 megabytes Terabyte 1024 Gigabytes Petabyte 1024 terabytes Exabyte 1024 petabytes Zettabyte 1024 exabytes Yottabyte 1024 zettabytes

Page 25: The Easiest Way to Learn ASM by Socket 0x03

The Easiest Way to Learn ASM Alvaro J. Gene

24

The CPU (Central Processing Unit)

• The CPU (Central Processing Unit): The CPU is the hardware or physical device inside of a

computer; furthermore, this component has an important function in a system, which is to perform

instructions.

o Machine Language: Also known as machine code. The machine language consists of a

great variety of numbers and instructions that a CPU can read to execute an operation. An

application (.exe) developed on a high-level computer programming language is translated

into ASM; then, this application is translated into machine language by a compiler. Finally,

a CPU can read that machine language to execute an operation or task.

o Compiler: A compiler is a computer application that translates the source code of a

program into machine language; then, the source code is read by a CPU.

o Microprocessor: A microprocessor is a little device inside of a CPU. Moreover, this device

contains a great variety of functions of a CPU. There are different kinds of

microprocessors, such as 80286, 80386, 80486, and others.

© Copyright 2012. Alvaro J. Gene. All rights reserv ed