X86 register file
This prefix is added automatically by assemblers when an operand contains a bit register. Note: The instruction pointer can only be used in RIP-relative addressing, which was introduced with long mode.
NOTE that this register is the only control register that can be written and read via 2 ways unlike the other that can be accessed only via the MOV instruction. This control register contains the linear virtual address which triggered a page fault, available in the page fault's interrupt handler.
CR8 is a new register accessible in bit mode using the REX prefix. CR8 is used to prioritize external interrupts and is referred to as the task-priority register TPR. The AMD64 architecture allows software to define up to 15 external interrupt-priority classes. Priority classes are numbered from 1 to 15, with priority-class 1 being the lowest and priority-class 15 the highest.
CR8 uses the four low-order bits for specifying a task priority and the remaining 60 bits are reserved and must be written with zeros. System software can use the TPR register to temporarily block low-priority interrupts from interrupting a high-priority task. This is accomplished by loading TPR with a value corresponding to the highest-priority interrupt that is to be blocked.
For example, loading TPR with a value of 9 b blocks all interrupts with a priority class of 9 or less, while allowing all interrupts with a priority class of 10 or more to be recognized. Some instructions also use it as a counter.
Preserved register: don't use it without saving it! The stack pointer. Points to the top of the stack details coming soon! Preserved register. Sometimes used to store the old value of the stack pointer, or the "base". Scratch register used to pass function argument 2 in bit Linux. In bit Windows, a preserved register. Scratch register and function argument 1 in bit Linux.
Scratch register. These were added in bit mode, so they have numbers, not names. You can use it, but you need to save and restore it. Unlike in high level languages where arrays can have many dimensions and are accessed by indices, arrays in x86 assembly language are simply a number of cells located contiguously in memory.
An array can be declared by just listing the values, as in the first example below. Two other common methods used for declaring arrays of data are the DUP directive and the use of string literals. The DUP directive tells the assembler to duplicate an expression a given number of times. For example, 4 DUP 2 is equivalent to 2, 2, 2, 2. Some examples:. Examples push eax — push eax on the stack push [var] — push the 4 bytes at address var onto the stack.
Arithmetic and Logic Instructions add — Integer Addition The add instruction adds together its two operands, storing the result in its first operand. Note, whereas both operands may be registers, at most one operand may be a memory location.
Examples imul eax, [var] — multiply the contents of EAX by the bit contents of the memory location var. Store the result in EAX. The shifted operand can be shifted up to 31 places. The number of bits to shift is specified by the second operand, which can be either an 8-bit constant or the register CL.
In either case, shifts counts of greater then 31 are performed modulo Control Flow Instructions The x86 processor maintains an instruction pointer IP register that is a bit value indicating the location in memory where the current instruction starts.
Normally, it increments to point to the next instruction in memory begins after execution an instruction. The IP register cannot be manipulated directly, but is updated implicitly by provided control flow instructions. Labels can be inserted anywhere in x86 assembly code text by entering a label name followed by a colon. Elsewhere in the code, we can refer to the memory location that this instruction is located at in memory using the more convenient symbolic name begin.
This label is just a convenient way of expressing the location instead of its bit value. The contents of the machine status word include information about the last arithmetic operation performed. For example, one bit of this word indicates if the last result was zero. Another indicates if the last result was negative. Based on these condition codes, a number of conditional jumps can be performed.
For example, the jz instruction performs a jump to the specified operand label if the result of the last arithmetic operation was zero.
Otherwise, control proceeds to the next instruction in sequence. A number of the conditional branches are given names that are intuitively based on the last operation performed being a special compare instruction, cmp see below.
For example, conditional branches such as jle and jne are based on first performing a cmp operation on the desired operands. Otherwise, continue to the next instruction. This instruction is equivalent to the sub instruction, except the result of the subtraction is discarded instead of replacing the first operand.
The call instruction first pushes the current code location onto the hardware supported stack in memory see the push instruction for details , and then performs an unconditional jump to the code location indicated by the label operand. Unlike the simple jump instructions, the call instruction saves the location to return to when the subroutine completes. The ret instruction implements a subroutine return mechanism.
This instruction first pops a code location off the hardware supported in-memory stack see the pop instruction for details.
0コメント