General purpose registers:
- AL/AH/AX/EAX/RAX: Accumulator
- CL/CH/CX/ECX/RCX: Counter (for use with loops and strings)
- DL/DH/DX/EDX/RDX: Extend the precision of the accumulator (e.g. combine 32-bit EAX and EDX for 64-bit integer operations in 32-bit code)
- BL/BH/BX/EBX/RBX: Base index (for use with arrays)
- SP/ESP/RSP: Stack pointer for top address of the stack.
- BP/EBP/RBP: Stack base pointer for holding the address of the current stack frame.
- SI/ESI/RSI: Source index for string operations.
- DI/EDI/RDI: Destination index for string operations.
- IP/EIP/RIP: Instruction pointer. Holds the program counter, the address of next instruction.
Segment registers:
- CS: Code
- DS: Data
- SS: Stack
- ES: Extra data
- FS: Extra data #2
- GS: Extra data #3
源自: https://en.wikipedia.org/wiki/X86#x86_registers
更详细的介绍请见: X86-assembly/Registers - aldeid
还有:https://riptutorial.com/Download/intel-x86-assembly-language---microarchitecture.pdf
相关内容(Page 80) Chapter 11: Register Fundamentals
16-bit Registers When Intel defined the original 8086, it was a 16-bit processor with a 20-bit address bus (see below). They defined 8 general-purpose 16-bit registers - but gave them specific roles for certain instructions:
• AX The Accumulator register. Many opcodes either assumed this register, or were faster if it was specified.
• DX The Data register. This was sometimes combined as the high 16 bits of a 32-bit value with AX - for example, as the result of a multiply.
• CX The Count register. This was used in a number of loop-oriented instructions as the implicit counter for those loops - for example LOOPNE (loop if not equal) and REP (repeated move/compare)
• BX The Base register. This could be used to index the base of a structure in memory - none of the above registers could be used to directly index into memory.
• SI The Source Index register. This was the implicit source index into memory for certain move and compare operations.
• DI The Destination Index register. This was the implicit destination index into memory for certain move and compare operations.
• SP The Stack Pointer register. This is the least general-purpose register in the set! It pointed to the current position in the stack, which was used explicitly for PUSH and POP operations, implicitly for CALL and RET with subroutines, and VERY implicitly during interrupts. As such, using it for anything else was hazardous to your program!
• BP The Base Pointer register. When subroutines call other subroutines, the stack holds multiple "stack frames". BP could be used to hold the current stack frame, and then when a new subroutine was called it coould be saved on the stack, the new stack frame created and used, and on return from the inner subroutine the old stack frame value could be restored.
Original Segment Registers:
So they implemented the idea of "Segments" - a 64 kilobyte block of memory indexed by the 16-bit address registers - that could be re-based to address different areas of the total memory. To hold these segment bases, they included Segment Registers:
• CS The Code Segment register. This holds the segment of the code that is currently being executed, indexed by the implicit IP (Instruction Pointer) register.
• DS The Data Segment register. This holds the default segment for data being manipulated by the program.
• ES The Extra Segment register. This holds a second data segment, for simultaneous data operations across the total memory.
• SS The Stack Segment register. This holds the segment of memory that holds the current stack.
More Segment Registers:
When Intel was designing the 80386, they recognised that the existing suite of 4 Segment Registers wasn't enough for the complexity of programs that they wanted it to be able to support. So they added two more:
• FS The Far Segment register
• GS The Global Segment register
These new Segment registers didn't have any processor-enforced uses: they were merely available for whatever the programmer wanted.
Some say that the names were chosen to simply continue the C, D, E theme of the existing set...
64-bit registers
AMD is a processor manufacturer that had licensed the design of the 80386 from Intel to produce compatible - but competing - versions. They made internal changes to the design to improve throughput or other enhancements to the design, while still being able to execute the same programs.
To one-up Intel, they came up with 64-bit extensions to the Intel 32-bit design and produced the first 64-bit chip that could still run 32-bit x86 code. Intel ended up following AMD's design in their versions of the 64-bit architecture.
The 64-bit design made a number of changes to the register set, while still being backward compatible: The existing general-purpose registers were extended to 64 bits, and named with an R prefix: RAX, RBX, RCX, RDX, RSI, RDI, RBP, and RSP.
Again, the bottom halves of these registers were the same E-prefix registers as before, and the top halves couldn't be independently accessed.
• 8 more 64-bit registers were added, and not named but merely numbered: R8, R9, R10, R11, R12, R13, R14, and R15.
○ The 32-bit low half of these registers are R8D through R15D (D for DWORD as usual). The lowest 16 bits of these registers could be accessed by suffixing a W to the register name: R8W through R15W.
○ • The lowest 8 bits of all 16 registers could now be accessed: ○ The traditional AL, BL, CL, and DL;
○ The low bytes of the (traditionally) pointer registers: SIL, DIL, BPL, and SPL;
○ And the low bytes of the 8 new registers: R8B through R15B.
○ However, AH, BH, CH, and DH are inaccessible in instructions that use a REX prefix (for 64bit operand size, or to access R8-R15, or to access SIL, DIL, BPL, or SPL). With a REX prefix, the machine-code bit-pattern that used to mean AH instead means SPL, and so on. See Table 3-1 of Intel's instruction reference manual (volume 2).
Writing to a 32-bit register always zeros the upper 32 bits of the full-width register, unlike writing to an 8 or 16-bit register (which merges with the old value, which is an extra dependency for out-oforder execution).
也许古老的MS-DOS下这些汇编的寄存器更简单易懂,而现在的win10(Win11)下复杂的多。如果要感受MS-DOS的复古风格,可以在这里下载: https://www.dosbox.com/
相关介绍:MS-DOS DEBUG Program
MS-DOS DEBUG下的命令:https://montcs.bloomu.edu/Information/LowLevel/DOS-Debug.html
|
例如r命令: