Data Transfer Group ECE 511: Digital System & Microprocessor.

Slides:



Advertisements
Similar presentations
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
Advertisements

680XX Program Examples Outline –Binary to BCD –Matrix Addition –Ones Count –String Compare –Sector Map –Raster Graphics –Subroutine Calls Goal –Understand.
Run-time Environment for a Program different logical parts of a program during execution stack – automatically allocated variables (local variables, subdivided.
There are two types of addressing schemes:
Stack Frames: Using LINK. CEG 320/5208: Stack frames and LINK2 Assembling source code One source file: –Use ORG statements for data and code –Assemble.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set.
Computer Architecture CSCE 350
EECC250 - Shaaban #1 Lec # 6 Winter Stack-Related Instructions PEA Push Effective Address Calculates an effective address and pushes it.
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 6.
1 Storage Registers vs. memory Access to registers is much faster than access to memory Goal: store as much data as possible in registers Limitations/considerations:
Procedures in more detail. CMPE12cCyrus Bazeghi 2 Procedures Why use procedures? Reuse of code More readable Less code Microprocessors (and assembly languages)
Exception Processing ECE511: Digital System & Microprocessor.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
Chapters 5 - The LC-3 LC-3 Computer Architecture Memory Map
EECC250 - Shaaban #1 lec #7 Winter Local workspace of a subroutine: A number of temporary memory locations required by the subroutine for temporary.
EET 2261 Unit 2 HCS12 Architecture
Faculty of Computer Science © 2006 CMPUT 229 Subroutines (Part 1) The 68K Stack.
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
ECE 447 Fall 2009 Lecture 5: TI MSP430 Software Development in C and Assembly pt. 2.
Assembly Programming on the TI-89 Created By: Adrian Anderson Trevor Swanson.
1 CSCE3193: Programming Paradigms Nilanjan Banerjee Programming Paradigms University of Arkansas Fayetteville, AR
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
7/23 C Programming in Embedded Systems Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Passing Parameters using Stack Calling program pushes parameters on the stack one element at a time before calling subroutine. Subroutine Call (jsr, bsr)
Procedure (Method) Calls Ellen Spertus MCS 111 September 25, 2003.
Computer Architecture Lecture 13 – part 1 by Engineer A. Lecturer Aymen Hasan AlAwady 31/3/2014 University of Kufa - Information Technology Research and.
MAL 3 - Procedures Lecture 13. MAL procedure call The use of procedures facilitates modular programming. Four steps to transfer to and return from a procedure:
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
INTRODUCTION TO MICROPROCESSOR Engr. Ammar Anwar Khan.
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
1 ECE 372 – Microcontroller Design Assembly Programming HCS12 Assembly Programming Addressing Modes Stack Operations Subroutines.
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
68k Software Model ECE511: Digital System & Microprocessor.
Resets & Interrupts MTT CPU08 Core Motorola CPU08 RESETS & INTERRUPTS.
Microprocessor Programming & Interfacing Tutorial 1 Module 1 &2.
M68k Arithmetic Instructions ECE 511: Digital System & Microprocessor.
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
ECE 511: Digital System & Microprocessor
Logical, Shift, Rotate & BCD. What we will learn in this session: Logical instructions. Shift & Rotate instructions. BCD operations. Bit operations.
M68k Addressing Modes ECE 511: Digital System & Microprocessor.
Index What is an Interface Pins of 8085 used in Interfacing Memory – Microprocessor Interface I/O – Microprocessor Interface Basic RAM Cells Stack Memory.
Instruction set Architecture
Figure 8.1 of course package
Stack Frames Stack frame = block of memory located in the system stack that contains: return address input parameters (from calling program to subroutine)
EECE-276 Fall 2003 Microprocessors & Microcontrollers II
Lecture 3 - Instruction Set - Al
4.4 Bit Manipulation Instructions
Subroutines … a 1st look procedures and functions in high level languages are modeled on subroutines typically, assembly code is very modular with.
Programming 8086 – Part IV Stacks, Macros
MIPS Instructions.
8085 MICROPROCESSOR 8085 CPU Registers and Status Flags S Z AC P C A B
68000 Architecture, Data Types and Addressing Modes
Figure 8.1 of course package
EE6502/MPMC/UNIT II/STACK AND SUBROUTINE/T.THARANKUMAR
M68k Arithmetic Instructions
Lecture 06 Programming language.
Subroutines … passing data
Program and memory layout
8051 ASSEMBLY LANGUAGE PROGRAMMING
Program and memory layout
Program and memory layout
Program and memory layout
Computer Operation 6/22/2019.
ECE511: Digital System & Microprocessor
(The Stack and Procedures)
Presentation transcript:

Data Transfer Group ECE 511: Digital System & Microprocessor

What we will learn in this session Data transfer group instructions:  Moving data around.

Data Transfer Group Instructions to  Move data around.  Assign values to registers, memory.  Manipulate data.

MOVE (Move Data) Moves data into registers, memory. Format: MOVE.s,

MOVE DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss d-ddddddd--- NZVCX **00- BWL

MOVE Example A4 = $ D0 = $AAAAAAAA MOVE.B(A4), D0 $5003$9A $5002$78 $5001$56 $5000$34 $4FFF$12 AAAAAA78 D0 = CCR X = not effected. N = 0 (MSB = 0) Z = 0 (data not zero) V = always clear. C = always clear.

MOVE Example A4 = $ A5 = $FF3000 MOVE.W(A4), (A5) $5003$9A $5002$F8 $5001$56 $5000$34 $4FFF$12 $FF3003… $FF3002… $FF3001$9A $FF3000$F8 $FF2FFF… CCR X = not effected. N = 1 (MSB = 1) Z = 0 (data not zero) V = always clear. C = always clear.

MOVEA (Move Address) Used to transfer data to address register. Only WL can be used. If W used, will be sign-extended to 32-bits. Doesn’t effect CCR.

MOVEA DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssssssssssss -d NZVCX WL

MOVEA Example MOVEA.W# $AAAA,A3 AAAA FFFFAAAA Sign-extended = FFFFAAAA A3 = Final value: D0 = $0000AAAA, A3 = $FFFFAAAA

MOVEA Example D0 = $0000AAAA MOVEA.LD0,A3 0000AAAA D0 = 0000AAAA A3 = Final value: D0 = $0000AAAA, A3 = $0000AAAA *L is specified, value not sign-extended.

MOVEQ (Move Quick) Moves 8-bit immediate data to data register. Data sign-extended to 32-bits before transfer. Generates smaller machine code, executes faster.

MOVEQ DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s d NZVCX **00- L

MOVEQ Example MOVEQ#$AE,D3 FFFFFFAE D3 = AE Immediate data = FFFFFFAE Sign extended = MSB is 1, sign-extended using ones. CCR X = not effected. N = 1 (MSB = 1) Z = 0 (data not zero) V = always clear. C = always clear.

MOVEQ Example MOVEQ#$55,D D3 = 55 Immediate data = Sign extended = MSB is 0, sign-extended using zeros. CCR X = not effected. N = 0 (MSB = 0) Z = 0 (data not zero) V = always clear. C = always clear.

MOVEP (Move Peripheral Data) Created for data transfer with older 8-bit peripherals. If initial address is odd, then MOVEP only takes data from next odd locations in memory. Same for even addresses.

MOVEP DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s----s d----d NZVCX WL

MOVE vs. MOVEP A0 = $1000 D0 = $ MOVE.L D0,0(A0) A0 = $1000 D0 = $ MOVEP.L D0,0(A0) $1000$12 $1001 $1002$34 $1003 $1004$56 $1005 $1006$78 $1007 Memory $1008 (Not modified) $1000$12 $1001 $1002 $34 $1003 $1004 $56 $1005 $1006 $78 $1007 Memory $1008

MOVEP Example: Even Address A0 = $1000 D0 = $ MOVEP.L D0,0(A0) D3 = $1000$12 $1001 $1002$34 $1003 $1004$56 $1005 $1006$78 $1007 Memory $1008 (Not modified)

MOVEP Example: Odd Address A0 = $1001 D0 = $ MOVEP.L D0,0(A0) D3 = $1000 $12$1001 $1002 $34$1003 $1004 $56$1005 $1006 $78$1007 Memory $1008 (Not modified)

MOVEP Example: Move Data to Register A0 = $1001 MOVEP.L 0(A0),D3 00AABBCC D3 = $1000 $00$1001 $1002 $AA$1003 $1004 $BB$1005 $1006 $CC$1007 $1008 (Not taken)

MOVEM (Move Multiple Registers) Two uses:  Move many registers to memory at once.  Move memory locations to registers. Useful to save many registers to stack. Can use WL:  If W specified, is sign-extended. Writes A7-A0, then D7-D0. Takes back D0-D7, then A0-A7.

MOVEM DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ssss-ssssss- ddd-ddddd--- NZVCX WL

MOVEM Example – Registers to Memory A7 = $FFFE MOVEM.L D0-D7,-(A7) D0= D1= D2= D3= D4= AAAABBBB D5= CCCCDDDD D6= EEEEFFFF D7= $FFFC$FFFF $FFFA$EEEE $FFF8$DDDD $FFF6$CCCC $FFF4$BBBB $FFF2$AAAA $FFF0$9999 $FFEE$8888 $FFEC$7777 $FFEA$6666 $FFE8$5555 $FFE6$4444 $FFE4$3333 $FFE2$2222 $FFE0$1111 $FFDE$0000 $FFFE…  1 ST  LAST Old SP  New SP 

MOVEM Example – Mem. to Registers A7 = $FFDE MOVEM.L (A7)+, D0-D D0= D1= D2= D3= D4= AAAABBBB D5= CCCCDDDD D6= EEEEFFFF D7=  LAST  1st $FFFC$FFFF $FFFA$EEEE $FFF8$DDDD $FFF6$CCCC $FFF4$BBBB $FFF2$AAAA $FFF0$9999 $FFEE$8888 $FFEC$7777 $FFEA$6666 $FFE8$5555 $FFE6$4444 $FFE4$3333 $FFE2$2222 $FFE0$1111 $FFDE$0000 $FFFE… New SP  Old SP 

Saving/Recovering All Registers To save all registers to stack:  MOVEM.LD0-D7/A0-A7, -(A7)  Put A7 first, then A6, A5, A4,…  Then put D7, D6, D5, D4, … To get back all registers from stack:  MOVEM.L(A7)+, D0-D7/A0-A7  Gets D0 first, then D1, D2, …, D7.  Then, get A0, A1, …, A7.

MOVEM Example – Selected Registers to Memory A7 = $FFFE MOVEM.L D0/A5/A4/D3,-(A7) D0= D3= A4= AAAABBBB A5= $FFFC $FFFA $FFF8 $FFF6 $FFF4 $BBBB $FFF2 $AAAA $FFF0 $9999 $FFEE $8888 $FFEC $FFEA $FFE8 $FFE6 $FFE4 $3333 $FFE2 $2222 $FFE0 $1111 $FFDE $0000 $FFFE…  LAST Old SP  New SP   1st *MOVEM always puts A7-A0, then D7-D0 It doesn’t matter how you arrange them.

All these are the same… MOVEM.L D0/A5/A4/D3,-(A7) MOVEM.L D0/A4/A5/D3,-(A7) MOVEM.L D3/A5/A4/D0,-(A7) MOVEM.L A5/D0/A4/D3,-(A7) A7  A6  A5  A4  A3  A2  A1  A0 D7  D6  D5  D4  D3  D2  D1  D0

All these are the same… MOVEM.L (A7)+,D0/A5/A4/D3 MOVEM.L (A7)+,D0/A4/A5/D3 MOVEM.L (A7)+,D3/A5/A4/D0 MOVEM.L (A7)+,A5/D0/A4/D3 A0  A1  A2  A3  A4  A5  A6  A7 D0  D1  D2  D3  D4  D5  D6  D7

Exchange & Swap

EXG (Exchange Registers) Exchanges contents of registers. Can only use L. Doesn’t effect CCR.

EXG DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n ss dd NZVCX L

EXG Example D0 = $ D5 = $000000FF EXGD0,D5 D0= D5= FF EXG D0= FF D5=

SWAP (Swap Register Halves) DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n s d NZVCX **00- L Swaps contents of upper and lower words in register.

SWAP Example D0 = $0000FFFF SWAP D0 D0= 0000FFFF SWAP D0= 0000FFFF CCR X = not effected. N = 1 (MSB = 1) Z = 0 (data not zero) V = always clear. C = always clear.

Load/Push Effective Address

LEA (Load Effective Address) Loads effective address into address register. DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n -ss--ssssss- -d NZVCX L

LEA Example Find out the effective address of 3(A0,D1.W) when A0 = $1000, and D1 = $005A. A0 = $ D = $ 3 +D1.W = $ 005A = $ 105D LEA3(A0,D1.W),A D A1 =

PEA (Push Effective Address) Same as LEA, but destination is software stack. DnAn(An)(An)+-(An)d(An)d(An,i)ASAALAd(PC)d(PC,i)#n --s--ssssss- NZVCX L

PEA Example A0 = $ D = $ 36 = $ 8536 A0 = $8500 SP = $ PEA54(A0) MSB is 1, sign extended to 32-bits $ $ $00FFFE$8536 $00FFFC$FFFF Old SP  New SP  Software Stack

Link & Unlink Stack Pointer*

LINK Allocates stack space for data.  Local workspace.  Temporary storage, released using UNLK.  Doesn’t effect CCR. Format: LNK An,

How LINK works An value stored into SP. SP stored into An. SP modified using immediate data value:  Immediate data must be negative.

How LINK Works – Before Execution A0 = $5000 SP = $1000 LINK A0,#-10 $1000 $0FFE $0FFC $0FFA $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE SP 

How LINK Works – Store An into Stack A0 = $5000 SP = $1000 LINK A0,#-10 $1000 $5000$0FFE $0000$0FFC $0FFA $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE SP  Extend to L, then store in Stack.

How LINK Works – Copy Stack to An A0 = $5000 SP = $1000 LINK A0,#-10 $1000 $0FFE$5000 $0FFC$0000 $0FFA $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE SP  SP copied to A FFC A0 =

How LINK Works – Get New SP A0 = $5000 SP = $1000 LINK A0,#-10 $1000 $0FFE$5000 $0FFC$0000 $0FFA $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE New SP  New SP = SP + (-10) New SP = $0FF2 Old SP  Reserved stack space.

How LINK Works – Using A0 to refer to stack space. $1000 $0FFE$5000 $0FFC$0000 $0FFA$1234 $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE Next stack data stored here  A0 = $000FFC MOVE.W #$1234,-2(A0) A0 = $000FFC - =$ 2 EA = $000FFA New SP  Reserved stack space.

UNLK Use to release stack space allocated by LINK. Does this by:  Copies An back into SP.  Copies original An value (in stack) back into An.

How UNLK Works – Initial Conditions A0 = $0FFC SP = $0FF2 UNLK A0 $1000 $0FFE$5000 $0FFC$0000 $0FFA$1234 $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE SP  00000FFC A0 =

How UNLK Works – Copy An into SP A0 = $0FFC SP = $0FF2 UNLK A0 $1000 $0FFE$5000 $0FFC$0000 $0FFA$1234 $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE A0 copied back into SP Old SP  00000FFC A0 = New SP  Reserved stack space lost.

How UNLK Works – Copy stack value to A0 $1000 $0FFE$5000 $0FFC$0000 $0FFA$1234 $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE Original A0 value returned back to A A0 = SP  A0 = $0FFC SP = $0FF2 UNLK A0

How UNLK Works – SP returned after pop $1000 $0FFE$1000 $0FFC$0000 $0FFA$1234 $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE A0 = Old SP  New SP  A0 = $0FFC SP = $0FF2 UNLK A0

How UNLK Works – After Execution $1000 $0FFE $0FFC $0FFA $0FF8 $0FF6 $0FF4 $0FF2 $0FF0 $0FEE SP  A0 =

Conclusion

Summary of Instructions InstructionDescription MOVEMove data between registers & memory MOVEAMove data to address register MOVEMMove data between multiple registers & memory MOVEQQuick move byte to register MOVEP Move peripheral data. Selects only even/odd byte, depending on starting address.

Summary of Instructions InstructionDescription LEALoad effective address to register. PEAPush effective address to software stack. EXGExchange contents between registers. SWAPSwap upper & lower register halves. InstructionDescription

Summary of Instructions LINKReserves part of stack for local workspace UNLNK Undoes LINK, restores register and stack to before LINK operation. InstructionDescription

The End Please read: Antonakos, pg