In: Computer Science
Give six examples of memory addressing commands in Intel assembly language two of each(register-memory, register offset with an index, and perhaps one other) and explain what they are doing. Why is there no Assembly command to move an item from one RAM location to another directly?
Below are the addressing modes used in intel 8086 assembly language.
-Immediate addressing mode in which data operand is a part the instruction.
Example:
mov ax, 0954h ; immediate value is moved to register ax.
add cx, 5567h; the data in cx is added to the immediate data.
-Register addressing mode in which operands are registers.
Example:
mov cx, dx; data in register dx is moved to register cx.
add ax,bx; data in registers ax and bx are added.
-Direct addressing or register memory addressing in which specific memory address is directly written in the instruction. operand data is stored in the specified address.
Example;
mov ax,[3456h] ; the data in the given address is directly moves to ax.
add, [de45h],bx ; data in register bx is added to the data in memory location de45h.
Register indirect addressing in which operand registers contains the address of the data. Addresses are stores in bp, bx or index registers such as si and di. These registers contains data segment offset address.
Example:
mov ax,[bx]; suppose register bx has value 3462h, then the data in memory location 3462h will be moved to register ax.
mov [si], bx; data segment offset address is stored in si, suppose si=0220h and data segment ds=0aabh, then memory address is calculated as
Data segment value (left shifted)+ si value =0220+0aa0*10=0cd0h so the instruction moves data in register bx to the memory location.
--Register offset with index( base/indexe addressing addressing)
In this addressing mode, a displacement value is to be added with base/ index register value to get the memory address.
Example;
mov dx,[bx+04]; displacement value 04 is added to the value in base register bx to get the memory address. Then the data in that memory location is moved to register dx.(base addressing)
mov cx, [si+16] ; the displacement value 16 is added to the data segment offset address stored in the index register si to get the memory location of the data. Then that data is added to the data in register cx.(indexed added).
add cx, [ax+si]; data segment offset value is in the index register si. It is added to the register value to get the memory address of the data.(based index address)
add dx,[bx+si+04]; in this, memory address of the data is calculated by adding register value, index register value and the offset value.
Memory to memory mode is not possible in assembly language because RAM memory can only be in one of the two states. read mode or write mode. So to move data from one location of RAM to another, it need switching from read mode to write mode. So a temporary storage is needed to store the data.
But it is possible to move data from RAM to RAM using some high level instruction in microcode that would translate RAM to Register, then from Register to RAM. With recent advancement RAM to RAM data transfer is possible with some support logic, not RAM itself.