ELE22MIC Lectures 6 and 7 Assembly Language Instruction Set Overview, Part 3 –Addressing Modes –Add, Push, Pull, Jump –Conditional Jumps.

Slides:



Advertisements
Similar presentations
CH10 Instruction Sets: Characteristics and Functions
Advertisements

Microprocessors.
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
INSTRUCTION SET ARCHITECTURES
Revised: Aug 1, EE4390 Microprocessors Lesson 6,7 Instruction Set, Branch Instructions, Assembler Directives.
TK 2633 Microprocessor & Interfacing
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
What is an instruction set?
8051 ASSEMBLY LANGUAGE PROGRAMMING
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
© 2010 Kettering University, All rights reserved..
Lecture 18 Last Lecture Today’s Topic Instruction formats
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
Module 10 Adapted By and Prepared James Tan © 2001.
Machine Instruction Characteristics
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Physics 413 Chapter 4 A Fork in the Road LDAB # $ 13 here :ADDA # $ 24 DEC B BNE here WAI BNE is the new instruction. Branch if not equal to zero.
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
Computer Architecture and Organization
ME4447/6405 The George W. Woodruff School of Mechanical Engineering ME4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics.
Computer Architecture EKT 422
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Z80 Overview internal architecture and major elements of the Z80 CPU.
ECE 265 – LECTURE 5 The M68HC11 Basic Instruction Set 12/8/ ECE265.
ELE22MIC Lecture 24 Course Review 1 –Review Addressing Modes operation –Instruction Set Categories & instructions Review of Assignment 1 & 2 Assignment.
Ch.2 Intro. To Assembly Language Programming
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
1 Microcontroller Fundamentals & Programming Addressing Modes.
Advanced Assembly Language Programming
What is a program? A sequence of steps
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Microprocessor & Assembly Language
1 Stack Advanced Programming. 2 The Stack It is a special area of memory used as temporary storage A stack is a LIFO data structure Putting data into.
EE345 Chapter 2 Lecture 3 April Instruction and addressing modes 1.Extended Addressing 2.Direct Addressing 3.Inherent Addressing 4.Immediate Addressing.
ELE22MIC Lecture 6 Continuation of Lecture 5 Instruction Set Overview, Part 4 –HC-COM - Lab notes –Stack Pointer, Push, Pull Call/return Data –Conditional.
ELE22MIC Lecture 7 Instruction Set Overview, Part 4 –HC-COM - Lab notes –Stack Pointer, Push, Pull Call / Return Data –Conditional Jumps –Address Bus –Data.
Addressing Modes in Microprocessors
HC11 Programming.
Classification of Instruction Set of 8051
Assembly Language Programming of 8085
ECE 3430 – Intro to Microcomputer Systems
Microprocessor T. Y. B. Sc..
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
8086 Microprocessor.
ECE 3430 – Intro to Microcomputer Systems
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME4447/6405 Microprocessor Control of Manufacturing Systems and
ECE 3430 – Intro to Microcomputer Systems
Chapter 8 Central Processing Unit
ECEG-3202 Computer Architecture and Organization
Chapter 9 Instruction Sets: Characteristics and Functions
ECEG-3202 Computer Architecture and Organization
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

ELE22MIC Lectures 6 and 7 Assembly Language Instruction Set Overview, Part 3 –Addressing Modes –Add, Push, Pull, Jump –Conditional Jumps

LDS#STACK;initialize start of stack 68HC11 Register Set

M68HC Addressing Modes Immediate Direct Extended Indexed Inherent Relative

Immediate Addressing Mode The data for the operation immediately follows the instruction The # symbol must be used to select immediate addressing Examples: LDAA #$42 ; Load Acc.A with the value $42 -> Machine Codes: LDX #DEEE ; Load Index Register X with hex value DEEE -> Machine Codes CE DE EE

Direct Addressing Modes Direct Addressing can access an operand located in the first 256 bytes of memory, $0000..$00FF An 8-bit memory address specifies where: data is read from, or data is written to. Examples: –LDAA $42; AccA = Memory[$42] -> Machine Code –STAA$FF; Memory[FF] = AccA –LDX $12; IX = Memory[$12]..[$13]

Extended Addressing Modes Extended Addressing uses 16-bit address to specify A 16-bit memory address specifies where: data is read from, or data is written to. Examples: –LDAA $4231; AccA = Memory[$4321] -> Machine Code B –STAA$2000; Memory[$2000] = AccA –LDX $1234; IX = Memory[$1234]..[$1235]

Indexed Addressing Modes (1) Indexed addressing always uses one of two index registers X or Y. Instruction Format: –Operation Offset, Index_Register –Offset is an unsigned 8-bit value (0..255) added to the contents of the index register –The value of the index register is not altered. –Addition is modulo 65536

Indexed Addressing Modes (2) –EXAMPLE: LDAA 42, X ; AccA = Memory[42+X] -> Machine Code A6 42

Inherent Addressing Modes All data for the instruction is within the CPU. ABA; A = A + B -> Machine code $1B MUL; D = A * B -> Machine code $3D NEGA ; A = -A -> Machine code $40 ABX; X = X + A -> Machine code $3A INX; X = X + 1 -> Machine code $08 SEC; CarryFlag= 1 -> Machine code$0D TAB; B = A -> Machine code $16

Addressing Modes Review Immediate, Direct, Extended, Indexed, Inherent, Relative LDAA > B LDAA 42 -> LDAA #42 -> LDAA 42, X -> A6 42 BRA > 20 1E (at $2000) ABA-> 1B No memory to memory moves w/o register

Major Instruction Set Categories ARITHMETIC BRANCH, JUMP & SUBROUTINE CALL/RETURN COMPARE DATA MOVEMENT LOGICAL

ARITHMETIC Instructions ADDITION, SUBTRACTION, TWOS COMPLEMENT (NEGATION), DECREMENT & INCREMENT MULTIPLY & DIVIDE ARITHMETIC/LOGICAL SHIFT/ROTATE BINARY CODED DECIMAL CLEAR (bit(s) = 0) & SET (bit(s) = 1) COMPARE & TEST CONDITION CODE MANIPULATION CONDITIONAL Branches SIGNED / UN-SIGNED NUMERIC INTERPRETATION DATA MOVEMENT Push/Pull Load/Store Register Transfer Registers Exchange Registers INTERRUPT HANDLING: LOGICAL LOGICAL AND LOGICAL EXCLUSIVE OR LOGICAL OR ONES-COMPLEMENT (NOT) MISCELLANEOUS

ADDITION ABAA = A + B ABXIX = IX + B ABYIY = IY + B ADCAA = A + M + CarryFlag ADCBB = B + M + CarryFlag ADDAA = A + M ADDBB = B + M ADDDD = D + M

SUBTRACTION SBAA = A - B SBCAA = A - M - CarryFla SBCBB = B - M - CarryFlag SUBAA = A - M SUBBB = B - M SUBDD = D - M

NEGATION NEGM = -M NEGAA = -A BEGBB = -B TWOS COMPLEMENT

DECREMENT DECM = M - 1 DECAA = A - 1 DECBB = B - 1 DESSP = SP - 1 DEXIX = IX - 1

INCREMENT INCM = M + 1 INCAA = A + 1 INCBB = B + 1 INSSP = SP + 1 INXIX = IX + 1 INYIY = IY + 1

MULTIPLY / DIVIDE MULTIPLY –MULD = A * B DIVIDE –IDIVIX = D / IX, D = D % IX (Unsigned Integer Divide) –FDIVIX = D / IX, D = D % IX (Unsigned fractional divide - Radix point assumed left of bit 15 of both operands)

Arithmetic/Logical Shift & Rotate

ARITHMETIC SHIFT LEFT: (Multiply by 2) ASLArithmetic Shift Left (M) ASLAArithmetic Shift Left (A) ASLBArithmetic Shift Left (B) ASLDArithmetic Shift Left (D) RIGHT: (Divide By 2, Sign-Extend MSBit) ASRArithmetic Shift Right (M) ASRAArithmetic Shift Right (A) ASRBArithmetic Shift Right (B)

LOGICAL SHIFT LEFT: (Same as ASL) LSLLogical Shift Left (M) LSLALogical Shift Left (A) LSLBLogical Shift Left (B) LSLDLogical Shift Left (D) RIGHT: (Zero Fill MSBit) LSRLogical Shift Right (M) LSRALogical Shift Right (A) LSRBLogical Shift Right (B) LSRDLogical Shift Right (D) ROTATE LEFT: (extended multiply) ROLROtate Left (M) ROLAROtate Left (A) ROLBROtate Left (B) RIGHT: (extended divide) RORROtate Right (M) RORAROtate Right (A) RORBROtate Right (B) BINARY CODED DECIMAL (BCD) DAADecimal Adjust after Addition Branch & Jump BRABranch Always BRNBranch Never JMPJump to Address JSRJump to Subroutine NOPNo OPeration ; i.e do nothing but fetch next instruction CLEAR (bit(s) = 0) & SET (bit(s) = 1) CLRM = 0 CLRAA = 0 CLRBB = 0 BCLRClear Bits (M) BSETSet Bits (M) COMPARE & TEST CONDITION CODE MANIPULATION CLCCarryFlag = 0Clear Carry Flag CLVOVerflowFlag = 0Clear Overflow Flag SECCarryFlag = 1Set Carry Flag SEVOVerflowFlag = 1Set Overflow Flag TAPCCR = A Transfer A to Condition Codes Register (CCR) TPAA = CCR Transfer CCR to A CONDITIONAL Branches BEQBranch if EQual BNEBranch if Not Equal BCCBranch if CarryFlag is Clear BCSBranch if CarryFlag is Set BRCLRBranch if bits clear BRSETBranch if bits set Branches for SIGNED NUMERIC INTERPRETATION BMI; Branch if MInus BPL; Branch if PLus BVS;Branch if oVerflow Set BVC;Branch if oVerflow Clear BLT;Branch if Less Than BGE;Branch if Greater-Than or Equal-to BLE;Branch if Less-Than or Equal-to Branches for UN-SIGNED NUMERIC INTERPRETATION BHI; Branch if HIgher than BHS;Branch if Higher or Same BLS;Branch if Lower or Same BLO;Branch if Lower DATA MOVEMENT Push - Push register value onto stack PSHAM[SP--] = A The contents of the A register is pushed onto the stack - i.e. stored into memory at the address contained in the stack pointer; then the stack pointer is decremented. –PSHBM[SP--] = B PSHXM[SP--] = IX.LOW ; M[SP--] = IX.HIGH PSHYM[SP--] = IY.LOW ; M[SP--] = IY.HIGH Pull - Pull (POP) value from stack to Register PULA; A = M[++Sp] The stack pointer is first incremented, and then Accumulator A is popped off the stack - i.e. loaded from memory where the stack pointer is pointing. PULB; B = M[++SP] PULX; X.HIGH = M[++SP] ; X.LOW = M[++SP] PULY; Y.HIGH = M[++SP] ; Y.LOW = M[++SP] Load Register LDAAA = M LDABB = M LDDD = M LDSSP = M LDXX = M LDYY = M Store Register Transfer Registers TAB; A = B TBA; B = A TSX; IX = SP + 1 TSY; IY = SP + 1 TXS; SP = IX - 1 TXY; SP = IY - 1 Exchange Registers XGDX;D IX XGDY;D IY INTERRUPT HANDLING: CLI; Clear interrupt Mask SEI; Set interrupt Mask SWI; Software Interrupt RTI; Return from Interrupt WAI; Wait for interrupt LOGICAL LOGICAL AND –ANDA; A = A & M –ANDB;B = B & M LOGICAL EXCLUSIVE OR –EORA;A = A ^ M –EORB;B = B ^ M LOGICAL OR –ORAA; A = A | M –ORAB; B = B | M ONES COMPLEMENT (NOT) –COM; M = M# –COMA; A = A# –COMB; B = B# MISCELLANEOUS STOP; Stop clocks TEST; Special test mode (different meaning to 80x86)

ROTATE LEFT: (extended multiply) ROLROtate Left (M) ROLAROtate Left (A) ROLBROtate Left (B) RIGHT: (extended divide) RORROtate Right (M) RORAROtate Right (A) RORBROtate Right (B)

CLEAR/BIT CLEAR/BIT SET CLEAR (bit(s) = 0) & SET (bit(s) = 1) CLRM = 0 CLRAA = 0 CLRBB = 0 BCLRClear Bits (M) BSETSet Bits (M)

Jumps JUMP address (0..FFFF) JMPJump to Address JSRJump to Subroutine RTSReTurn from Subroutine NOPNo OPeration ; i.e do nothing but fetch next instruction

Branch & Jump BRANCH ( ) & JUMP (0..FFFF) Branch BRABranch Always BRNBranch Never BSR Branch to SubRoutine

COMPARE & TEST CONDITION CODE MANIPULATION CLCCarryFlag = 0CLear Carry Flag CLVOVerflowFlag = 0 SECCarryFlag = 1SEt Carry Flag SEVOVerflowFlag = 1 TAPCCR = ATransfer A to CCR TPAA = CCRTransfer CCR to A CCR = Condition Codes Register

CONDITIONAL BRANCHES (1) CONDITIONAL Branches BEQBranch if EQual BNEBranch if Not Equal BCCBranch if Carry Flag is Clear BCSBranch if Carry Flag is Set BRCLRBRanch if bits CLeaR BRSETBRanch if bits SET

CONDITIONAL BRANCHES (2) SIGNED COMPARISON BMIBranch if Minus BPLBranch if PLus BVSBranch if oVerflow Set BVCBranch if oVerflow Clear BGTBranch if Greater-Than > BGEBranch if Greater-than or Equal-to >= BLEBranch if Less-than or Equal-to <= BLTBranch if Less Than <

CONDITIONAL BRANCHES (3) UN-SIGNED COMPARISON BHIBranch if HIgher than > BHSBranch if Higher or Same>= BLSBranch if Lower or Same<= BLOBranch if Lower<

PUSH Push - Push register value onto stack PSHAM[SP--] = A The contents of the A register is pushed onto the stack - i.e. stored into memory at the address contained in the stack pointer; then the stack pointer is decremented. PSHB M[SP--] = B PSHX M[SP--] = IX.LOW ; M[SP--] = IX.HIG PSHY M[SP--] = IY.LOW ; M[SP--] = IY.HIGH Pull - Pull (POP) value from stack to Register PULA; A = M[++Sp] The stack pointer is first incremented, and then Accumulator A is popped off the stack - i.e. loaded from memory where the stack pointer is pointing. PULB; B = M[++SP] PULX; X.HIGH = M[++SP] ; X.LOW = M[++SP] PULY; Y.HIGH = M[++SP] ; Y.LOW = M[++SP] Load Register LDAAA = M LDABB = M LDDD = M LDSSP = M LDXX = M LDYY = M Store Register Transfer Registers TAB; A = B TBA; B = A TSX; IX = SP + 1 TSY; IY = SP + 1 TXS; SP = IX - 1 TXY; SP = IY - 1 Exchange Registers XGDX;D IX XGDY;D IY INTERRUPT HANDLING: CLI; Clear interrupt Mask SEI; Set interrupt Mask SWI; Software Interrupt RTI; Return from Interrupt WAI; Wait for interrupt LOGICAL LOGICAL AND –ANDA; A = A & M –ANDB;B = B & M LOGICAL EXCLUSIVE OR –EORA;A = A ^ M –EORB;B = B ^ M LOGICAL OR –ORAA; A = A | M –ORAB; B = B | M ONES COMPLEMENT (NOT) –COM; M = M# –COMA; A = A# –COMB; B = B# MISCELLANEOUS STOP; Stop clocks TEST; Special test mode (different meaning to 80x86)

PULL Pull - Pull (POP) value from stack to Register PULA; A = M[++Sp] The stack pointer is first incremented, and then Accumulator A is popped off the stack - i.e. loaded from memory where the stack pointer is pointing. PULB ; B = M[++SP] PULX ; X.HIGH = M[++SP] ; X.LOW = M[++SP] PULY ; Y.HIGH = M[++SP] ; Y.LOW = M[++SP] Load Register LDAAA = M LDABB = M LDDD = M LDSSP = M LDXX = M LDYY = M Store Register Transfer Registers TAB; A = B TBA; B = A TSX; IX = SP + 1 TSY; IY = SP + 1 TXS; SP = IX - 1 TXY; SP = IY - 1 Exchange Registers XGDX;D IX XGDY;D IY INTERRUPT HANDLING: CLI; Clear interrupt Mask SEI; Set interrupt Mask SWI; Software Interrupt RTI; Return from Interrupt WAI; Wait for interrupt LOGICAL LOGICAL AND –ANDA; A = A & M –ANDB;B = B & M LOGICAL EXCLUSIVE OR –EORA;A = A ^ M –EORB;B = B ^ M LOGICAL OR –ORAA; A = A | M –ORAB; B = B | M ONES COMPLEMENT (NOT) –COM; M = M# –COMA; A = A# –COMB; B = B# MISCELLANEOUS STOP; Stop clocks TEST; Special test mode (different meaning to 80x86)

Load Register LDAAA = M LDABB = M LDDD = M LDSSP = M LDXX = M LDYY = M

Store Register STAAM = A STABM = B STSM = SP STDM = D STXM = IX STYM = IY

Transfer Registers TAB; A = B TBA; B = A TSX; IX = SP + 1 TSY; IY = SP + 1 TXS; SP = IX - 1 TXY; SP = IY - 1

Exchange Registers XGDX;D IX XGDY;D IY

INTERRUPT HANDLING: CLI; Clear interrupt Mask SEI; Set interrupt Mask SWI; Software Interrupt RTI; Return from Interrupt WAI; Wait for interrupt

LOGICAL (1) LOGICAL AND –ANDA; A = A & M –ANDB; B = B & M LOGICAL EXCLUSIVE OR –EORA; A = A ^ M –EORB; B = B ^ M

LOGICAL (2) LOGICAL OR –ORAA; A = A | M –ORAB; B = B | M ONES COMPLEMENT (NOT) –COM; M = M# –COMA; A = A# –COMB; B = B#

MISCELLANEOUS STOP; Stop clocks TEST; Special test mode (different meaning to 80x86 instruction) BINARY CODED DECIMAL (BCD) DAADecimal Adjust after Addition

AS11 Constant Definition ' ASCII character $ hexadecimal octal constant % binary constant digit decimal constant

AS11 Assembler Directives EQU - EQUATE –Used to define constants for example: –OUTSTR EQU $E3D9 ORG xxxx - ORIGINATE –Locate the program at the specified address, xxxx

AS11 Assembler Expressions Expressions may consist of symbols, constants or the character“*” (denoting the current value of the program counter) joined together by one of the operators: + - * / % & | ^.

AS11 Assembler Expressions The operators are same as C: +add -subtract *multiply /divide %modulo &bitwise AND |bitwise OR ^bitwise EXCLUSIVE-OR

Examples Shift Left & Right Binary Multiplication Binary Division Extending for larger numbers

AS11 Assembler Invocation To invoke the cross-assembler AS11 in a dos box enter: AS11 file1 (file2...) -option1 -option2 Options: l enable output listing. nol disable output listing (default). cre generate cross reference table. s generate a symbol table. c enable cycle count info. noc disable cycle count info.

Next Lecture Address Bus Multiplexing / Demultiplexing MCU Reset Data Bus - Tri-state Interrupts - Open Drain (Open Collector)