23.2.08

learning assembly language

This article is strictly for a newbie who wants to learn assembly language if you are an expert or think yourself an expert check other articles on this blog about viruses and batch programming.

Lets start from pretty basic concepts:

Before setting out to learn assembly language you need to have an idea about number systems and their interconversion like HEX to BCD and all that.

Assembly is low level programming which deals with processor and its internal registers directly as you write instructions that manipulate these registers. A computer is made up of,
  • A CPU where all computations are carried out generally called "Heart" of computer though "Brain" is more appropriate word.
  • RAM is the memory where the program to be executed is stored.
  • system bus is a mechanism which connects CPU, RAM and external devices with each other.
The CPU is what we are going discuss here.(All references will be related to 8086 and will be applicable to all x86 based processors with/without any change.)

The general purpose registers for 8086 are
  1. AX : Accumulator register
  2. BX : Base register
  3. CX : Count register
  4. DX : Data register
All these are 16 bit and can be used as 2 different 8 bit registers.
eg: AX can be divided into AH AND AL
5. SP: Stack pointer
6. SI: Source index
7. DI: Destinations index
8. BP: Base pointer

As inter-processor registers are are much faster than any other form of memory care should be taken to optimize their usage in program. (more about this later)

Segment registers are

  1. CS : Code segment
  2. DS : Data segment
  3. ES : Extra segment
  4. SS : Stack segment
Segment registers can be used to store data like general purpose ones but such usage is never made for they serve an even higher purpose.
When used with general purpose registers they point at accessible locks of memory this concept is called segmentation and enables a greater memory access otherwise impossible.

eg. a physical memory location 10060h is represented as
1000 : 0060h
segment : offset called logical address

To calculate original address just multiply segment by 10h and add offset to it.

BX,SI,DI are used with DS

BP and SP with SS


Special purpose registers
  1. IP : instruction pointer
  2. Flag registers
IP is always used with CS and its function is to point towards currently executing instruction.
Flag registers are used by the processor to indicate status or results after any operation.

Now with this i'll conclude this article and next one will start with real programming tutorials .
Keep visiting.

No comments :