ECE291 Computer Engineering II Lecture 13 Josh Potts 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

There are two types of addressing schemes:
University of Tehran 1 Microprocessor System Design Interrupt Omid Fatemi
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
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.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
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.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
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.
80x86 Processor Architecture
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.
An Introduction to 8086 Microprocessor.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
ECE291 Computer Engineering II Lecture 13 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
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.
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.
Chapter 3 Examining Computer Memory and Executing Instructions.
Lecture 8 Working with tables Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Objective At the conclusion of this chapter you will be able to:
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Video systems. Lesson plan Review the code for the previous exercise Video systems Review for midterm exam.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
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:
ECE 353 Introduction to Microprocessor Systems Michael G. Morrow, P.E. Week 7.
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.
Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
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.
Preocedures A closer look at procedures. 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.
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Chapter 12 Processor Structure and Function. Central Processing Unit CPU architecture, Register organization, Instruction formats and addressing modes(Intel.
Assembly language programming
Instruction set Architecture
Lecture 2 Programming of 8086 Лектор: Люличева И.А. 1.
Format of Assembly language
Microprocessor and Assembly Language
BYTE AND STRING MANIPULATON
8086 Microprocessor.
Computer Organization And Assembly Language
Instruksi Set Prosesor 8088
ADDRESSING MODES.
Microprocessor and Assembly Language
Machine control instruction
Assembly Language Programming Part 2
ADDRESSING MODES.
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
BIC 10503: COMPUTER ARCHITECTURE
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
CS 301 Fall 2002 Computer Organization
Shift & Rotate Instructions)
Symbolic Instruction and Addressing
Unit:08 Software Interrupts
Chapter 6 –Symbolic Instruction and Addressing
Process.
Presentation transcript:

ECE291 Computer Engineering II Lecture 13 Josh Potts University of Illinois at Urbana- Champaign

Thursday, February 18, 2016ECE291 – Lecture 10Slide 2 of 19 Outline Material covered on Exam 1 Lookup tables Jump tables Interrupt vectors –Interrupt function examples

Thursday, February 18, 2016ECE291 – Lecture 10Slide 3 of 19 Exam Outline Name: ProblemPointsMax 1. Fundamentals20 2. Arithmetic and Logic30 3. Stack Operations30 4. Memory Addressing20 5. Branching10 6. Text Mode Video10 7. Coding Problem30 Total150

Thursday, February 18, 2016ECE291 – Lecture 10Slide 4 of 19 Exam Outline 1.Fundamentals A.Number Systems Base Conversion 2’s Complement B.Basic Processor Architecture Registers Memory Busses C.Addressing Modes A.Segment Offset Notation B.Mode Bytes D.Instruction Format and Opcodes This is essentially Lectures 1 through 3

Thursday, February 18, 2016ECE291 – Lecture 10Slide 5 of 19 Exam Outline 2.Arithmetic and Logic Operations A.All the instructions we learned (i.e. ADD, SUB, IMUL, SHL) B.Know how they work and what they do C.Be able to do the calculations by hand that these instructions accomplish D.Know how they affect the flags Lecture 4 Lecture 6

Thursday, February 18, 2016ECE291 – Lecture 10Slide 6 of 19 Exam Outline 3.Stack Operations A.Understand how data is accessed in the stack using PUSH, POP and the Base Pointer (BP) register B.Be able to analyze a segment of code that uses the stack and determine what effect the segment has on the stack and the registers C.Understand how procedure calls use the stack D.Understand how recursive functions work Lecture 7 Lecture 8

Thursday, February 18, 2016ECE291 – Lecture 10Slide 7 of 19 Exam Outline 4.Memory Addressing A.Know how your programs are arranged and stored in the memory B.Understand the physical arrangement of memory into banks C.Understand addressing D.Understand how variable declarations affect the contents of memory E.Be able to interpret instructions that use a variety of addressing modes Lecture 2 Lecture 3

Thursday, February 18, 2016ECE291 – Lecture 10Slide 8 of 19 Exam Outline 5.Branching A.Know the difference between jump commands for signed and unsigned comparisons B.Be able to determine the result of a jump command given the contents of the flag register or the preceding instruction C.Understand the difference between near and far jumps Lecture 5

Thursday, February 18, 2016ECE291 – Lecture 10Slide 9 of 19 Exam Outline 6.Text Mode Video A.Understand how the 80x25 text mode uses memory B.Know where the various pages are located in memory C.Understand how characters are stored in memory (e.g that they use two bytes, an attribute byte and an ASCII byte) D.Given the coordinates of a character on a given page, be able to calculate the physical address that stores that character Lecture 9

Thursday, February 18, 2016ECE291 – Lecture 10Slide 10 of 19 Exam Outline 7.Coding Problem A.We’ll give you a function definition, inputs, outputs, algorithm and ask you to code it. B.The algorithm could be anything, but it won’t be too complex. You should be able to do it with about 10 instructions, not including register pushes and pops to save state. C.The main thing is that you understand: how parameters get passed to functions how results are returned appropriate use of the stack the overall procedure call mechanism

Thursday, February 18, 2016ECE291 – Lecture 10Slide 11 of 19 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 ( )

Thursday, February 18, 2016ECE291 – Lecture 10Slide 12 of 19 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!

Thursday, February 18, 2016ECE291 – Lecture 10Slide 13 of 19 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!

Thursday, February 18, 2016ECE291 – Lecture 10Slide 14 of 19 Table Lookup Example 2 DAYS PUSH DX PUSH SI MOV SI, 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 $’ 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

Thursday, February 18, 2016ECE291 – Lecture 10Slide 15 of 19 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 ; Input BX = Command SHL BX,1 ; Words, not bytes JMP Jtable[BX] ; Jump to function Jtable dw Funct0 dw Funct1.. dw FunctN-1 Funct0 do something.. RET Funct1 do something else.. RET FunctN-1 do something else.. RET

Thursday, February 18, 2016ECE291 – Lecture 10Slide 16 of 19 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

Thursday, February 18, 2016ECE291 – Lecture 10Slide 17 of 19 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

Thursday, February 18, 2016ECE291 – Lecture 10Slide 18 of 19 Interrupt Functions Examples DOS Functions To execute one 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)

Thursday, February 18, 2016ECE291 – Lecture 10Slide 19 of 19 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

Thursday, February 18, 2016ECE291 – Lecture 10Slide 20 of 19 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