C S C O R N E R

Basic Concepts, before learning Assembly Programming


Before start, I hope you are very clear about some important and basic topics, necessary to learn programming. Those topics are,
  1. Hexa decimal number system
  2. Decimal number system
  3. Introduction to assembly programming
  4. Importance of assembly
  5. And how to write, assemble and open your program in debugger
Now moving on to the topic we will learn some important facts about Registers,
Registers
Registers are the small, fast memory locations inside the processor. This memory is volatile and helps the processor to be fast and accurate.
In IBM compatible computer generally we have about 14 register, each have its own function and for special purpose.
Here I am dividing the registers in 5 different categories.
  • Main or general purpose registers
  • Index registers
  • Program counter registers
  • Segment registers
  • Status or Signal register

16 Bit registers
In these days’ computers in front of us, having 32 bit or 64bit processor.  But our discussion will be all about 16 bit registers. Here the question is, what’s about our latest CPUs? How can we run 16 bit program on our latest CPU that is of 32 bit registers.
Answer to this question is, that our latest processor are downward compatible and can support all things about old 16 bit 8088 or 8085 processor.
Now I want to expand and discuss more about registers,
Relatively speaking some registers have two parts with Low byte and Hight byte,
For example in AX register,

In AH we can only store value of range (28-1). The story is same for other some registers,
For detail, you can refer to your reference book.
I remembered that, in my assembly course’s final paper, there was a MCQ about the 32 bit register.
So just for you reference, I am sharing you a list of 32 bit registers,
32 bit registers and 64 bit registers
32 bit register are the Extended form of 16 bits registers. So these are presented by prefixing “E”(for extended) to the register’s names.

x64 extends x86’s 8 general-purpose registers to be 64-bit, and adds 8 new 64-bit registers. The 64-bit registers have names beginning with “r”, so for example the 64-bit extension of eax is called rax. The new registers are named r8 through r15.
The following table specifies the assembly-language names for the lower portions of 64-bit registers.
64-bit registerLower 32 bitsLower 16 bitsLower 8 bits
RAXEAXAXAL
RBXEBXBXBL
RCXECXCXCL
RDXEDXDXDL
RSIESISISIL
RDIEDIDIDIL
RBPEBPBPBPL
RSPESPSPSPL
R8R8DR8WR8B
R9R9DR9WR9B
R10R10DR10WR10B
R11R11DR11WR11B
R12R12DR12WR12B
R13R13DR13WR13B
R14R14DR14WR14B
R15R15DR15WR15B
FLAGS\Status\Signal register : 8086 has 16 flag registers among which 9 are active. The purpose of the FLAGS register is to indicate the status of the processor. It does this by setting the individual bits called flags. There are two kinds of FLAGS;
Status FLAGS and Control FLAGS. Status FLAGS reflect the result of an operation executed by the processor. The control FLAGS enable or disable certain operations of the processor.

  1. Carry Flag (CF) – this flag is set to 1 when there is an unsigned overflow. For example when you add bytes 255 + 1 (result is not in range 0…255). When there is no overflow this flag is set to 0.
  2. Parity Flag (PF) – this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits.
  3. Auxiliary Flag (AF) – set to 1 when there is an unsigned overflow for low nibble (4 bits).
  4. Zero Flag (ZF) – set to 1 when result is zero. For non-zero result this flag is set to 0.
  5. Sign Flag (SF) – set to 1 when result is negative. When result is positive it is set to0. (This flag takes the value of the most significant bit.)
  6. Trap Flag (TF) – Used for on-chip debugging.
  7. Interrupt enable Flag (IF) – when this flag is set to 1 CPU reacts to interrupts from external devices.
  8. Direction Flag (DF) – this flag is used by some instructions to process data chains, when this flag is set to 0 – the processing is done forward, when this flag is set to 1the processing is done backward.
  9. Overflow Flag (OF) – set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128…127).

I think this knowledge is enough to move us to the next step. And with this, is the end of our day 01’s discussion. Thanks for reading..

No comments:

Powered by Blogger.