CPU registers are classified into five categories as follows
- Segment registers
- Pointer registers
- General Purpose registers
- Index registers
- Flags register
1. Segment registers
- Segments (20-bit wide) are special areas defined in a program for containing the code, the data and stack.
- segment begins on a paragraph boundary; that is at a location evenly divisible by 16
- segment registers are 16-bit size and contains starting address of the segment (Reason: since segments are starting on a paragraph boundary, the designers decided that it would be unnecessary to store the zero digit in the segment register)
- Offset is 16 bits wide (and is specified in Pointer registers described later)
- Further classified into Code, data, stack and extra - corresponds to CS, DS, SS, ES, FS and GS registers
2. Pointer registers
- Pointer registers are 32-bit EIP, ESP and EBP; the rightmost are IP, SP and BP respectively (16-bit wider as mentioned above)
- IP register is associated with CS register (as CS:IP => Segment:Offset)
Example - Segment address in CS 39B40h
Offset address in IP +0514h
------------
Address of next instruction 3A054h
------------
- SP register is associated with SS register (as SS:SP => Segment:Offset)
Example - Segment address in SS 39B40h
Offset address in SP +0514h
------------
Address in stack 3A054h
------------
- BP facilitates referencing parameters, which are data and addresses that a program passes via the stack. Processor combines the address in SS with the offset in BP. BP can also be combined with DI and with SI as a base register for special addressing.
3. General Purpose registers
- 32-bit general purpose registers
- AX - primary accumulator - used for operations involving input/output and most arithmetic - more efficient compared to other registers
- BX - base register - only register used as an index to extend addressing - can also be combined with DI or SI as a base register for special addressing
- CX - count register - may contain a value to control the number of times a loop is repeated or a value to shift bits left or right
- DX - data regsiter - works with AX sometimes, to compute operations that involve large values
4. Index registers
- SI (soure index) - may be required for some string (character) handling operations - in this context, SI is associated with DS register (as DS:SI)
- DI (destination index) - is required for some string operations - in this context, DI is associated with ES register
5. Flags register
- 32 bit wder
- OF (overflow), IF (interrupt), TF (trap), SF (sign), ZF (zero), AF (auxiliary carry), PF (parity) and CF (carry)
No comments:
Post a Comment