420 likes | 584 Views
EECE 374: Microprocessor Architecture and Applications Chapter 3. Agenda. Data addressing mode Program addressing mode Stack memory addressing mode. Chapter 3. How do we indicate a data item (e.g., 0xab) We can give the data item (0xab or abh) name?
E N D
EECE 374: Microprocessor Architecture and ApplicationsChapter 3
Agenda • Data addressing mode • Program addressing mode • Stack memory addressing mode
Chapter 3 • How do we indicate a data item (e.g., 0xab) • We can give the data item (0xab or abh) name? • We can give the location in memory (address) where that data item is stored • We can give the name of a register containing that data item • We can give the name of a register containing the memory address for that data item • We can give the name of a register and an offset and compute the memory address for that data item based on the register and offset
Register Addressing • Copy the contents of one register to another register • Note: Registers are of the same size • MOV BX, CX • MOV EBX, ECX
Register Addressing • Notice • Use registers that are of the same size • MOV does not affect flags • Changing the CS register with MOV is not allowed • Why?
Immediate Addressing • Immediate = Use the value to be moved
Direct Addressing • Direct = address is used in the instruction • MOV AL, [1234H] when DS=1000H
Register Indirect Addressing • Register indirect = the register used in the instruction contains the address • MOV AX, [BX] • If BX, DI or SI is used, DS is used by default • If BP is used, SS is used
Register Indirect Addressing • MOV AX, [BX]
BYTE, WORD, DWORD Pointerand OFFSET • MOV AL, [DI] = byte data transfer • MOV [DI], 10H = ? • MOV BYTE PTR [DI], 10H • OFFSET directive • MOV BX, OFFSET DATAS • Difference with MOV BX, DATAS?
Register Indirect Addressing(Cont’d) • LOOP instruction decrements the counter (CX). If CX is not zero, jump. Else, no jump
Base-Plus-Index Addressing • Base + offset (or index) • Index register (DI or SI) • MOV DX, [BX+DI] • Base register (BP or BX) • If BP is used, the data is in the stack segment
Base-Plus-Index Addressing • MOV DX, [BX+DI]
Register Relative Addressing • Data addressed by adding displacement to the contents of base (BP or BX) or index register (DI or SI) • MOV AX, [BX+1000H] • If BP is used, SS is used to calculate address
Register Relative Addressing • MOV AX, [BX+1000H]
Base Relative-Plus-Index Addressing • Access two dimensional data • MOV AX, [BX+SI+100H]
Other Addressing Modes • Direct program memory addressing • Instruction contains opcode, offset, segment • Intersegment jump(far jump): jump to anywhere in entire memory, e.g., JMP [10000H] • Relative (PC-relative) program memory addressing • Relative to the IP (instruction pointer) • Intrasegment jump (short or near jump) • jump within current code segment • short = 1B displacement • near = 2B displacement
PUSH and POP PUSH BX : SP <- SP-2 POP CX : SP <- SP+2
Homework • 7, 29, 31, 33, 35, 45