1 / 42

EECE 374: Microprocessor Architecture and Applications Chapter 3

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?

salma
Download Presentation

EECE 374: Microprocessor Architecture and Applications Chapter 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EECE 374: Microprocessor Architecture and ApplicationsChapter 3

  2. Agenda • Data addressing mode • Program addressing mode • Stack memory addressing mode

  3. 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

  4. Addressing Modes

  5. Register Addressing • Copy the contents of one register to another register • Note: Registers are of the same size • MOV BX, CX • MOV EBX, ECX

  6. 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?

  7. More ExamplesRegister Addressing

  8. Immediate Addressing • Immediate = Use the value to be moved

  9. Immediate Addressing

  10. More ExamplesImmediate Addressing

  11. Mixing C and Assembly Code

  12. Direct Addressing • Direct = address is used in the instruction • MOV AL, [1234H] when DS=1000H

  13. Direct Addressing

  14. More ExamplesDirect Addressing

  15. 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

  16. Register Indirect Addressing • MOV AX, [BX]

  17. Register Indirect Addressing

  18. 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?

  19. Register Indirect Addressing

  20. Register Indirect Addressing(Cont’d) • LOOP instruction decrements the counter (CX). If CX is not zero, jump. Else, no jump

  21. 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

  22. Base-Plus-Index Addressing • MOV DX, [BX+DI]

  23. Base-Plus-Index Addressing

  24. Base-Plus-Index Addressing

  25. More ExamplesBase-Plus-Index Addressing

  26. 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

  27. Register Relative Addressing • MOV AX, [BX+1000H]

  28. Register Relative Addressing

  29. More ExamplesRegister Relative Addressing

  30. Base Relative-Plus-Index Addressing • Access two dimensional data • MOV AX, [BX+SI+100H]

  31. Base Relative-Plus-Index Addressing

  32. Base Relative-Plus-Index Addressing

  33. More Examples of Base Relative-Plus-Index Addressing

  34. Scaled Index Addressing

  35. Data Structure

  36. Data Strucutre

  37. 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

  38. Indirect Program Memory Addressing

  39. PUSH and POP PUSH BX : SP <- SP-2 POP CX : SP <- SP+2

  40. Homework • 7, 29, 31, 33, 35, 45

More Related