The CRTC Interface Essential aspects of display page and cursor control for standard 80-column by 25-row text.

Slides:



Advertisements
Similar presentations
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Advertisements

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.
There are two types of addressing schemes:
MICROPROCESSORS TWO TYPES OF MODELS ARE USED :  PROGRAMMER’S MODEL :- THIS MODEL SHOWS FEATURES, SUCH AS INTERNAL REGISTERS, ADDRESS,DATA & CONTROL BUSES.
VGA Text Mode An introduction to font selection and to reprogramming of the Character Generator ram.
University of Tehran 1 Microprocessor System Design Interrupt Omid Fatemi
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#3) By Dr. Syed Noman.
Crafting a ‘boot time’ program How we can utilize some standard ‘real-mode’ routines that reside in the PC’s ROM-BIOS firmware.
Early PC Graphics Capabilities of the IBM Color Graphics Adapter (CGA) and Enhanced Graphics Adapter (EGA)
More about procedures and Video Processing. Lesson plan Review existing concepts More about procedures and boolean expression Video processing.
Video systems (continue). Practice Modify the program to get a string from a keyboard to display the input string on the middle of the screen with reverse.
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Lab6 – Debug Assembly Language Lab
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.
Defining protected-mode segment-descriptors An example of a protected-mode bootsector application that draws a message to the video display.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
The CRT Controller How to modify CRTC registers to achieve a non-standard horizontal and vertical screen resolution.
The CRTC Interface Essential aspects of display page and cursor control for standard 80-column by 25-row text.
The Keyboard Controller Essential steps for implementing an interrupt service routine for the Keyboard Controller.
Chapter 7 Programming with DOS and BIOS Function Calls Objectives: The use of DOS and BIOS function call How to read the PC’s keyboard How to send text.
Graphics Bitmaps Drawing characters glyphs and multicolor patterns.
Early PC Graphics Capabilities of the IBM Color Graphics Adapter (CGA) and Enhanced Graphics Adapter (EGA)
The Keyboard Controller Essential steps for implementing an interrupt service routine for the Keyboard Controller.
SiS 315 An introductory exploration of features of the SVGA graphics processor used in our classroom’s workstations.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2013 Lecture 4: 80386DX memory, addressing.
Practical Session No. 10 Input &Output (I/O). I/O Devices Input/output (I/O) devices provide the means to interact with the “outside world”. An I/O device.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
ORG ; FOUR INT 21H and INT 10H Programming and Macros Dec Hex Bin
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
I/O Systems I/O Hardware Application I/O Interface
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Principles of I/0 hardware.
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
PIT Programming Examples Working with the modes of PIT.
ENEE 440 Chapter DMA Controller 8237 DMA Controller Summary Direct Memory Access means that the microprocessor is not involved in the transfer.
Types of Registers (8086 Microprocessor Based)
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
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:
4. Kernel and VGA ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  None.
Khaled A. Al-Utaibi  I/O Ports  I/O Space VS Memory Space  80x86 I/O Instructions − Direct I/O Instructions − Indirect I/O Instructions.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
Control Structure vs. Assembly Language NASM. If-then-else If conditional then then_actions jump to endif else else_actions endif.
بسم الله الرحمن الرحيم MEMORY AND I/O.
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
Practical Session 12 Input &Output (I/O). I/O Device Input / Output (I/O) devices Input / Output (I/O) devices provide the means to interact with the.
Internal Programming Architecture or Model
Lecture 11 Text mode video
Week 6 Dr. Muhammad Ayaz Intro. to Assembly Language.
Practical Session 11 Computer Architecture and Assembly Language Input &Output (I/O)
Lecture 2 Programming of 8086 Лектор: Люличева И.А. 1.
Format of Assembly language
Microprocessor Systems Design I
8086 Microprocessor.
Computer Organization & Assembly Language Chapter 3
ADDRESSING MODES.
Microprocessor and Assembly Language
DMA CONTROLLER WHOLE WORKING
CS 301 Fall 2002 Computer Organization
Computer Architecture and Assembly Language
Chapter 13: I/O Systems.
Presentation transcript:

The CRTC Interface Essential aspects of display page and cursor control for standard 80-column by 25-row text

Motivation When a UNIX application wishes to write a text message to the display, and then wait for a keyboard-response from the user, the application will want a ‘cursor’ to be visible at the position where the next keystroke is going to be echoed EXAMPLE: Please type a number: We expect a blinking cursor to appear here

But it’s tedious to program… To write code that draws a blinking cursor on the screen would be a time-consuming chore for both programmer and processor: –You have to repeatedly ‘draw’ and then ‘hide’ –You have to setup careful timing controls –Your program-loop will keep the CPU busy! Fortunately the video system’s hardware is able to handle this tedious chore for you!

Info the CRTC engine needs The display hardware already knows how to do the timing for normal cursor blinking (i.e., usually about two blinks per second) Software only needs to tell the hardware a few specific pieces of information: –Where does the cursor appear (row, column)? –How large is the cursor? Where does it start and end within the 8x16 character-cell? –Which region of display-memory is visible?

Hardware registers The CRT Controller is a peripheral chip It implements 25 standard CRTC registers Access to these registers is accomplished via a multiplexing scheme which uses just two I/O port-addresses for color text: address-port:0x03D4 data-port:0x03D5

How it works The multiplexing scheme for access to the CRTC registers was designed to function as a two-step operation: –First, specify which register is to be accessed (by writing the register’s index to port 0x3D4) –Then, read (or write) to the specified register (by inputting, or outputting, at port 0x3D5) But a multi-step scheme is problematic for preemptive multitasking (also it is slow!)

A useful optimization To improve the multiplexing scheme when writing values to CRTC registers, the CPU is able to perform the two steps in a single ‘atomic’ fetch-execute cycle: Here the ‘outw’ instruction will write AL to port $0x03D4 and AH to port $0x03D5 mov$0x03D4, %dx mov$0xFF14, %ax outw%ax, %dx

Cursor-related CRTC registers For text-mode cursor-control, we are concerned with just 6 (of the 25) standard CRTC registers: Index 0x0A:CURSOR_START Index 0x0B:CURSOR_END Index 0x0C:START_ADDRESS_HI Index 0x0D:START_ADDRESS_LO Index 0x0E:CURSOR_LOCATION_HI Index 0x0F:CURSOR_LOCATION_LO

8x16 character box scanline 0 scanline 1 scanline 2 scanline 3 scanline 4 scanline 5 scanline 6 scanline 7 scanline 8 scanline 9 scanline 10 scanline 11 scanline 12 scanline 13 scanline 14 scanline 15 Cursor_start = 12 Cursor_end = 13

CURSOR START/END dis- able starting_scanline skewending_scanline Index 0x0A: Index 0x0B: CURSOR_START REGISTER CURSOR_END REGISTER NOTE: The ‘skew’ capability works by delaying the cursor’s appearance for 0, 1, 2, or 3 character-cells (i.e., shifting the cursor toward the right). When Is this useful? We couldn’t find any examples. Recommend skew be zero.

Organization of the VRAM Page 0 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Base_Address = 0xB8000 4KB

Changing the visual page START_ADDRESS_HISTART_ADDRESS_LO register-index 0x0C register-index 0x0D Programming example: # switches display to vram page 5 # the word-offset for page 5 is 0x2800 (= 5 * 2048) mov$0x03D4, %dx# port-address in register DX mov$0x280C, %ax# value=0x28, register=0x0C out%ax, %dx# write value to CRTC register mov$0x000D, %ax# value=0x00, register=0x0D out%ax, %dx# write value to CRTC register

Moving the CRT’s cursor CURSOR_LOCATION_HICURSOR_LOCATION_LO register-index 0x0Eregister-index 0x0F Programming example: // moves cursor to row 5, column 9, on page 0 mov$0x03D4, %dx// port-address in register DX mov$5, %bx// row-number imul$80, %bx// times cells-per-row add$9, %bx// plus column-number mov%bh, %ah// cursor offset’s MSB mov$0x0E, %al// CURSOR_HI index out%ax, %dx// write value to CRTC register mov%bl, %ah// cursor offset’s LSB mov$0x0F, %al// CURSOR_LO index out%ax, %dx// write value to CRTC register

Scrolling the screen Here’s a code-fragment that will scroll the contents of vram page 0 up by one line: mov$0xB800, %ax// address vram page 0 mov%ax, %ds// with DS register mov%ax, %es// also ES register mov$0, %di// destination is the top line mov$160, %si// source is one line lower cld// do forward copying mov$3840, %cx// 24 times 160 repmovsb// perform the copying mov$0x0720, %ax// blank character w/color mov $80, %cx// characters on bottom line repstosw// fill final line with blanks

Linux uses hardware scrolling The value of the CRT START_ADDRESS is reprogrammed, to change the region of visible vram by one line (i.e., add #80) So instead of subdividing vram into eight 4KB pages, the entire 32KB vram is one continuous page, but only partially visible To scroll up by one line, Linux adds $80 to the value of the CRT_START_ADDRESS

The ROM-BIOS variables Several variables in the ROM-BIOS DATA AREA are used by the VIDEO ROM-BIOS routines (i.e., int-0x10) to keep track of the current visisible page and of the positions of the cursors on each of the eight pages The locations of these variables are part of the IBM-PC BIOS standard, and as such they are widely documented

Standard data-addresses 0x449 (byte) current video mode-number 0x44A (word) number of columns on screen 0x44C (word) current page-size (in bytes) 0x44E (word) current page-address 0x450 (byte array) cursor-positions (col,row) 0x460 byte-pair) cursor type (END, START) 0x462 (byte) current display page-number 0x463 (word) CRTC base i/o port-address

Real-mode INT-0x10 services Function 0x00: set_display_mode Function 0x01: set_cursor_type Function 0x02: set_cursor_position Function 0x03: get_cursor_position_and_type Function 0x05: select_new_video_page Function 0x06: scroll_current_page_up Function 0x07: scroll_current_page_down Function 0x08: read_char_and_attrib_from_screen Function 0x09: write_char_and_attrib_to_screen Function 0x0A: write char_only_to_screen Function 0x0E: write_teletype_to_active_page Function 0x0F: return_video_status Function 0x13: write_string NOTE: These ROM-BIOS services are not available in protected-mode

Cursor-movement demo To illustrate reprogramming of the six CRT controller registers, we wrote ‘arrows.s’ It lets the user control the cursor position and visible page by using arrow-keys It also changes the height of the cursor An unusual feature (not recommended) is its use of “polled mode” keyboard device- programming (instead of “interrupt-driven”)

Polling the status-register The keyboard controller’s interrupt is masked The keyboard controller’s status-register is read and reread in a tight loop until bit #0 gets set, indicating that a key was pressed (or released) and hence the output-buffer register is now “full” So then the output-buffer register is read by the CPU to get the key’s “scancode” For the arrow-keys, the cursor will get moved Other keys are just ignored (except ESCAPE)

Disadvantage of polling Almost all of the CPU’s time is consumed by continually reading the status-register So this would not be a good design to use in writing a multitasking operating system! On the other hand, for single-tasking it has the advantage of not requiring an Interrupt Service Routine to be written, so the demo code we write can be shorter and simpler

Another noteworthy feature The ‘arrows.s’ demo uses a ‘jump-table’ to efficiently dispatch control to appropriate subroutines, based on a variable’s value This is a similar programming situation to using a ‘switch’ statement in C/C++ The jump-table avoids the long chain of ‘compare-and-branch’ statements for all the various possible cases that can occur

In-Class exercise To insure your mastery of the jump-table concept, and cement your grasp of how the CRTC START_ADDRESS registers are programmed, try modifying the demo to incorporate these additional actions: when one of the function-keys F1-F7 is pressed, the display is switched to the correspondingly numbered display-page