Presentation is loading. Please wait.

Presentation is loading. Please wait.

ELE22MIC Lecture 6 Continuation of Lecture 5 Instruction Set Overview, Part 4 –HC-COM - Lab notes –Stack Pointer, Push, Pull Call/return Data –Conditional.

Similar presentations


Presentation on theme: "ELE22MIC Lecture 6 Continuation of Lecture 5 Instruction Set Overview, Part 4 –HC-COM - Lab notes –Stack Pointer, Push, Pull Call/return Data –Conditional."— Presentation transcript:

1 ELE22MIC 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

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

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

4 Using Subroutines - JSR JSR 16 bit address ($0..$FFFF, 0..$FF) JSRJump to Subroutine –Push next instruction address onto stack –then jump to the specified address RTSReturn 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.

5 Using Subroutines - BSR BSR relative address (PC + [-$80.. +$7F]) BSRBranch 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).

6 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 FFF6..FFF7

7

8 Stack contents - during interrupt service routine

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

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

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

12 CLEAR/BIT CLEAR/BIT SET CLEAR (bit(s) = 0) & SET (bit(s) = 1) CLRM = 0 CLRAA = 0 CLRBB = 0 Direct bit manipulation: BCLRClear Bits (M) –M = M & (mask#) BSETSet Bits (M) –M = M | (mask#)


Download ppt "ELE22MIC Lecture 6 Continuation of Lecture 5 Instruction Set Overview, Part 4 –HC-COM - Lab notes –Stack Pointer, Push, Pull Call/return Data –Conditional."

Similar presentations


Ads by Google