Introduction to Registers By Bill T. May 10, 1998 Introduction ----------------------------------------------------------------------------- Registers are located directly on the CPU. They are used to store data for processing. The general registers can be used to store anything needed, but some registers are specialized for certain functions. Registers ----------------------------------------------------------------------------- General Purpose Registers: EAX Accumulator: Used for general purpose and slightly specialized for mathematical results EBX Base: Used for general purpose and specialized for indexing ECX Counter: Used for general purpose and specialized for counting EDX Data: General purpose register Each of these registers are 32-bit. They each can be divided into a 16-bit register: AX, BX, CX, DX. They can also be furthur divided into two 8-bit registers, AH (high) and AL (low). EAX is 32-bit, therefore it is 4 bytes, called a DWORD. AX is 16-bit, 2 bytes, called a WORD. AL and AH are each 8-bit or 1 BYTE. Offset Registers: EBP Base Pointer: General purpose, holding offsets, and indexing ESP Stack Pointer: Points to the top of the stack The next item pushed on the stack goes here ESI Source Index: Used for general purpose as well as the source in data movement operations EDI Destination Index: Used for general purpose as well as the destination in data movement operations EIP Instruction Pointer: Points to the instruction to be executed next Each of these registers asre 32-bit, but can also be accessed as a 16-bit register (BP, SP, SI, DI, IP). Segment Registers: CS Code Segment: Segment containing the code of the current program DS Data Segment: Segment containing the data of current program ES Extra Segment: Function depends upon program, may be unused FS Extra Segment: GS Extra Segment: SS Stack Segment: Segment which contains the stack memory These registers are each 16-bit. Each locate the start of a 64K segment in memory. You cannot perform math on segment registers or use them to hold the results of other operations. Segments may be stored anywhere in memory. Flags Register: o Overflow Flag d Direction Flag i Interrupt Enable Flag t Trap Flag s Sign Flag z Zero Flag a Auxillary Flag p Parity Flag c Carry Flag The flags usually represent the result of various instructions. In addition to those listed there are several other flags which are not frequently used. Other Registers: CR0-CR3 Control Registers These 32-bit registers handle things such as processor mode, paging and so on. DR0-DR7 Debug Registers These are 32-bit registers which are used for debugging purposes. DR0-DR3 are used to hold breakpoint addresses and DR4-DR7 determine the results of a breakpoint. TR6-TR7 Test Registers These 32-bit registers are used to test memory paging. IDTR Interrupt Descriptor Table Register (52-bit) GDTR Global Descriptor Table Register (52-bit) LDTR Local Descriptor Table Register (68-bit) TR Task State Segment Register (68-bit) ----------------------------------------------------------------------------- Copyright (C) 1998 Bill T. (billasm@usa.net)