ELE 22 MIC Lecture 8 Instruction Set Overview


![Branch • BRANCH (PC + [-$80. . $7 F]) – Jump relative to current Branch • BRANCH (PC + [-$80. . $7 F]) – Jump relative to current](https://slidetodoc.com/presentation_image_h/25e52ae79deceffb4ca3a5366e11c535/image-3.jpg)

![Using Subroutines - BSR • BSR relative address (PC + [-$80. . +$7 F]) Using Subroutines - BSR • BSR relative address (PC + [-$80. . +$7 F])](https://slidetodoc.com/presentation_image_h/25e52ae79deceffb4ca3a5366e11c535/image-5.jpg)







- Slides: 12
ELE 22 MIC Lecture 8 • 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 Address – Loads the specified address, into the program counter. – Functions like GOTO in C/BASIC/PASCAL.
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 Branch Always – BRN Branch Never – BSR Branch to subroutine
Using Subroutines - JSR • JSR 16 bit address ($0. . $FFFF, 0. . $FF) • JSR Jump to Subroutine – Push next instruction address onto stack (16 bits) – then jump to the address specified in the operand • RTS Return from Subroutine – Pul the 16 bit item on the stack top 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]) • BSR Branch to Subroutine – Push next instruction address onto stack (16 bits) – 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 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
INTERUPT VECTORS IN ROM ORG $FFD 6 *** Vectors *** VSCI FDB JSCI VSPI FDB JSPI VPAIE FDB JPAIE VPAO FDB JPAO VTOF FDB JTOF VTOC 5 FDB JTOC 5 VTOC 4 FDB JTOC 4 VTOC 3 FDB JTOC 3 VTOC 2 FDB JTOC 2 VTOC 1 FDB JTOC 1 VTIC 3 FDB JTIC 3 VTIC 2 FDB JTIC 2 VTIC 1 FDB JTIC 1 VRTI FDB JRTI VIRQ FDB JIRQ VXIRQ FDB JXIRQ VSWI FDB JSWI VILLOP FDB JILLOP VCOP FDB JCOP VCLM FDB JCLM VRST FDB BUFFALO PSEUDO VECTORS IN RAM *** Vector jump table *** JSCI RMB 3 JSPI RMB 3 JPAIE RMB 3 JPAO RMB 3 JTOF RMB 3 JTOC 5 RMB 3 JTOC 4 RMB 3 JTOC 3 RMB 3 JTOC 2 RMB 3 JTOC 1 RMB 3 JTIC 3 RMB 3 JTIC 2 RMB 3 JTIC 1 RMB 3 JRTI RMB 3 JIRQ RMB 3 JXIRQ RMB 3 JSWI RMB 3 JILLOP RMB 3 JCLM RMB 3
Stack contents - during interrupt service routine
INTERRUPTs RTI/WAI • RTI • WAI ; Return from Interrupt ; Wait for interrupt
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.
References: BUF 34. ASM - Buffalo Source Code AS 11 Freeware Assembler help file Conditional jump examples MCU Reset sequence Data Bus - Tri-state