Registers
As we start our study of assembly language, there a couple of things to clarify. We need to understand the internals of the CPU better than we do now.
First, let's look at the registers for today's 32-bit registers.
(This is what you will see when you try debugging a program, but let us simplify it back to the 8086/8088.)
It will help to see how we can use these registers in different sizes.
What are all of those registers?
| General-Purpose Registers |
| EAX | Accumulator |
| EBX | Base |
| ECX | Counter |
| EDX | Data |
|
| Segment Registers |
| CS | Code Segment |
| DS | Data Segment |
| SS | Stack Segment |
| ES | Extra Segment |
|
| Index Registers |
| ESI | Source Index |
| EDI | Destination Index |
| EBP | Base Pointer |
|
| Special Registers |
| EIP | Instruction Pointer |
| ESP | Stack Pointer |
|
| Extended Registers | Unused in CMSC313 |
| Flag Registers |
| Bit | Code | Meaning |
| 0 | C | Carry |
| 1 | x | undefined |
| 2 | P | Parity |
| 3 | x | undefined |
| 4 | A | Auxiliary Carry |
| 5 | x | undefined |
| 6 | Z | Zero |
| 7 | S | Sign |
| 8 | T | Trap |
| 9 | I | Interrupt |
| 10 | D | Direction |
| 11 | O | Overflow |
| 12 | x | undefined |
| 13 | x | undefined |
| 14 | x | undefined |
| 15 | x | undefined |
|
Flags
Flags are either Control Flags or Status Flags
Control
Control flags allow the programmer to control the CPU's operation.
- Direction Controls the assumed direction in string processing
- Interrupt Makes it possible for external interrupts to occur
- Trap Determines whether or not the CPU will be halted after each instruction (also known as Trace)
Status
This bits reflect the outcome after of arithmetic and logical operations.
- Carry is set when the result of an unsigned arithmetic operation is too large to fit in the destination.
- Overflow is set when the result of an signed arithmetic operation is too large to fit in the destination.
- Sign is set when the result of an arithmetic or logical operation generates a negative number.
- Zero is set when the result of an arithmetic or logical operation generates a result of zero.
- Auxiliary Carry is used with BCD operations.
- Parity is used to check for odd or even parity, useful in communications.