+ All Categories
Home > Documents > Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson...

Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson...

Date post: 17-Dec-2015
Category:
Upload: iris-owens
View: 229 times
Download: 1 times
Share this document with a friend
Popular Tags:
39
Assembly Language for Intel- Assembly Language for Intel- Based Computers Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and copy this slide show for your personal use, or for use in the classroom, as long as this copyright statement, the author's name, and the title are not changed.
Transcript
Page 1: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Assembly Language for Intel-Based Assembly Language for Intel-Based ComputersComputers

Chapter 15: BIOS-Level Programming

(c) Pearson Education, 2006-2007. All rights reserved. You may modify and copy this slide show for your personal use, or for use in the classroom, as long as this copyright statement, the author's name, and the title are not changed.

Page 2: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 2Web site Examples

Chapter OverviewChapter Overview

• Introduction• VIDEO Programming with INT 10h• Drawing Graphics Using INT 10h• Memory-Mapped Graphics

Page 3: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 3Web site Examples

PC-BIOSPC-BIOS

• The BIOS (Basic Input-Output System) provides low-level hardware drivers for the operating system.• accessible to 16-bit applications

• written in assembly language, of course

• source code published by IBM in early 1980's

• Advantages over MS-DOS:• permits graphics and color programming

• faster I/O speeds

• read mouse, serial port, parallel port

• low-level disk access

Page 4: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 4Web site Examples

BIOS Data AreaBIOS Data Area

• Fixed-location data area at address 00400h• this area is also used by MS-DOS

• this area is accessible under Windows 98 & Windows Me, but not under Windows NT, 2000, or XP.

• Contents:

• Serial and parallel port addresses

• Hardware list, memory size

• Keyboard status flags, keyboard buffer pointers, keyboard buffer data

• Video hardware configuration

• Timer data

Page 5: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 5Web site Examples

What's NextWhat's Next

• Introduction• Keyboard Input with INT 16h• VIDEO Programming with INT 10h• Drawing Graphics Using INT 10h• Memory-Mapped Graphics• Mouse Programming

Page 6: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 6Web site Examples

VIDEO Programming with INT 10hVIDEO Programming with INT 10h

• Basic Background• Controlling the Color• INT 10h Video Functions

Page 7: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 7Web site Examples

Video ModesVideo Modes

• Graphics video modes• draw pixel by pixel

• multiple colors

• Text video modes• character output, using hardware or software-based

font table

• mode 3 (color text) is the default

• default range of 80 columns by 25 rows.

• color attribute byte contains foreground and background colors

Page 8: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 8Web site Examples

Video Text ModeVideo Text Mode

• Fonts.• Video Text Pages• Attributes

Page 9: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 9Web site Examples

Controlling the ColorControlling the Color

• Mix primary colors: red, yellow, blue• called subtractive mixing

• add the intensity bit for 4th channel

• Examples:• red + green + blue = light gray (0111)

• intensity + green + blue = white (1111)

• green + blue = cyan (0011)

• red + blue = magenta (0101)

• Attribute byte:• 4 MSB bits = background

• 4 LSB bits = foreground

Page 10: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 10Web site Examples

Controlling the ColorControlling the Color

Page 11: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 11Web site Examples

INT 10h Video FunctionsINT 10h Video Functions

• AH register contains the function number• 00h: Set video mode

• text modes listed in Table 15-5

• graphics modes listed in Table 15-6

• 01h: Set cursor lines• 02h: Set cursor position• 03h: Get cursor position and size• 06h: Scroll window up• 07h: Scroll window down • 08h: Read character and attribute

Page 12: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 12Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

• 09h: Write character and attribute• 0Ah: Write character• 10h (AL = 03h): Toggle blinking/intensity bit• 0Fh: Get video mode

Page 13: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 13Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 14: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 14Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 15: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 15Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 16: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 16Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 17: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 17Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 18: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 18Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 19: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 19Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 20: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 20Web site Examples

Displaying a Color StringDisplaying a Color String

Write one character and attribute:mov si,OFFSET string

. . .

mov ah,9 ; write character/attribute

mov al,[si] ; character to display

mov bh,0 ; video page 0

mov bl,color ; attribute

or bl,10000000b ; set blink/intensity bit

mov cx,1 ; display it one time

int 10h

Page 21: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 21Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 22: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 22Web site Examples

INT 10h Video FunctionsINT 10h Video Functions (cont) (cont)

Page 23: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 23Web site Examples

Gotoxy ProcedureGotoxy Procedure

;--------------------------------------------------

Gotoxy PROC

;

; Sets the cursor position on video page 0.

; Receives: DH,DL = row, column

; Returns: nothing

;---------------------------------------------------

pusha

mov ah,2

mov bh,0

int 10h

popa

ret

Gotoxy ENDP

Page 24: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 24Web site Examples

Clrscr ProcedureClrscr Procedure

Clrscr PROC

pusha

mov ax,0600h ; scroll window up

mov cx,0 ; upper left corner (0,0)

mov dx,184Fh ; lower right corner (24,79)

mov bh,7 ; normal attribute

int 10h ; call BIOS

mov ah,2 ; locate cursor at 0,0

mov bh,0 ; video page 0

mov dx,0 ; row 0, column 0

int 10h

popa

ret

Clrscr ENDP

Page 25: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 25Web site Examples

What's NextWhat's Next

• Introduction• VIDEO Programming with INT 10h• Drawing Graphics Using INT 10h• Memory-Mapped Graphics

Page 26: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 26Web site Examples

INT 10h Pixel-Related FunctionsINT 10h Pixel-Related Functions

• Slow performance• Easy to program• 0Ch: Write graphics pixel• 0Dh: Read graphics pixel

Page 27: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 27Web site Examples

INT 10h Pixel-Related FunctionsINT 10h Pixel-Related Functions

Page 28: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 28Web site Examples

INT 10h Pixel-Related FunctionsINT 10h Pixel-Related Functions

Page 29: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 29Web site Examples

INT 10h Pixel-Related FunctionsINT 10h Pixel-Related Functions

Page 30: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 30Web site Examples

DrawLine ProgramDrawLine Program

Page 31: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 31Web site Examples

DrawLine ProgramDrawLine Program

Page 32: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 32Web site Examples

Memory-Mapped GraphicsMemory-Mapped Graphics

• Binary values are written to video RAM• video adapter must use standard address

• Very fast performance• no BIOS or DOS routines to get in the way

Page 33: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 33Web site Examples

Memory-Mapped GraphicsMemory-Mapped Graphics

Page 34: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 34Web site Examples

Mode 13h: 320 X 200, 256 ColorsMode 13h: 320 X 200, 256 Colors

• Mode 13h graphics (320 X 200, 256 colors)• Fairly easy to program

• read and write video adapter via IN and OUT instructions

• pixel-mapping scheme (1 byte per pixel)

Page 35: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 35Web site Examples

Example: Draw 10 Pixels on the ScreenExample: Draw 10 Pixels on the Screen

Page 36: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 36Web site Examples

Example: Draw 10 Pixels on the ScreenExample: Draw 10 Pixels on the Screen

Page 37: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 37Web site Examples

Example: Draw 10 Pixels on the ScreenExample: Draw 10 Pixels on the Screen

Page 38: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 38Web site Examples

Using video Text RamUsing video Text Ram

.model small

.codem:

mov ax,@datamov ds,axmov ah,0mov al,3int 10h

mov bx,0b800hmov es,bxmov byte ptr es:[0], 'A'mov byte ptr es:[1], 00001100bmov byte ptr es:[2], 'v'mov byte ptr es:[3], 00000100b

mov ah,4chint 21h

end m

Page 39: Assembly Language for Intel-Based Computers Chapter 15: BIOS-Level Programming (c) Pearson Education, 2006-2007. All rights reserved. You may modify and.

Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007. 39Web site Examples

Using video Text RamUsing video Text Ram

.model small

.386

.stack 10

.codepush ob800hpop esmov cx , 2000mov bx , 0Lop: mov word ptr es: [bx] , 0f20h

add bx , 2 loop lop

mov ah , 4chint 21hend


Recommended