ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
I/O Unit.
ELEC 330 Digital Systems Engineering Dr. Ron Hayne
68HC11 Polling and Interrupts
EET 2261 Unit 9 Interrupts  Read Almy, Chapters 17 – 19.  Homework #9 and Lab #9 due next week.  Quiz next week.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Chapter 7 Interupts DMA Channels Context Switching.
RapUp Dynamic Allocation of Memory in C Last HW Exercise Review for Final Final Exam Next Thursday – Same Time / Same Place.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
CSS 372 Oct 2 nd - Lecture 2 Review of CSS 371: Simple Computer Architecture Chapter 3 – Connecting Computer Components with Buses Typical Bus Structure.
Introduction to Interrupts
TCSS 372A Computer Architecture. Getting Started Get acquainted (take pictures) Review Web Page (
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Midterm Wednesday 11/19 Overview: 25% First Midterm material - Number/character representation and conversion, number arithmetic - DeMorgan’s Law, Combinational.
INTERRUPTS PROGRAMMING
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
DAT2343 Accessing Services Through Interrupts © Alan T. Pinck / Algonquin College; 2003.
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
Stacks and Subroutines. Some example stacks Stacks and subroutine usage The stack is a special area of the random access memory in the overall memory.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Interrupts and reset operations. Overview  Introduction to interrupts – What are they – How are they used  68HC11 interrupt mechanisms – Types of interrupts.
Microprocessors 1 MCS-51 Interrupts.
9-1 EE 319K Introduction to Microcontrollers Lecture 9:I/O Synchronization; LCD Interfacing; Implementing Local Variables using a Stack Frame; Parameter.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
INT- interrupt program execution 1. It decrements the sp by 2 and pushes the flag registers on the stack. 2. Decrement the sp by 2 and push the content.
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.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
6-1 Infineon 167 Interrupts The C167CS provides 56 separate interrupt sources that may be assigned to 16 priority levels. The C167CS uses a vectored interrupt.
Dec Hex Bin 14 E ORG ; FOURTEEN Interrupts In x86 PC.
1 Stacks, Subroutines, I/O Routines Today: First Hour: Stacks, Subroutines –Section 3.9,3.10 of Huang’s Textbook –In-class Activity #1 Second Hour: I/O.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Subroutines and Stacks. Stack The stack is a special area in memory used by the CPU to store register information or general data information during program.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
George W. Woodruff School of Mechanical Engineering, Georgia Tech ME4447/6405 ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction.
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.
Revised: Aug 1, EE4390 Microprocessors Lessons 11, 12 Advanced Assembly Programming.
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
ELE22MIC Lecture 6 Continuation of Lecture 5 Instruction Set Overview, Part 4 –HC-COM - Lab notes –Stack Pointer, Push, Pull Call/return Data –Conditional.
Stacks and Subroutines May 23. Stacks and subroutine usage The stack is a special area of the random access memory in the overall memory system The stack.
Signal Name Direction w.r.t. Printer Function Summary Pin# (25-DB) CPU
ECE 3430 – Intro to Microcomputer Systems
Interrupts and interrupt responses
68HC11 Interrupts & Resets.
Microprocessor Systems Design I
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
Protection of System Resources
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
8259 Programmable Interrupt Controller
Accessing Services Through Interrupts
Interrupts.
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Lecture 7 System architecture Input-output
COMP3221: Microprocessors and Embedded Systems
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Presentation transcript:

ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR

AS11 Example (1) -16 bit counters * 16 Bit counter problems loop_counter rmb 2; declare 2 bytes for 16 bit counter ; then execute code as follows: dec_count: decloop_counter ; only one byte is decremented !!! rts ; How can we fix this problem? ; One way is to use a 16 bit register as follows: dec_count: ldd#FFFF; we can loop times stdloop_counter lots_of_loops: jsrdo_something; do something pshy; save the y index register value ldyloop_counter ; load value of loop_counter -> Y dey; decrement y = decrement loop_counter styloop_counter; store value of y-> loop_counter puly; recover saved y index register value bneloop_again; if (loop_counter <> 0), loop again rts

68HC11 Parallel I/O & Control (1)

AS11 Example (2) - Bit IO (1) * The 68HC11 has single Bit Set & Bit Clear instructions set or clear * individual bits at the selected memory location. * The instruction format is BSET/BCLR MemoryAddress Mask * A ‘1’ in the Mask indicates this bit should be Set/Cleared * A ‘0’ in the Mask indicates that the bit will not be changed. * I.e. BSET bitwise-ORs the Mask onto memory * BCLR bitwise-ANDs the inverse of the Mask onto memory * We can declare equates as follows to access them: Bit0EQU% ; = 1 Bit1EQU% ; = 2 Bit2EQU% ; = 4 Bit3EQU% ; = 8 Bit4EQU% ; = $10 Bit5EQU% ; = $20 Bit6EQU% ; = $40 Bit7EQU% ; = $80 AllBitsEQU% ; = $FF LowNyyble EQU% ; = $0F HighNyyble EQU% ; = $F0 LoopMaxEQU100 IOREGEQU$1000; start address of Configuration Registers PORTBEQU4

AS11 Example (2) - Bit IO (2) FlashLeds:; Connect LEDs to PortB LDAALoopMax; A = 100 = Our loop counter LDX#IOREG; X = $1000 BCLRPORTB, X AllBits; PortB = % LOOPAGAIN: BSET PORTB, X BIT0; PortB = % BSETPORTB, X BIT1; PortB = % BSET PORTB, X BIT2; PortB = % BSET PORTB, X BIT3; PortB = % BSET PORTB, X BIT4; PortB = % BSET PORTB, X BIT5; PortB = % BSET PORTB, X BIT6; PortB = % BSET PORTB, X BIT7; PortB = % jsrwait_a_bit BCLRPORTB, X LowNybble; PortB = % BCLRPORTB, X HighNybble; PortB = % jsrwait_a_bit BSETPORTB, X HighNybble; PortB = % BCLRPORTB, X HighNybble; PortB = % DECA BNELOOPAGAIN; loop 100 times RTS

Wired OR - IRQ A Wired-NOR gate is formed by connecting open-collector device interrupt lines together. Normal gates would fight causing high current drain and possibly damage the gate.

IRQ Processing (1) Any device requiring attention activates an interrupt service routine simply by asserting its interrupt output. The interrupt causes the CPU to : 1. Complete the current instruction - delay interrupt servicing until the current instruction completes (delay of from 1 (ABA) - 41 (IDIV) clock cycles) 2. Push all registers - PC, X, Y, AccA, AccB & CCR 3. Mask interrupts by setting the I bit in CCR 3. Fetch the interrupt vector 4. Jump to the address fetched from the int. vector

IRQ Processing (2) The Interrupt Service Routine (ISR) must then poll all devices connected to the IRQ pin and ask each device in turn: “Did you interrupt me?” Upon finding a device requiring service, perform the appropriate Input/Output/Processing and reset the device’s interrupt request (so that upon return the cpu is not immediately interrupted again). Upon successful servicing, the ISR must exit without altering the previously running program’s state. The ISR does this simply by executing the RTI instruction (ReTurn from Interrupt).

IRQ Processing (3) The RTI instruction :Pulls all the previously saved registers from the stack, in the reverse order that they were pushed, so that all registers contain the previous values. Pul : CCR, AccB, AccA, Y, X, PC The last pul - Pul PC - Pulls (pops) the program counter which effectively transfers program execution to the instruction immediately following the instruction completed before the interrupt request was accepted. Pulling the CCR re-enables the CPUs ability to be interrupted as the I flag which was cleared will be cleared again.

IRQ Processing (4) If the interrupt mask bit, I, in the CCR is unmasked during the ISR, then the IRQ line could cause one or more nested interrupts. This ISR nesting procedure would normally only be performed to provide more rapid response to a higher priority device.

Stack Frame (1) In the C language, the function parameters are normally pushed in the reverse order that they are listed. This is to facilitate C’s format statements for example: Printf (“P1=%3d, P2=%4d\n”, P1, P2); would compile to: Push P2 Push P1 PushFormatStatement JSR Printf ; Printf knows where the ; format statement will be AddSP, #6; drop the parameters

Stack Frame (2) The subroutine Printf expects to find the format statement as the first parameter on the stack. It then parses the statement, and determines how many more, and what type of, parameters are required. The return address is also placed on the stack. Also Local variables are pushed onto the stack. During the function these variables can be accessed on the stack frame as follows:

Frame/Base Pointer (2) For the duration of the function execution a frame pointer can be set up using the X or Y registers, and the variables may be accessed using indexed addressing P2EQUA P1EQU8 FormatSttEQU6 LocalVar1EQU2 LocalVar2 EQU0 TSX; X = SP+1 (Setup Frame Ptr) LDDP1, X; D = P1(Fetch P1) STDLocalVar1, X; LocalVar = AccD = P1

Buffalo Routines Jump Table (1) ORG ROMBS+$1F7C.WARMST JMP MAIN warm start.BPCLR JMP BPCLR clear breakpoint table.RPRINT JMP RPRINT display user registers.HEXBIN JMP HEXBIN convert ascii hex char to binary.BUFFAR JMP BUFFARG build hex argument from buffer.TERMAR JMP TERMARG read hex argument from terminal.CHGBYT JMP CHGBYT modify memory at address in x.READBU JMP READBUFF read character from buffer.INCBUF JMP INCBUFF increment buffer pointer.DECBUF JMP DECBUFF decrement buffer pointer.WSKIP JMP WSKIP find non-whitespace char in buffer.CHKABR JMP CHKABRT check for abort from terminal

Buffalo Routines Jump Table (2) ORG ROMBS+$1FA0.UPCASE JMP UPCASE convert to upper case.WCHEK JMP WCHEK check for white space.DCHEK JMP DCHEK check for delimeter.INIT JMP INIT initialize i/o device.INPUT JMP INPUT low level input routine.OUTPUT JMP OUTPUT low level output routine.OUTLHL JMP OUTLHLF display top 4 bits as hex digit.OUTRHL JMP OUTRHLF display bottom 4 bits as hex digit.OUTA JMP OUTA output ascii character in A.OUT1BY JMP OUT1BYT display the hex value of byte at X.OUT1BS JMP OUT1BSP out1byt followed by space.OUT2BS JMP OUT2BSP display 2 hex bytes at x and a space.OUTCRL JMP OUTCRLF carriage return, line feed to terminal.OUTSTR JMP OUTSTRG display string at X (term with $04).OUTST0 JMP OUTSTRG0 outstrg with no initial carr ret.INCHAR JMP INCHAR wait for and input a char from term.VECINT JMP VECINIT initialize RAM vector table