ELE 22 MIC Lecture 6 Continuation of Lecture

  • Slides: 12
Download presentation
ELE 22 MIC Lecture 6 • Continuation of Lecture 5 • Instruction Set Overview,

ELE 22 MIC Lecture 6 • Continuation of Lecture 5 • Instruction Set Overview, Part 4 – HC-COM - Lab notes – Stack Pointer, Push, Pull • Call/return • Data – Conditional Jumps – Address Bus – Data Bus

Jump • JUMP address (0. . $FFFF, 0. . $FF) • JMP Jump to

Jump • JUMP address (0. . $FFFF, 0. . $FF) • JMP Jump to Address – Load the specified address, into the program counter. – Functions like GOTO in C/BASIC/PASCAL.

Branch • BRANCH (PC + [-$80. . $7 F]) – Jump relative to current

Branch • BRANCH (PC + [-$80. . $7 F]) – Jump relative to current program counter (PC) – Used if the destination is close to the current instruction • Branch • BRA • BRN • BSR Branch Always Branch Never Branch to subroutine

Using Subroutines - JSR • JSR 16 bit address ($0. . $FFFF, 0. .

Using Subroutines - JSR • JSR 16 bit address ($0. . $FFFF, 0. . $FF) • JSR Jump to Subroutine – Push next instruction address onto stack – then jump to the specified address • RTS Return from Subroutine – Pul the top item on the stack into the Instruction Pointer - effectively jumps to the address on the top of stack. This address is the value pushed by the JSR (or BSR) instruction.

Using Subroutines - BSR • BSR relative address (PC + [-$80. . +$7 F])

Using Subroutines - BSR • BSR relative address (PC + [-$80. . +$7 F]) • BSR Branch to Subroutine – Push next instruction address onto stack – then branch to the specified relative address • How it works: – The program counter is incremented by 2. (as usual) – The PC of the next instruction is pushed onto the stack (so the stack contains the return address) – Then the relative displacement is added to the Program counter, and execution continues from there (i. e. within the subroutine).

INTERRUPTs SWI • SWI ; Software Interrupt – Pushes all user registers (not stack

INTERRUPTs SWI • SWI ; Software Interrupt – Pushes all user registers (not stack pointer) – The interrupt mask bit is set • this prevent furthur interrupts being serviced immediately – Fetches the Vector Address from memory location – Jumps to the vector address from memory at FFF 6. . FFF 7

Stack contents - during interrupt service routine

Stack contents - during interrupt service routine

INTERRUPTs RTI/WAI • RTI • WAI ; Return from Interrupt ; Wait for interrupt

INTERRUPTs RTI/WAI • RTI • WAI ; Return from Interrupt ; Wait for interrupt

INTERRUPT MASKING: • CLI ; CLear Interrupt Mask • Enable Interrupts on IRQ# line

INTERRUPT MASKING: • CLI ; CLear Interrupt Mask • Enable Interrupts on IRQ# line • SEI ; Set interrupt Mask • Disable Servicing of Interrupts on IRQ# line • Interrupt mask does not affect SWI (Software Interrupt) nor XIRQ.

Next Lecture Address Bus Multiplexing / Demultiplexing MCU Reset Data Bus - Tri-state

Next Lecture Address Bus Multiplexing / Demultiplexing MCU Reset Data Bus - Tri-state

CLEAR/BIT SET • CLEAR (bit(s) = 0) & SET (bit(s) = 1) • •

CLEAR/BIT SET • CLEAR (bit(s) = 0) & SET (bit(s) = 1) • • • CLRA CLRB M=0 A=0 B=0 • Direct bit manipulation: • BCLR Clear Bits (M) – M = M & (mask#) • BSET – M = M | (mask#) Set Bits (M)