A P P E N D I X E S
for
A Guide to DEBUG
( The Microsoft® DEBUG.EXE
Program )
Copyright©2004 by Daniel B. Sedory
This
page may be freely copied for PERSONAL use ONLY !
( It may NOT be used for ANY other purpose UNLESS
you have
first contacted and received permission
from the author ! )
AX: |
|
Accumulator | ||||||||||||
BX: | Base Register | |||||||||||||
CX: | Count Register | |||||||||||||
DX: | Data Register | |||||||||||||
The other 16-bit ( two-byte ) registers of the 8086 CPU are:
| Stack Pointer |
|||||
|
Base Pointer |
|||||
|
Source Index |
|||||
|
Destination Index |
|
|
Code Segment |
||||
|
Data Segment |
|||||
|
Stack Segment |
|||||
|
Extra Segment |
|
|
Instruction Pointer |
The 8086 CPU uses a method I'll call the SEGMENT:
OFFSET scheme whenever it needs to access Memory locations or Jump
from one 64kb Segment to another. It does this by combining two 16-bit
registers together to form a 20-bit Segment:Offset value ( which means it can
access over 1MB of Memory this way). For certain types of tasks, the registers
are often grouped together in the same way, but the programmer must still
make sure that the CPU will use them as expected. Here are a couple tasks which
are set by the CPU itself:
CS : IP Next Instruction
SS : SP Stack Pointer
Two other sets which are often used together in
String operations
are: DS : SI Source Index
ES : DI Destination Index
The "FLAGS" REGISTER
If you really want to use MS-DEBUG (or any other debugger!) to examine the operation of Assembly programs, then I advise you to copy these abbreviations onto notecards and try to understand why certain bits (flags) do/don't change in the register for each instruction in the program you're examining. ( Make sure you study the final table below if you'll be reading textbooks which discuss the newer 16-bit Flags Register. Newer 32-bit debuggers, such as Borland's Turbo Debugger, display the same eight Flags as DEBUG, but use an abbreviation for the Name of the Flag and simply show whether it's a 0 or 1 bit.)
This is an 8-bit register that holds 1-bit of data for each of the eight "Flags" which are to be interpreted as follows: Textbook abbrev. for Flag Name => of df if sf zf af pf cf If the FLAGS were all SET (1), -- -- -- -- -- -- -- -- they would look like this... => OV DN EI NG ZR AC PE CY If the FLAGS were all CLEARed (0), they would look like this... => NV UP DI PL NZ NA PO NC FLAGS SET (a 1-bit) CLEARed (a 0-bit) --------------- --------------- ------------------- Overflow of = OV NV [No Overflow] Direction df = DN (decrement) UP (increment) Interrupt if = EI (enabled) DI (disabled) Sign sf = NG (negative) PL (positive) Zero zf = ZR [zero] NZ [ Not zero] Auxiliary Carry af = AC NA [ No AC ] Parity pf = PE (even) PO (odd) Carry cf = CY [Carry] NC [ No Carry] ============== The individual abbreviations appear to have these meanings: OV = OVerflow, NV = No oVerflow. DN = DowN, UP (up). EI = Enable Interupt, DI = Disable Interupt. NG = NeGative, PL = PLus; a strange mixing of terms due to the fact that 'Odd Parity' is represented by PO (rather than POsitive), but they still could have used 'MI' for MInus. ZR = ZeRo, NZ = Not Zero. AC = Auxiliary Carry, NA = Not Auxiliary carry. PE = Parity Even, PO = Parity Odd. CY = CarrY, NC = No Carry.
Symbols used by MS-DEBUG ----------------------------------- OV DN EI NG ZR AC PE CY ---> When bit = 1 NV UP DI PL NZ NA PO NC ---> When bit = 0 |xx|xx|xx|--|xx|xx| 0|xx| 0|xx| 1|xx| Newer Designations: Bits: 11 10 9 8 7 6 5 4 3 2 1 0 | | | | | | | | | | | '--- CF - Carry Flag | | | | | | | | | | '--- is always a 1 | | | | | | | | | '--- PF - Parity Flag | | | | | | | | '--- is always a 0 | | | | | | | '--- AF - Auxiliary (Carry) Flag | | | | | | '--- is always a 0 | | | | | '--- ZF - Zero Flag | | | | '--- SF - Sign Flag | | | '--- (TF Trap Flag - not shown in MS-DEBUG) | | '--- IF - Interrupt Flag | '--- DF - Direction Flag '--- OF - Overflow flag