MOV (move data)
It transfers bytes or words of data between two registers or between registers and memory in the 8086 through the 80286. Bytes, words, or doublewords are transferred in the 80386 and above by a MOV.
Data-addressing modes
it includes register, immediate, direct, register indirect, baseplus index, register-relative, and base relative-plus-index in the 8086 through the 80286 microprocessors.
Program memory - addressing modes
it include program relative, direct, and indirect.
Opcode (operation code)
tells the microprocessor which operation to perform.
MOV (move data)
it is an instruction is a very common and flexible instruction, it provides a basis for the explanation of the data-addressing modes. The source is to the right and the destination is to the left, next to the opcode.
Operands
The source and destination are often called ____
Register Addressing
transfers a copy of a byte or word from the source register or contents of a memory location to the destination register or memory location.
Register Addressing
Example: The MOV CX, DX instruction copies the word-sized contents of register DX into register CX.
Immediate addressing
transfers the source, an immediate byte, word, doubleword, or quadword of data, into the destination register or memory location.
Immediate addressing
Example: The MOV AL, 22H instruction copies a byte-sized 22H into register AL.
Direct addressing
moves a byte or word between a memory location and a register. The instruction set does not support a memory-to-memory transfer, except with the MOVS instruction.
Direct addressing
Example: The MOV CX, LIST instruction copies the word-sized contents of memory location LIST into register CX.
Register indirect addressing
transfers a byte or word between a register and a memory location addressed by an index or base register. The index and base registers are BP, BX, DI, and S1.
Register indirect addressing
Example: The MOV AX, [BX] instruction copies the word-sized data from the data segment offset address indexed by BX into register AX.
Base-plus-index addressing
transfers a byte or word between a register and the memory location addressed by a base register (BP or BX) plus an index register (DI or SI).
Base-plus-index addressingz
Example: The MOV [BX+DI], CL instruction copies the byte-sized contents of register CL into the data segment memory location addressed by BX plus DI.
Register relative addressing
moves a byte or word between a register and the memory location addressed by an index or base register plus a displacement.
Register relative addressing
Example: MOV AX,[BX+4]or MOV AX,ARRAY[BX]. The first instruction loads AX from the data segment address formed by BX plus 4. The second instruction loads AX from the data segment memory location in ARRAY plus the contents of BX.
Base relative-plus-index addressing
transfers a byte or word between a register and the memory location addressed by a base and an index register plus a displacement.
Base relative-plus-index addressing
Example: MOV AX, ARRAY[BX+DI] or MOV AX, [BX+DI+4]. These instructions load AX from a data segment memory location. The first instruction uses an address formed by adding ARRAY, BX, and DI and the second by adding BX, DI, and 4.
Scaled-index addressing
is available only in the 80386 through the Pentium 4 microprocessor. The second register of a pair of registers is modified by Notes by: RM the scale factor of 2x, 4x or 8x to generate the operand memory address.
Scaled-index addressing
Example: A MOV EDX, [EAX+4*EBX] instruction loads EDX from the data segment memory location addressed by EAX plus four times EBX.
RIP relative addressing mode
is only available to the 64-bit extensions on the Pentium 4 or Core2. This mode allows access to any location in the memory system by adding a 32-bit displacement to the 64-bit contents of the 64-bit instruction pointer.
RIP relative addressing mode
Example: For example, if RIP = 1000000000H and a 32-bit displacement is 300H, the location accessed is1000000300H. The displacement is signed so data located within +-2G from the instruction is accessible by this addressing mode.
Register Addressing
the most common form of data addressing and, once the register names are learned, is the easiest to apply.
8-bit register:
AH, AL, BH, BL, CH, CL, DH, and DL.
16-bit register:
AX, BX, CX, DX, SP, BP, SI, and DI.
Extended 32-bit register:
EAX, EBX, ECX, EDX, ESP, EBP, EDI, and ESI.
64-bit mode:
RAX, RBX, RCX, RDX, RSP, RBP, RDI, RSI, and R8 through R15.
16-bit segment register;
CS, ES, DS, SS, FS, and GS.
Immediate Addressing
The term immediate implies that the data immediately follow the hexadecimal opcode in the memory. Also note that immediate data are constant data, whereas the data transferred from a register or memory location are variable data.
-Intel ASM, Microsoft MASM, and Borland TASM
The most common assemblers
The .MODEL TINY
statement directs the assembler to assemble the program into a single code segment.
The .CODE
statement or directive indicates the start of the code segment.
The .STARTUP
statement indicates the starting instruction in the program.
The .EXIT
statement causes the program to exit to DOS.
The END
statement indicates the end of the program file.
DOS EDIT program, Windows NotePad, or Programmer’s WorkBench (PWB)
To store the program into the system
Label, Opcode Field, Operand field and Comment Field
Assembly language program Four Parts or Fields
Label
The leftmost field and it is used to store a symbolic name for the memory location that it represents. It may be of any length from 1 to 35 characters. It appears in a program to identify the name of a memory location for storing data and for other purposes that are explained as they appear.
Opcode Field
it is designed to hold the instruction, or opcode.
Operand field
which contains information used by the opcode.
Comment Field
contains a comment about an instruction or a group of instructions. A comment always begins with a semicolon (;).
.LST
In this view, the hexadecimal number at the far left is the offset address of the instruction or data.
direct addressing
A direct data addressing form which with a MOV instruction transfers data between a memory location, located within the data segment, and the AL (8-bit), AX (l6-bit), or EAX (32-bit) register. Using this type of addressing is usually a 3-byte long instruction.
displacement addressing
A direct data addressing form which almost identical to direct addressing, except that the instruction is 4 bytes wide instead of 3.
SMALL
a model allows one data segment and one code segment. It is often used whenever memory data are required for a program. It programs assembles as an execute (.EXE) program file.
Register Indirect Addressing
allows data to be addressed at any memory location through an offset address held in any of the following registers: BP, BX, DI, and SI.
Data segment
is used by default with register indirect addressing or any other addressing mode that uses BX, DI, or SI to address memory.
stack segment
If the BP register addresses memory, the ____ is used by default.
Special Assembler Directive
The size is specified by this BYTE PTR, WORD PTR, DWORD PTR, or QWORD PTR.
OFFSET
directive is used with the MOV instruction, the assembler calculates the offset address and then uses a MOV immediate instruction to load the address in the specified 16-bit register.
Base-Plus-Index Addressing
It is similar to indirect addressing because it indirectly addresses memory data. In the 8086 through the 80286, this type of addressing uses one base register (BP or BX) and one index register (DI or SI) to indirectly address memory
base register
often holds the beginning location of a memory array.
index register
holds the relative position of an element in the array.
Register Relative Addressing
is similar to base-plus-index addressing and displacement addressing. In register relative addressing, the data in a segment of memory are addressed by adding the displacement to the contents of a base or an index register (BP, BX, DI, or SI).
Base Relative-Plus-Index Addressing
is similar to base-plus-index addressing, but it adds a displacement, besides using a base register and an index register, to form the memory address. This type of addressing mode often addresses a two-dimensional array of memory data.
Scaled-Index Addressing
is the last type of data-addressing mode discussed. Scaled-index addressing uses two 32-bit registers (a base register and an index register) to access the memory. The second register (index) is multiplied by a scaling factor
RIP Relative Addressing
This form of addressing uses the 64-bit instruction pointer register in the 64-bit mode to address a linear location in the flat memory model.
Data Structure
is used to specify how information is stored in a memory array and can be quite useful with applications that use arrays. It is best to think of a ______ as a template for data.
Data Structure
The start of a structure is identified with the STRUC assembly language directive and the end with the ENDS statement.
Program memory-addressing modes
used with the JMP (jump) and CALL instructions, consist of three distinct forms: direct, relative, and indirect. This section introduces these three addressing forms, using the JMP instruction to illustrate their operation.
Direct program memory addressing
is what many early microprocessors used for all jumps and calls. _____ addressing is also used in high-level languages, such as the BASIC language GOTO and GOSUB instructions.
Intersegment jump
is a jump to any memory location within the entire memory system.
direct jump
is often called a far jump because it can jump to any memory location for the next instruction.
Label
the name of a memory address, refers to the location that is called or jumped to instead of the actual numeric address.
Relative program memory addressing
is not available in all early microprocessors, but it is available to this family of microprocessors. The term relative means “relative to the instruction pointer (IP).”
short jumps
A 1-byte displacement is used in this
near jumps
a 2-byte displacement is used with and calls.
Intrasegment jumps
Both jumps types are considered to be this. It is a jump anywhere within the current code segment.
Indirect Program Memory Addressing
If a relative register holds the address, the jump is also considered to be an indirect jump
STACK MEMORY-ADDRESSING MODES
It holds data temporarily and stores the return addresses used by procedures. It is an LIFO (last-in, first-out) memory, which describes the way that data are stored and removed from the stack.
PUSH, POP
Data are placed onto the stack with a ____ instruction and removed with a ___ instruction.
CALL, RET
___ an instruction also uses the stack to hold the return address for procedures and a ___ instruction to remove the return address from the stack.
the stack pointer (SP or ESP) and the stack segment register (SS).
The stack memory is maintained by two registers: