120 likes | 265 Views
ELE22MIC 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 J u mp to Address Loads the specified address, into the program counter.
E N D
ELE22MIC 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..$7F]) • 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 .. +$7F]) • 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 FFF6..FFF7
INTERUPT VECTORS IN ROM ORG $FFD6 *** Vectors *** VSCI FDB JSCI VSPI FDB JSPI VPAIE FDB JPAIE VPAO FDB JPAO VTOF FDB JTOF VTOC5 FDB JTOC5 VTOC4 FDB JTOC4 VTOC3 FDB JTOC3 VTOC2 FDB JTOC2 VTOC1 FDB JTOC1 VTIC3 FDB JTIC3 VTIC2 FDB JTIC2 VTIC1 FDB JTIC1 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 JTOC5 RMB 3 JTOC4 RMB 3 JTOC3 RMB 3 JTOC2 RMB 3 JTOC1 RMB 3 JTIC3 RMB 3 JTIC2 RMB 3 JTIC1 RMB 3 JRTI RMB 3 JIRQ RMB 3 JXIRQ RMB 3 JSWI RMB 3 JILLOP RMB 3 JCOP RMB 3 JCLM RMB 3
INTERRUPTs RTI/WAI • RTI ; Return from Interrupt • WAI ; 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: BUF34.ASM - Buffalo Source Code AS11 Freeware Assembler help file Conditional jump examples MCU Reset sequence Data Bus - Tri-state