Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "ECE291 Computer Engineering II Lecture 12 Josh Potts University of Illinois at Urbana- Champaign."— Presentation transcript:

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

2 Josh PottsECE291 Outline Video Display Text video mode Controlling and accessing video display using –DOS functions –BIOS functions

3 Josh PottsECE291 Basic Forms of Input and Output I/O-mapped I/O –uses special instructions to transfer data between the computer system and the outside world Memory-mapped I/O –uses special memory locations in the normal address space of the CPU to communicate with real-world devices Direct memory access (DMA) –special form of memory-mapped I/O where the peripheral device reads and writes the memory without going through the CPU –Note that the CPU and DMA device cannot both use the address and data buses at the same time –concurrent processing only occurs if the CPU has a cache and is executing code and accessing data found in the cache (so the bus is free)

4 Josh PottsECE291 Video I/O Video is the primary form of I/O between a human and a computer The monochrome (one color) monitor uses one wire for video, one for horizontal sync, and one for vertical synch A color video monitor uses three video signals: red, green, & blue –these monitors are called RGB monitors and convert the analog RGB signal to an optical image. The RGB monitor is available as either analog or TTL monitor

5 Josh PottsECE291 TTL RGB monitor Uses TTL level signals (0 or 5V) as video inputs (RGB) and an extra signal called intensity to allow change in intensity Used in the CGA (Color Graphics adaptor) system found in older computers Can display a total of 16 different colors (eight are generated at high intensity and eight at low intensity) Example: Red GreenBlueIntensityColor 00 0 0Black 0 0 0 1Gray 0 1 0 0Light green 10 0 0Light red 11 1 0White

6 Josh PottsECE291 The Analog RGB Monitor Uses analog signals - any voltage between 0.0 V and 0.7 V This allow infinite number of colors to be displayed In practice a finite number of levels is generated (256K, 16M, or 24M colors depending on the standard) Analog displays use a digital-to-analog converter (DAC) to generate each color video voltage A common standard uses a 6-bit DAC to generate 64 different video levels between 0 V and 0.7 V –this allows 64x64x64 different colors to be displayed or 262,144 (256 K) colors 8-bit DACs allow 256x256x256 or 16M colors

7 Josh PottsECE291 The Analog RGB Monitor The Video Adapter converts digital information from the CPU to analog signals for a monitor. VRAM/DRAM Video/Dynamic Random Access Memory –Stores screen content Video BIOS –Stores character mappings Palette registers –Defines R/G/B color values Graphic accelerator –Hardware implemented graphic routines DAC –Generates analog Red/Green/Blue signals

8 Josh PottsECE291 The Analog RGB Monitor Example of Video Generation Example video generation used in video standards such as EGA (enhance graphic adapter) and VGA (variable graphics array) A high-speed palette SRAM (access time less than 40ns) stores 256 different codes that represent 256 different hues (18-bit codes) This 18-bit code is applied to the DACs The SRAM is addressed by 8-bit code that is stored in the computer VRAM to specify color of the pixel Once the color code is selected, the three DACs convert it to three video voltages for the monitor to display a picture element (pixel)

9 Josh PottsECE291 The Analog RGB Monitor Example of Video Generation (cont.) Any change in the color codes is accomplish during retrace (moving the electron beam to the upper left-hand corner for vertical retrace and to the left margin of the screen for horizontal retrace) The resolution of the display (e.g., 640x400) determines the amount of memory required for the video interface card 640x400 resolution with 256 colors (8 bit per pixel) 256K bytes of memory are required to store all the pixels for the display

10 Josh PottsECE291 Text-Video Mode There is not a single common device for supporting video display There are numerous display adapter cards available for the PC Each supports several different display modes We discuss the 80x25 text display mode which is supported by most of display adapters The 80x25 text display is a two dimensional array of words with each word in the array corresponding a character on the screen Storing the data into this array affects the characters appearing on the display

11 Josh PottsECE291 Text-Video Mode Each text page occupies under 4K bytes of memory 80(columns) x 25 (rows) x 2 (bytes) = 4000bytes The LO byte contains the ASCII code of the character to display The HO byte contains the attribute byte The color display adapters provide 32 K for text displays and let you select one of eight different pages Each display begins on a 4K boundary, at address: –B800:0, B800:1000, B800:2000, …. B800:7000 You can address the memory on the video display like ordinary RAM, but it is never a good idea to do this –access to the display adapter is much slower than to the main memory

12 Josh PottsECE291 Text-Video Mode The attribute byte controls underlying background and foreground colors, intensity and blinking video Choose your colors with care (some combinations of foreground and background colors are not readable) Do not overdo blinking text on the screen

13 Josh PottsECE291 Using DOS and BIOS Functions to Control Display DOS (disk operating system) and BIOS (basic I/O system) provide functions to control and to access the I/O environment of the computer including display. DOS provides INT 21h, which is called the DOS function dispatcher and supports functions such as: read from the keyboard, write to the screen, write to the printer, read and write to disk files ….. INT 21 must be told which function is being requested this information is passed by placing the function number in the AH register depending on the function being used, other information may be needed

14 Josh PottsECE291 Displaying A Single Character Using DOS INT 21h Example: suppose that the letter ‘A’ is to be printed to the screen at the current cursor position can use function 02h, or 06h (this function can also be used to read a key) INT 21h must also be told which letter to print – the ASCII code must be placed into DL register MOVDL, ‘A’ MOVAH, 06h INT21h

15 Josh PottsECE291 Displaying A Character String Using DOS INT 21h DOS function 09h displays a character string that ends with $ MSGDB‘This is a test line’,’$’ …... MOVDX, OFFSET MSG MOVAH, 09h INT21h The string will be printed at the current cursor position

16 Josh PottsECE291 Using BIOS to Control Display The DOS function calls allow a key to be read and a character to be displayed but the cursor is difficult to be position at the desired screen location The BIOS function calls allow more control over the video display and require less time to execute than the DOS function calls BIOS provides interrupt INT 10h, known as video interrupt, which gives access to various functions to control video screen Before we place information on the screen we should get the position of the cursor: function 03h reads cursor position (DH = Row, DL = Column, BH =Page # function 02h sets cursor position (DH = Row, DL = Column, BH =Page #

17 Josh PottsECE291 Using BIOS to Control Display Function 0Fh finds the number of the active page –the page number is returned in BH register The cursor position assumes that –the left hand page column is column 0 progressing across a line to column 79 –the row number corresponds to the character line number on the screen

18 Josh PottsECE291 Using BIOS to Control Display Example TITLE vidDispl.asm CR EQU 0dh LF EQU 0ah.MODEL small.STACK.DATA HeadBYTE '==============', 0 PromptBYTE 'Middle (12, 40)’,0 ClearBYTE'Do you want to clear screen', 0 yesBYTE3 dup (?) middleBYTE'Move cursor to the middle', 0 HelloBYTE'ECE291', 0.CODE.STARTUP movax, @DATA movds, ax GetPage MACRO ;gets current page movah, 0fh int10h ENDM HomeMACRO ;moves cursor to (0,0) GetPage movah, 02h movdx, 0 ;coordinates of the cursor int10h ENDM

19 Josh PottsECE291 Using BIOS to Control Display Example (cont.) ClearScr MACRO ;clear the screen GetPage mov ah, 8;read attributes int 10h mov bl, bh mov bh, ah;bh=attributes for cleared area sub cx, cx ;ch and cl = (x,y) coordinates of upper left ;corner of the window (0, 0) mov dx, 184fh;dh and dl = (x,y) coordinates of lower ;right corner of the window (24, 79) mov ax, 0600h;al=#lines to scroll if zero window cleared int 10h ENDM

20 Josh PottsECE291 Using BIOS to Control Display Example (cont.) ClearScr Home mov ax, OFFSET Head push ax call putStr call newLine mov ax, OFFSET Clear push ax call putStr call newLine mov ax, OFFSET yes ;checks whether to clear the screen push ax call getStr movbx, OFFSET yes cmpBYTE PTR [bx], 'y' jne noClear ClearScr Home noClear: call newLine mov ax, OFFSET middle push ax call putStr call newLine mov ax, OFFSET yes push ax call getStr mov bx, OFFSET yes cmp BYTE PTR [bx], 'y' jne goToEnd

21 Josh PottsECE291 Using BIOS to Control Display Example (cont.) ;Cursor to the middle of the screen ClearScr GetPage movdh, 12 movdl, 40 movah, 02h int10h movbl, 1eh ;initial attributes 0 001 1 110 ;background = blue (001) ;foreground = yellow(110) movcx,1 ;#times a character ;will be printed mov al, 'M' ;mark middle with M movah, 09h int10h ;write in the middle movdh, 12 movdl, 42 ;move the cursor two ;position right movah, 02h int10h mov ax, OFFSET Prompt push ax call putStr call newLine

22 Josh PottsECE291 Using BIOS to Control Display Example (cont.) ;Print text with different attributes GetPage mov si,OFFSET Hello mov bl, 1ah ;initial attributes 0 001 1 010 ;background = blue (001) ;foreground = green (010) movcx,80 ;#times a character will be printed movah,09h ;ready to write a character next: call newLine cmp BYTE PTR [si], 0 ;check for the end of the string je goToEnd mov al, [si] int 10h inc si ;next character inc bl ;change in foreground color jmp next goToEnd: mov ah, 4ch int 21h

23 Josh PottsECE291 Using BIOS to Control Display Example (cont.) ;OFFSET of string to be printed must ;be on the stack and the string must ;be null terminated putStrPROC NEAR pushbp movbp, sp pushax pushbx pushdx movbx, [bp + 4] ;expect bx to point to string movah, 2h nextChar: cmp BYTE PTR [bx], 0h ;check for null terminator jefoundEnd ;when found exit movdl, [bx] int21h ; print with 21h incbx ;point to next char jmpnextChar foundEnd: popdx popbx popax popbp ret 2 putStrENDP

24 Josh PottsECE291 Using BIOS to Control Display Example (cont.) ;OFFSET of large enough buffer must ;have been pushed onto stack ;string will be null terminated getStrPROC NEAR pushbp movbp, sp pushax pushbx movbx, [bp + 4] ;base address of storing buffer movah, 01h getLoop: int21h cmpal, CR ;look for CR in al je getEnd mov[bx], al ;bx points to storage location inc bx jmpgetLoop getEnd: movBYTE PTR [bx], 0 ;CR is converted in null term popbx popax popbp ret2 getStr ENDP

25 Josh PottsECE291 Using BIOS to Control Display Example (cont.) newLine PROC NEAR push ax push dx movah, 02h movdl, CR int21h movdl, LF int21h popdx popax ret newLineENDP


Download ppt "ECE291 Computer Engineering II Lecture 12 Josh Potts University of Illinois at Urbana- Champaign."

Similar presentations


Ads by Google