06 8086 Registers

āĻāĻŦāĻžāϰ EU-āĻāϰ Registers — āĻŦāĻ‡ā§Ÿā§‡āϰ āĻĒ⧃āĻˇā§āĻ āĻž ā§§ā§ĢāĨ¤ Flags āĻĒāϰ⧇āϰ āϧāĻžāĻĒ⧇ āĻĒ⧜āĻŦāĨ¤

Register āϕ⧀?

Register āĻšāϞ⧋ CPU-āĻāϰ āϭ⧇āϤāϰ⧇āϰ āϛ⧋āϟ āĻ“ āĻĻā§āϰ⧁āϤ storage, āϝ⧇āĻ–āĻžāύ⧇ āĻ•āĻžāĻœā§‡āϰ āϏāĻŽā§Ÿ data āĻŦāĻž address āϏāĻžāĻŽā§ŸāĻŋāĻ•āĻ­āĻžāĻŦ⧇ āϰāĻžāĻ–āĻž āĻšā§ŸāĨ¤ āϝ⧇āĻŽāύ, āĻĻ⧁āϟāĻŋ āϏāĻ‚āĻ–ā§āϝāĻž āϝ⧋āĻ— āĻ•āϰāĻžāϰ āφāϗ⧇ āϏ⧇āϗ⧁āϞ⧋ register-āĻ āϰāĻžāĻ–āĻž āϝāĻžā§ŸāĨ¤

Exam definition:
“A register is a small, high-speed storage location inside the CPU used to temporarily hold data, addresses, or intermediate results.”

ā§§. General-purpose registers: AX, BX, CX, DX

āĻāϗ⧁āϞ⧋ āĻĒā§āϰāϤāĻŋāϟāĻŋ 16-bitāĨ¤ āĻĒā§āϰāϤāĻŋāϟāĻŋāϕ⧇ āφāĻŦāĻžāϰ āĻĻ⧁āχāϟāĻŋ 8-bit āĻ…āĻ‚āĻļ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻž āϝāĻžā§Ÿ:

16-bit register Higher 8 bits Lower 8 bits
AX AH AL
BX BH BL
CX CH CL
DX DH DL

H = High, L = LowāĨ¤ āĻāϗ⧁āϞ⧋ āĻāĻ•āχ register-āĻāϰ āĻ…āĻ‚āĻļ; āφāϞāĻžāĻĻāĻž āĻ…āϤāĻŋāϰāĻŋāĻ•ā§āϤ storage āύ⧟āĨ¤

āϧāϰ⧋:

AX = 1234H → AH = 12H, AL = 34H

āĻ•āĻžāϰāĻŖ āĻāĻ•āϟāĻŋ hexadecimal digit āĻŦā§‹āĻāĻžā§Ÿ 4 bitsāĨ¤ āϤāĻžāχ āϚāĻžāϰ digit-āĻāϰ 1234H āĻšāϞ⧋ 16-bit āĻāĻŦāĻ‚ āĻĻ⧁āχ digit-āĻāϰ 12H āĻšāϞ⧋ 8-bitāĨ¤

āĻāĻŦāĻžāϰ AL āĻŦāĻĻāϞ⧇ 56H āĻ•āϰāϞ⧇:

AX = 1256H — AH āφāϗ⧇āϰ āĻŽāϤ⧋āχ 12H āĻĨāĻžāϕ⧇āĨ¤

āĻāχ register-āϗ⧁āϞ⧋āϰ āĻŦāĻŋāĻļ⧇āώ āĻŦā§āϝāĻŦāĻšāĻžāϰ

āϏāĻŦāϗ⧁āϞ⧋ data āϰāĻžāĻ–āϞ⧇āĻ“ āĻ•āĻŋāϛ⧁ instruction-āĻ āĻāĻĻ⧇āϰ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ­ā§‚āĻŽāĻŋāĻ•āĻž āφāϛ⧇:

Register Name Common special use
AX Accumulator Arithmetic operations and I/O data transfers
BX Base register Holding a base address for memory access
CX Count register Loop counting and shift/rotate counts
DX Data register Multiplication/division and I/O port addressing

āĻāĻ–āύ āύāĻžāĻŽ āĻ“ āĻŽā§‚āϞ āĻ•āĻžāϜ āĻŽāύ⧇ āϰāĻžāĻ–ā§‹; instructions āĻĒ⧜āĻžāϰ āϏāĻŽā§Ÿ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻĻ⧇āĻ–āĻŦāĨ¤

⧍. Pointer āĻ“ Index Registers

EU-āϤ⧇ āφāϰāĻ“ āϚāĻžāϰāϟāĻŋ 16-bit register āφāϛ⧇:

Register Full name Main role
SP Stack Pointer Holds the offset of the top of the stack
BP Base Pointer Helps access data in the stack
SI Source Index Holds the source offset, especially in string operations
DI Destination Index Holds the destination offset, especially in string operations

Stack āφāĻĒāĻžāϤāϤ āĻāĻŽāύ storage āĻ­āĻžāĻŦā§‹ āϝ⧇āĻ–āĻžāύ⧇ āϏāĻ°ā§āĻŦāĻļ⧇āώ āϰāĻžāĻ–āĻž item āφāϗ⧇ āĻŦ⧇āϰ āĻšā§Ÿâ€”āϝ⧇āĻŽāύ āĻĒā§āϞ⧇āĻŸā§‡āϰ āĻ¸ā§āϤ⧂āĻĒāĨ¤ Offset āĻŽāĻžāύ⧇ āĻāĻ•āϟāĻŋ segment-āĻāϰ āĻļ⧁āϰ⧁āϰ āϤ⧁āϞāύāĻžā§Ÿ āĻ…āĻŦāĻ¸ā§āĻĨāĻžāύ; āϏāĻžāĻŽāύ⧇ āĻŦāĻŋāĻ¸ā§āϤāĻžāϰāĻŋāϤ āĻĒ⧜āĻŦāĨ¤

āĻ–ā§‡ā§ŸāĻžāϞ āϰāĻžāĻ–āĻŦ⧇: SP, BP, SI, DI-āϕ⧇ AX-āĻāϰ āĻŽāϤ⧋ āĻĻ⧁āχāϟāĻŋ āφāϞāĻžāĻĻāĻž 8-bit āĻ…āĻ‚āĻļ āĻšāĻŋāϏ⧇āĻŦ⧇ access āĻ•āϰāĻž āϝāĻžā§Ÿ āύāĻžāĨ¤

Exam answer: Registers in the EU

“The EU contains four 16-bit general-purpose registers: AX, BX, CX, and DX. Each can also be accessed as two 8-bit registers. It also contains two 16-bit pointer registers, SP and BP, and two 16-bit index registers, SI and DI.”

Quick check — āĻļ⧁āϧ⧁ āϛ⧋āϟ āωāĻ¤ā§āϤāϰ:

  1. If AX = 7A25H, what are AH and AL?
  2. If AL changes to 40H, what is the new value of AX?
  3. Which register is commonly used as a loop counter?
  4. Can SI be accessed as two separate 8-bit registers in the 8086?