Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microprocessor and Assembly Language

Similar presentations


Presentation on theme: "Microprocessor and Assembly Language"— Presentation transcript:

1 Microprocessor and Assembly Language
Lecture-12-Text Display and Keyboard Programming Muhammad Hafeez Department of Computer Science GC University Lahore

2 Today’s Agenda Controlling the Screen Controlling the Keyboard

3 The Monitor Electron gun shoot a stream on phosphorus screen
Lines and dots are generated with electron gun A raster of lines is created starting from top left corner of screen

4 Types of Monitors Monochrome Color
Single beam, single color typically amber or green Dots of different brightness is created called gray scale Color Screen is coated with RGB phosphorus, and three guns are used to create a single homogenous color

5 Types of Monitors Monochrome Color
Single beam, single color typically amber or green Dots of different brightness is created called gray scale Color Screen is coated with RGB phosphorus, and three guns are used to create a single homogenous color

6 Video Adapters Video Adapter has two parts
Display Memory Video Controller Display Memory address starts at segment A000h and above depending upon the type of video adapter Video Controller reads Display Memory and do appropriate task on the screen

7 Types of Video Adapters in IBM PC

8 Display Modes Computer has different techniques and memory requirement for displaying text and images Video Adapter has two modes, each for text and images Text Mode Screen is divided into Rows and Column, 25 rows (0-24) and 80 columns (0-79) Graphics Mode Screen is again divided into Rows and Columns and each screen position is called a pixel

9 Text Mode Character Generation
Every single character on the screen is created using a dotter array called character cell The video adapter uses a character generation circuit to create a dotted pattern Number of dots in a character depends upon the resolution of adapter, monitor has its resolution, its mandatory that both monitor and adapter’s resolution must be compatible

10 Details of IBM Video Adapters
IBM introduced MDA and CGA with its original PC MDA only supported text mode with good character resolution i.e. 9x14 dots, used for business software CGA could display both text and graphics but low resolution in character cell i.e. 8 x 8 dots Then IBM introduced EGA for both text and graphics with character cell 8 x 14 dots Finally IBM introduced VGA and MCGA with more text and graphics resolution, text resolution 8 x 19 dots for each character

11 Details of IBM Video Adapters
IBM introduced MDA and CGA with its original PC MDA only supported text mode with good character resolution i.e. 9x14 dots, used for business software CGA could display both text and graphics but low resolution in character cell i.e. 8 x 8 dots Then IBM introduced EGA for both text and graphics with character cell 8 x 14 dots Finally IBM introduced VGA and MCGA with more text and graphics resolution, text resolution 8 x 19 dots for each character

12 Text Mode Number A program can select text or graphics mode
Following are text mode

13 Screen Positions 80 x 25 screen positions

14 Character display and Video Memory
In text mode screen consists of rows and columns (80x25), in graphics mode (40x25) is also possible A character displayed at screen is defined by content of word in display memory Low byte contains character ASCII code High byte contains character attribute

15 Display pages MDA adapter display memory hold screen full of data
Graphics adapter can contain many screens of display text, each screen is called display page Number of display varies among adapter starts from 0 Each display page is 4KB for MDA has one page starts at B000:0000h CGA has four pages starting at B800:0000h

16 Number of pages from various adapter in text mode

17 Attribute Byte In text mode, high byte of character is called attribute byte It defines foreground color, background color, intensity and whether a character is blinking or not Number of display varies among adapter starts from 0 Each display page is 4KB for MDA has one page starts at B000:0000h CGA has four pages starting at B800:0000h

18 Attribute Byte Attribute byte for 16 color display has the following format Red color on blue background

19 Attribute Byte Adjacent colors can be added to produce new colors
Intensity bit is used to brighten the color on color display Normal attribute for a character is 07h, white on black background

20 16 Color on Color Display

21 Monochrome attributes

22 Screen Rows and Columns

23 Manual Screen Printing

24 Video Interrupt 10h Text Mode functions of INT 10H
Select text display mode i.e. character height and width and number of rows and columns INT 10H INPUT: AH=0 AL = Mode Number OUTPUT: None

25 Video Interrupt 10h Change Cursor Size INT 10H
Cursor is displayed as small dotted array MDA, EGA 14 rows (0-13), 11 and 12 lit CGA 8 rows (0-7), 6 and 7 lit INT 10H INPUT: AH=1 CH = start scan line CL = end scan line OUTPUT: None

26 Video Interrupt 10h Move Cursor INT 10H
Let the cursor move anywhere on the screen INT 10H INPUT: AH=2 DH = new cursor row (0-24) DL = new cursor column (0-79) BH= page number OUTPUT: None

27 Video Interrupt 10h Get cursor position and size INT 10H
If we want to know current cursor position INT 10H INPUT: AH=3 BH= page number OUTPUT: DH = CURSOR ROW DL = CURSOR COLUMN CH = CURSOR START SCAN LINE CL = CURSOR END SCAN LINE

28 Video Interrupt 10h Select active display page INT 10H INPUT: AH=5
AL = ACTIVE DISPLAY PAGE (0-7) OUTPUT: NONE

29 Video Interrupt 10h INT 10H Scroll the screen Up
Also used to clear the screen or clear a particular area on the screen It could be used to draw game boxes INT 10H INPUT: AH=6 AL = Number of lines to scroll up, 0 means whole screen BH = attribute for blank line (07H) CH, CL = ROW, COL FOR UPPER LEFT CORNER OF WINDOW DH, DL = ROW, COL FOR LOWER RIGHT CORNER OF WINDOW OUTPUT: NONE

30 Video Interrupt 10h INT 10H Scroll the screen Down
Also used to clear the screen or clear a particular area on the screen It could also be used to draw game boxes INT 10H INPUT: AH=7 AL = Number of lines to scroll up, 0 means whole screen BH = attribute for blank line (07H) CH, CL = ROW, COL FOR UPPER LEFT CORNER OF WINDOW DH, DL = ROW, COL FOR LOWER RIGHT CORNER OF WINDOW OUTPUT: NONE

31 Video Interrupt 10h INT 10H Read a character a cursor position
INPUT: AH=8 BH = Page Number OUTPUT: AH = ATTRIBUTE OF CHARACTER AL = ASCII OF CHARACTER

32 Video Interrupt 10h Display character at cursor with any attribute INT 10H INPUT: AH=9 BH = Page Number AL = ASCII OF CHARACTER TO DISPLAY CX = NUMBER OF TIMES TO WRITE CHARACTER BL = ATTRIBUTE OF CHARACTER OUTPUT: NONE

33 Video Interrupt 10h Display character at cursor with current attribute Cursor does not advance after display of character INT 10H INPUT: AH=0AH BH = Page Number AL = ASCII OF CHARACTER TO DISPLAY CX = NUMBER OF TIMES TO WRITE CHARACTER OUTPUT: NONE

34 Video Interrupt 10h Display character at cursor with current attribute Cursor is advanced one position This BIOS interrupt is called by INT 21h function 2 INT 10H INPUT: AH=0EH BH = Page Number AL = ASCII OF CHARACTER TO DISPLAY BL = FOREGROUND COLOR (GRAPHICS MODE) OUTPUT: NONE

35 Video Interrupt 10h INT 10H Get Video Mode INPUT: AH=0FH OUTPUT:
AH = NUMBER OF SCREEN COLUMNS AL = DISPLAY MODE BH = ACTIVE DISPLAY PAGE

36 Video Interrupt 10h

37 Graphics Three color graphics adapters for IBM PC
CGA (Color Graphics Adapter) EGA (Enhanced Graphics Adapter) VGA (Video Graphics Array)

38 Composition of Video on Monitor
Electron beam creates scan lines on screen Number of dots per line can vary by changing the size of dot Number of scan lines may also vary

39 Pixel Graphics mode screen is also divided into rows and column
Each intersection of row and column is called Pixel (Picture Element) Number of pixels define the resolution of screen 320x200 means 300 columns and 200 rows Columns are numbered from left to right starting with 0 Rows numbered from top to bottom start with 0 If in low resolution a pixel may contain more than two dots

40 Graphics Modes

41 CGA Graphics CGA in medium resolution 320x200 and high resolution 640x200 16 KB memory starting at address B800:0000 and end at B800:3FFF Each pixel is coded by two bits Four colors can be displayed at a time Medium resolution is 320x200 = pixels Each pixel require two bits 64000x2 = bits or bytes Display memory is 16 KB

42 16 color combinations

43 Text in Graphics Mode In graphics mode characters are formed by turning pixels on and off and are not drawn by character generating circuitry as in text mode However cursor position can still be set by using function number 2 INT 10h When we display text in graphics mode we use text coordinates

44 Text COLUMNS AND ROWS IN GRAPHICS MODE

45 Set Background Color INT 10H Set Background color after setting mode
INPUT: AH=0BH BH = 0 BL = COLOR NUMBER (0-15) OUTPUT: NONE

46 Writing Pixel INT 10H Write Graphics Pixel INPUT: AH=0CH
AL = PIXEL VALUE (COLOR) BH = PAGE NUMBER CX = COLUMN NUMBER DX = ROW NUMBER OUTPUT: NONE

47 Reading Pixel Read Graphics Pixel INT 10H INPUT: AH=0DH BH = PAGE NUMBER CX = COLUMN NUMBER DX = ROW NUMBER OUTPUT: AL = PIXEL VALUE (COLOR) Pixel read and write can be done any display page

48 Active Display Page INT 10H
Select Active Display Page INT 10H INPUT: AH=5 AL = PAGE NUMBER OUTPUT: AL = PIXEL VALUE (COLOR) Quickly switching the page can be used for animation

49 Vga Adapter VGA has two important modes to work
640x480 resolution on mode 12H with 16 colors 320x200 resolution on mode 13H with 256 colors. 12H is good for game purpose

50 Random Number Here is the Program to generate Semi-Random Number

51 Adding Sound Communicate with Ports using IN and OUT instructions
These instructions help assembly program to communicate with peripheral devices

52 Input/ Output Ports Ports are like registers, in which we send 8-bit or 16-bit data from AL or AX Ports contents can also be read in AL or AX Ports are connected to peripheral devices We change something in Port content, we send a message to particular peripheral devices

53 Out Instruction Send byte/ word to Input/ Output Port In case of Byte
OUT Portno, AL In case of Word OUT Portno, AX

54 Internals of Port 61

55 In Instruction Receive byte/ word to Input/ Output Port
In case of Byte OUT AL, Portno In case of Word OUT AX, Portno

56 Example: Sound generation using direct Port access

57 Timer in IBM PC Three types of timers circuits in IBM PC
Timer0 used for DMA (Data Transfer) Timer1 is used as system clock Timer2 is connected to the speaker

58 Generating Sound using Timer2
Three step process Put a certain number in timer2 to initialize it Load a 16 bit number into timer2 to establish the frequency of tone to be generated Open a switch in output port 61H to generate the sound

59 Generating Sound using Timer2


Download ppt "Microprocessor and Assembly Language"

Similar presentations


Ads by Google