Addressing Modes Immediate #<data> or Imm

Slides:



Advertisements
Similar presentations
Instruction Set Design
Advertisements

Chapter 3 Loaders and Linkers
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
Chapter 11 Instruction Sets
Chapter 6: Machine dependent Assembler Features
Execution of an instruction
Pentium Addressing Modes
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Chapter 11 Instruction Sets: Addressing Modes and Formats HW: 11.4, 5, 13, 16 (Due 11/15)
Part II: Addressing Modes
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
MIPS coding. SPIM Some links can be found such as:
Computer Architecture and the Fetch-Execute Cycle
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Execution of an instruction
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
Computer Organization
Addressing Modes1 Addressing modes are concerned with how the CPU accesses the operands used by its instructions.
INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
G.Umamaheswari Lect/IT R.M.D.EC system software
Addressing Modes and Formats
Loader and Linker.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Linking Loader untuk SIC/XE Machine. Lebih Lanjut mengenai Absolute Loader Shortcoming of an absolute loader –Programmer needs to specify the actual address.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
Displacement (Indexed) Stack
Instruction sets : Addressing modes and Formats
Machine dependent Assembler Features
CSCI206 - Computer Organization & Programming
Machine Code typically: word 1 words 2-3 words 4-5
William Stallings Computer Organization and Architecture 6th Edition
Addressing Modes the addressing mode defines how data is accessed
How objects are located in memory
Figure 8.1 of course package
Computer Science 210 Computer Organization
Chapter 11 Instruction Sets
System Programming and administration
Alvaro Mauricio Peña Dariusz Niworowski Frank Rodriguez
Microcomputer Programming
William Stallings Computer Organization and Architecture 8th Edition
Computer Science 210 Computer Organization
EECE-276 Fall 2003 Microprocessors & Microcontrollers II
Lecture 3 - Instruction Set - Al
ECE 445 CS1251 Computer Organization Carl Hamacher
Computer Science 210 Computer Organization
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
Computer Science 210 Computer Organization
CSCI206 - Computer Organization & Programming
Addressing Modes Immediate #<data> or Imm
ECEG-3202 Computer Architecture and Organization
Memory Management Tasks
Computer Architecture and the Fetch-Execute Cycle
68000 Architecture, Data Types and Addressing Modes
Write a program to calculate x**y, given x and y.
Figure 8.1 of course package
Computer Organization and Design Assembly & Compilation
Introduction to Micro Controllers & Embedded System Design
CNET 315 Microprocessor & Assembly Language
Mastering Memory Modes
Addressing Modes Immediate #<data> or Imm
William Stallings Computer Organization and Architecture 8 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.
ECE511: Digital System & Microprocessor
Presentation transcript:

Addressing Modes Immediate #<data> or Imm data is part of the instruction Register Direct Dn or An data is in a register the address of the data is the register number Memory Direct (xxx).W or (xxx).L data is in a memory location the address of the data is the address of the memory location Address Register Indirect (An) Postincrement (An)+ the address of the data is in the address register Predecrement -(An) the address of the data is the contents of the address register minus the decrement

Address Register Indirect … variations Address register indirect with displacement d(An) operand is written as d(An) where d = 16 bit displacement the address of the data is the sum of the address register and the displacement instruction registers memory d An address data displacement

Address Register Indirect w/ displacement Rows EQU 3 Cols EQU 4 … LEA Table,A0 Loop MOVE.B 3(A0),D0 … ADDA.L #Cols,A0 CMPA.L #Table+Rows*Cols,A0 BNE Loop … Table DC.B 15,14,13,12 DC.B 9,8,7,6 DC.B 4,3,2,1

Address Register Indirect … variations Address register indirect with indexing d(An,Rn) operand is written as d(An,Ri{.W|.L}) where d = 8 bit displacement and Ri is an index register (W or L) the address of the data is the sum of the address register, the index register, and the displacement instruction registers memory data d Ri An address index displacement

Address Register Indirect w/ indexing Rows EQU 3 Cols EQU 4 … LEA Table,A0 MOVE.W #0,D1 Loop MOVE.B 3(A0,D1.W),D0 ADDI.W #Cols,D1 CMPI.W #Rows*Cols,D1 BNE Loop Table DC.B 15,14,13,12 DC.B 9,8,7,6 DC.B 4,3,2,1

Program Counter Relative … variations SOURCE ONLY – except for BTST, branches, jumps Program Counter Relative … variations Program counter relative w/ displacement d(PC) operand is written as d(PC) where d = 16 bit displacement the address of the data is the sum of the program counter and the displacement instruction registers memory d PC address data displacement

Program Counter Relative … variations Program counter relative w/ displacement d(PC) operand is written as label(PC) where label refers to a label in the program when reading code, treat as if (PC) not there the use of a label reference causes the assembler to calculate an offset to the PC instruction registers memory label PC instruction address data label - PC = offset

Program Counter Relative … examples e.g. MOVE.W $50(PC),D2 e.g. MOVEA.L WK(PC),A0 … WK DC.L WK_CASE e.g. JMP NEXT(PC) NEXT MOVEQ.B #1,D0 If instruction located at $2050, then <ea> = $2052+$50 =$20A2 Move contents from memory location $20A2 to D2. If instruction located at $1000 and WK located at $1508, then offset = $1508 - $1002 = $0506 <ea> = $1002 + $0506 = $1508 Move address WK_CASE to A0. If instruction located at $3000 and NEXT located at $3052, then offset = $3052 - $3002 = $0050 <ea> = $3002 + $0050 = $3052 Jump to NEXT.

Program Counter Relative … variations Program counter relative w/ indexing d(PC,Rn) operand is written as d(PC,Ri{.W|.L}) where d = 8 bit displacement the address of the data is the sum of the PC, the index register, and the displacement registers instruction memory d Ri PC PC data Ri displacement

Program Counter Relative … variations Program counter relative w/ indexing d(PC,Rn) operand is written as label(PC,Ri{.W|.L}) where label refers to a label in the program the use of a label reference causes the assembler to calculate an offset to the PC registers instruction memory label PC Ri Ri PC data label - PC = offset

Program Counter Relative … example e.g. print an appropriate error msg from a return code in D0 …. D0 is 2 … LSL.W #2,D0 MOVEA.L CASES(PC,D0.W),A0 JMP (A0) … * CASEx are the names of code segments to handle the various situations CASES DC.L CASE0 DC.L CASE1 DC.L CASE2 DC.L CASE3

Position Independent Code code can be loaded and executed from any starting address in memory after it has been assembled; address assigned at run time static → after assembly, e.g. shared library, ROM based program dynamic → can be moved after it has started execution, e.g. virtual memory system

Position Independent Code no absolute addresses except for hardware device addresses PC-relative addressing is used wherever possible for branches within modules where PC-relative addressing cannot be used, indirect addressing through a linkage table is used for accesses to global variables, for inter-module procedure calls, for branches and literal accesses The dynamic loader fills in procedure and data linkage tables with the absolute virtual addresses of the routines and data in a shared library at run time (known as binding) .

Relocatable vs NonRelocatable Code code can be moved to different starting address but requires reassembly code contains symbols but no explicit addresses (except hardware) addresses assigned at link time NonRelocatable Code code requires reprogramming to be moved to a different memory location code contains actual addresses addresses assigned during programming

What is the code type? START LEA *+0,A0 ADDA.L #(TABLE-START),A0 For the following examples, TABLE DS.B 100 is at address $100E e.g. MOVEA.L #$100E,A0 e.g. MOVEA.L #TABLE,A0 e.g. LEA TABLE(PC),A0 e.g. START LEA *+0,A0 ADDA.L #(TABLE-START),A0

Reading: Expectations: M68000 Assembly Language [92p; N. Znotinas] review operation of address register instructions: CMPA, ADDA, SUBA, MOVEA, LEA Addressing Modes [© Stephen J Kuyath, UNCC, 2007] - has good single step animations for the various addressing modes - best way to use the animations is to (1) look at the instruction he is executing, (2) figure out the actions, (3) determine the final result, and (4) then single step through the animation to verify - for PC relative, he is showing the PC after the instruction fetch Position Independent Code from “Assembly Language and Systems Programming for the M68000 Family” William Ford, William R. Topp - many good examples, some later examples use the M68020 program counter memory indirect addressing mode which has a scale (multiplication) factor and some additional fields; in M68000, you have to shift (multiply) the index explicitly Expectations: I do not expect you to be able to write code using program relative addressing modes but you should be able to read code that contains program relative addressing modes you should be able to use all of the address register indirect variations you should be able to classify the code type for a given sample of code