Skip to content

Instantly share code, notes, and snippets.

@sithumonline
Last active March 30, 2020 03:07
Show Gist options
  • Select an option

  • Save sithumonline/afc486ebed6792a8c8d4b8860a2eed54 to your computer and use it in GitHub Desktop.

Select an option

Save sithumonline/afc486ebed6792a8c8d4b8860a2eed54 to your computer and use it in GitHub Desktop.
x8086

x8086

x8086 Registers

8086 CPU has 8 general purpose registers.

  • AX-the Accumulator register (divided into AH / AL).

  • BX-the Base address register (divided into BH / BL).

  • CX-the Count register (divided into CH / CL).

  • DX-the Data register (divided into DH / DL).

  • SI- Source Index register.

  • DI- Destination Index register.

  • BP- Base pointer.

  • SP- Stack pointer.

The main purpose of a register is to keep a number (variable). The size of the above registers is 16 bit

Ex: 0011000000111001b(in binary form), or 12345in decimal

Segment registers

  • CS-points at the segment containing the current program.
  • DS-generally points at segment where variables are defined.
  • ES-extra segment register, it's up to a coder to define its usage.
  • SS-points at the segment containing the stack.

Segment registers work together with general purpose register to access any memory value

This is good, since this way we can access much more memory than with a single register that is limited to 16 bit values.CPU makes a calculation of physical address by multiplying the segment register by 10h and adding general purpose register to it

By default BX, SI and DI registers work with DS segment register; BP and SP work with SS segment register

Special purpose registers

  • IP-the instruction pointer.
  • Flags register - determines the current state of the Microprocessor [It is a 16-bit register that behaves like a flip-flop, i.e. it changes its status according to the result stored in the accumulator. It has 9 flags and they are divided into 2 groupsConditional Flags* and Control Flags.]

Conditional Flags

  • Carry flag
  • Auxiliary flag
  • Parity flag
  • Zero flag
  • Sign flag
  • Overflow flag

Control Flags

  • Trap flag
  • Interrupt flag
  • Direction flag

Generally you cannot access these registers [Special Purpose] directly, the way you can access AX and other general registers, but it is possible to change values of system registers using some tricks that you will learn a little bit later.

Reference

*If u want to learn x8086 assembly refer this xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment