ECE291 Computer Engineering II Lecture 13 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.

Slides:



Advertisements
Similar presentations
DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
Advertisements

10-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Subroutine and Interrupt.
University of Tehran 1 Microprocessor System Design Interrupt Omid Fatemi
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
80x86 Instruction Set Dr. Qiang Lin.
Set 20 Interrupts. INTERRUPTS The Pentium has a mechanism whereby external devices can interrupt it. Devices such as the keyboard, the monitor, hard disks.
Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, All rights reserved. You may modify and.
11/13/01CS-550 Presentation - Overview of Microsoft disk operating system. 1 An Overview of Microsoft Disk Operating System.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
CS2422 Assembly Language & System Programming November 2, 2006.
8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Assembly Language for Intel-Based Computers Chapter 16: Expert MS-DOS Programming (c) Pearson Education, All rights reserved. You may modify.
Introduction to Computer Engineering by Richard E. Haskell Interrupts Module M17.3 Sections 11.3, 14.1.
8.4 Instruction Execution Times TOBIN PROC FAR SUB AX,AX MOV DX,AX MOV CX,4 NEXTD: PUSH CX SUB BP,BP MOV CX,4 GETNUM: RCL BX,1 RCL BP,1 LOOP GETNUM.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
BIOS1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
1 Screen and Keyboard Operations Suthida Chaichomchuen
Chapter 3 Examining Computer Memory and Executing Instructions.
ECE291 Lecture 9 Interrupts I. ECE 291 Lecture 9Slide 2 of 28 Lecture Outline Printed lab manual?Printed lab manual? Interrupt I/OInterrupt I/O Interrupt.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Lecture 8 Working with tables Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
8086 Microprocessor Interrupts By: Vijay Kumar. K Reference From Slide Share.
10H Interrupt. Option 0H – Sets video mode. Registers used: – AH = 0H – AL = Video Mode. 3H - CGA Color text of 80X25 7H - Monochrome text of 80X25 Ex:
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
EEL 3801 Part IV The Assembler. OFFSET Operator Returns address of variable used as operand. Actually, it represents the offset from the beginning of.
ECE291 Computer Engineering II Lecture 3 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
ECE291 Computer Engineering II Lecture 13 Josh Potts University of Illinois at Urbana- Champaign.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 13: 16-Bit MS-DOS Programming Interrupts (c) Pearson Education, All rights reserved.
BIOS and DOS Interrupts Basic Input /Outpu System Disk Operating System.
Calling Procedures C calling conventions. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
Internal Programming Architecture or Model
Lecture 11 Text mode video
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
File Operations. FILE PROCESSING For the purposes of the following discussion, reading means copying all or part of an existing file into memory Writing.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA 1 Assembly Language Programming.
ECE291 Computer Engineering II Lecture 14 Josh Potts University of Illinois at Urbana- Champaign.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Instruction set Architecture
Lecture 2 Programming of 8086 Лектор: Люличева И.А. 1.
Format of Assembly language
Microprocessor and Assembly Language
BYTE AND STRING MANIPULATON
Computer Organization & Assembly Language Chapter 3
Computer Organization And Assembly Language
Instruksi Set Prosesor 8088
ADDRESSING MODES.
ADDRESSING MODES.
Microprocessor and Assembly Language
(The Stack and Procedures)
Symbolic Instruction and Addressing
BIC 10503: COMPUTER ARCHITECTURE
Chapter 4 Data Movement Instructions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
(The Stack and Procedures)
Symbolic Instruction and Addressing
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Unit:08 Software Interrupts
Chapter 6 –Symbolic Instruction and Addressing
(The Stack and Procedures)
Presentation transcript:

ECE291 Computer Engineering II Lecture 13 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign

Z. KalbarczykECE291 Outline Material covered on Exam I Lookup tables Jump tables Interrupt vectors –Interrupt functions examples

Z. KalbarczykECE291 Lookup Tables Lookup tables are often used to convert from one data form to another A lookup table is formed in the memory as a list of data that is referenced by a procedure to perform conversions XLAT instruction can often be used to lookup data in a table –place the offset of the array in the BX and –the desired index value in AL –XLAT returns the byte element in AL –AL cannot contain an index value greater than 255 –you can use XLAT with arrays containing more than 256 elements, simply treat each 256-byte block of the array as a smaller sub-array, e.g., to retrieve the 260th element add 256 to BX and set AL =3 ( )

Z. KalbarczykECE291 Table-Lookup Functions Example 1 Consider movement in an array by one element Array = Matrix of ROWSIZE x COLSIZE elements Pos = Position in array = Row * COLSIZE + Column Dir = Direction (UP=0, RIGHT=1, DOWN=2,LEFT=3) Slow and Tedious Original Code: Compares each possible direction value MBegin: CMP DIR,UP JE MoveUP CMP DIR,RIGHT JE MoveRT CMP DIR,DN JE MoveDOWN CMP DIR,LEFT JE MoveDown MoveUP: SUB Pos,COLSIZE JMP MDone MoveRT: ADD Pos,1 JMP MDone MoveDN: ADD Pos,COLSIZE JMP MDone MoveLT: SUB Pos,1 JMP MDone MDone: Finished!

Z. KalbarczykECE291 Table-Lookup Functions Example 1 (cont.) Fast and Compact Table-lookup Code Eliminate conditional jumps by defining a table of movements indexed by the Direction. Movement dw -COLSIZE ; Movement[0] == Go UP dw +1 ; Movement[1] == Go RIGHT dw +COLSIZE ; Movement[2] == Go DOWN dw -1 ; Movement[3] == Go LEFT MBegin: MOV BX, DIR ; Direction = {0..3} SHL BX, 1 ; Index words, not bytes MOV AX, Movement[BX] ADD Pos, AX ; Position += Movement MDone: Finished!

Z. KalbarczykECE291 Table Lookup Example 2 DAYS PROC FAR PUSH DX PUSH SI MOV SI, OFFSET DTAB XOR AH, AH ;clear AH ADD AX, AX ;double AX ADD SI, AX ;modify table address MOV DX, CS:[SI] ;get string address MOV AX, CS ;change data segment PUSH DS MOV DS, AX MOV AH, 09h INT21h POP DS POPSI POPDX RET DTABDWSUN, MON, TUE, WED, THU, FRI, SAT SUNDB‘Sunday $’ MONDB‘Monday $’ TUEDB‘Tuesday $’ WEDDB‘Wednesday $’ THUDB‘Thursday $’ FRIDB‘Friday $’ SATDB‘Saturday $’ DAYESENDP Converts numbers 0 to 6 to days of the week The number is passed in AL register Converts numbers 0 to 6 to days of the week The number is passed in AL register

Z. KalbarczykECE291 Jump Tables Suppose table entries are pointers to functions Suppose BX holds a command in the range of 0..N-1; let cmd index a function JFUNCTION PROC NEAR/FAR; Input BX = Command SHL BX,1 ; Words, not bytes JMP Jtable[BX] ; Jump to function Jtable dw offset Funct0 dw offset Funct1.. dw offset FunctN-1 Funct0: do something.. RET Funct1: do something else.. RET FunctN-1: do something else.. RET JFUNCTION ENDP

Z. KalbarczykECE291 Interrupt Vectors Jump Tables are the basis for interrupt vectors On 80x86, low 1024 bytes of memory hold vector table There are 256 pointers in the table Each entry is a far (4 byte segment:offset) pointer Memory address (hex) Interrupt function pointer 003FC INT * x INT x INT INT INT 0

Z. KalbarczykECE291 Interrupt Vectors The term interrupt is used in three different contexts: Software interrupts (e.g., 21h) –provide a mechanism whereby the programmer can use the int instruction to access blocks of code that already exist and are resident in machine memory Hardware interrupts –triggered by hardware events external to the microprocessor, rather than resulting from an int or any other instruction –e.g., request for service by external devices such as disk drives Exceptions –hardware origin within the microprocessor itself –e.g., anomalous event within a program, such as an attempt to divide by zero

Z. KalbarczykECE291 Interrupt Functions Examples DOS Functions To execute of the many DOS functions, you can specify a sub- function by loading a value into AH just before calling INT 21 INT 21h, Subfunction: AH=3Dh: Open File AH=3Fh: Read File AH=3Eh: Close File AH=13h: Delete File (!) AH=2Ah: Get system date AH=2Ch: Get system time AH=2Ch: Read DOS Version AH=47h: Get Current Directory AH=48h: Allocate Memory block (specified in paragraphs==16 bytes) AH=49h: Free Memory block AH=4Ch: Terminate program (and free resources)

Z. KalbarczykECE291 Interrupt Functions Examples BIOS Functions SYSTEM BIOS Functions All PCs come with a BIOS ROM (or EPROM). The BIOS contains standard 80x86 opcodes to provide basic functions such as bootstraping and primitive I/O. INT 19h: Reboot system INT 11h: Get equipment configuration INT 16h: Keyboard I/O VIDEO BIOS Functions Video cards come with 80x86 commands burned in a ROM. Video BIOS is located at C0000-C7FFF and holds routines for handling basic functions. To execute a function in video BIOS ROM, call INT 10 with AX=sub- function. INT 10h, Subfunction: –AH=0,AL=2h: 80x25 Text –AH=0,AL=13h: 320x200, 256-color graphic

Z. KalbarczykECE291 Interrupt Functions Examples MOUSE & Hardware Functions MOUSE Functions : INT 33h Routines to read position and status of mouse AX=0000h: Reset AX=0001h: Show Mouse AX=0003h: Get Position & Status BX = Buttons Pressed: bit[0]=left, bit[1]=right CX = Column Position DX = Row Position HARDWARE Functions IRQ 0-7 FUNCTIONS : INT 8-Fh System timer (IRQ 0 == INT 8h) Keyboard (IRQ 1 == INT 9h) Bus/DMA (IRQ 2 == INT Ah) Serial Port (IRQ 3 == INT Bh) SoundBlaster (IRQ 5 == INT Dh) INT = 8 + IRQ IRQ 8-15 FUNCTIONS : INT 70h-77h SCSI Request (IRQ 10d == INT 72h) INT = 68h + IRQ