Sie sind auf Seite 1von 20

Assembly language Program

DOS Functions

DOS Service
In assembly language DOS functions and interrupts are used for input/output services. An interrupt occurs when any currently executing program is disturbed (interrupted). Interrupts are generated for a variety of reasons, usually related to peripheral devices such as keyboard, disk drive or printer. The Intel 8086 microprocessor recognizes two types of interrupts; hardware and software.
Hardware interrupt is generated when a peripheral device needs attention from microprocessor. A software interrupt is a call to subroutine located in the operating system, usually an input-output routine. i.e. a software interrupt calls a built-in subroutine from the operating system usually DOS for input and output operations.

INT 21H: DOS service


This service has many functions. The function number of the service is to be loaded in register AH and the other registers are loaded with the data as required before the interrupt call.

DOS Service INT 21H


Func no. Description 00H 01H Terminate the current program: INT 21H, function 4CH is used instead Console input with echo: wait for a character from the standard input device. The character is returned in AL and echoed. Respond to CTRL+BREAK. Character output: Send the character in DL to the standard output device.

02H

05H
06H

Printer output: Send the character in DL to the parallel printer port.


Direct console input-output: Reads the character in AL if DL=0FFH else displays character at DL to the standard output device. Control characters are not filtered. Console input: Wait for a character from the standard input device. The character is returned in AL, but not echoed. It does not respond to CTRL+BREAK

07H

DOS Service INT 21H


08H Console input without echo: Wait for a character from the standard input device. The character is returned in AL, but not echoed. Respond to CTRL+BREAK. String output: Send a string of characters to the standard output device until $ character is reached. DX contains the offset address of the string. Read string: Read characters from the standard input device. DX points a location whose first byte gives the max characters allowed to enter, the next byte reserved to store the actual no of characters entered and the rest space to store the entered characters. Check keyboard Status: Returns FFH in AL if an input character is available in the keyboard buffer else returns 00Hin AL

09H 0AH

0BH

OCH
4CH

Clear key board buffer and invoke input functions: The input functions are stored in AL and other registers should hold the values as required.
Return control to operating system (stop program).

INT 21H/AH=01H
Read character from standard input, with echo, result is stored in AL. If there is no character in the keyboard buffer, the function waits until any key is pressed. Example:
MOV AH, 01H INT 21H

INT 21H/AH=02H
Write character to standard output. Entry: DL = character to write, after execution AL= DL. Example:
MOV AH, 02H MOV DL, a INT 21H

INT 21H/AH=09H
Output a string at DS:DX. String must be terminated by $. Example:
ORG 100H MOV DX, OFFSET MSG MOV AH, 09H INT 21H RET MSG DB hellow world $

INT 21H/AH=0AH
Input of a string to DS:DX, first byte is buffer size, second byte is number of chars actually read. This function does not add $ in the end of string. To print using INT 21H/AH=09H, you must set dollar character at the end of it and start printing from address DS:DX + 2 This function does not allow to enter more character than the specified buffer size.

INT 21H/AH=0AH
Example:
Org 100h MOV DX, OFFSET BUFFER MOV AH, 0AH INT 21H JMP PRINT BUFFER DB 10,?, 10 DUP( ) PRINT: XOR BX, BX MOV BL, BUFFER[1] MOV BUFFER*BX=2+, $ MOV DX, OFFSET BUFFER+2 MOV AH, 09H INT 21H RET

INT 21H/AH=4CH
Return control to the operating system (stop program). Example:
MOV AH, 4CH INT 21H

BIOS Function Calls


In addition to DOS function call INT 21H, some other BIOS functions calls are useful in controlling the I/O environment of the computer. Unlike INT 21H, which exists in the DOS program, the BIOS functions are found stored in the system and video BIOS ROMs. These BIOS ROM functions directly control the I/O devices with or without DOS loaded into a system

INT 10H
The INT 10H BIOS interrupt is often called video service interrupt. It directly controls the video display in a system. The INT 10H instruction uses register AH to select the video service provided by the interrupt. The video BIOS ROM is located on the video board and varies from one video card to another.

INT 10H/AH=00H
Set video mode. Input:
AL = desired video mode Supported video modes are:
00h text mode: 40x25. 16 colors. 8 pages. 03h text mode. 80x25. 16 colors. 8 pages. 13h graphical mode. 40x25. 256 colors. 320x200 pixels. 1 page.

Example:
MOV AL, 13H MOV AH, 00H INT 10H

INT 10H/ AH=01H


Set text-mode cursor shape. Input:
CH = cursor start line (bit 0-4) and option (bits 5-7). CL = bottom cursor line (bit 0-4). When bit 5 of CH is set to 0, the cursor is visible. When bit 5 is 1, the cursor is invisible. Hide blinking text cursor: MOV CH, 32 MOV AH, 01H INT 10H

INT 10H/ AH=01H


Show standard blinking text cursor:
MOV CH, 06H MOV CL, 07H MOV AH, 01H INT 10H

Show box-shaped blinking text cursor:


MOV CH, 00H MOV CL, 07H MOV AH, 01H INT 10H Note: Some bioses required CL to be >=7 otherwise wrong cursor shapes are displayed.

INT 10H/ AH=02H


Set cursor position Input:
DH=row DL= column BH= page number (0.7)

Example:
MOV DH, 10H MOV DL, 20H MOV BH, 0H MOV AH, 2H INT 10H

INT 10H/ AH=06H INT 1OH/AH=07H


INT 10H/ AH=06H: scroll up window. INT 10H/AH= 07H: scroll down window. Input:
AL = number of lines by which to scroll (00 = clear entire window). BH = attribute used to write blank lines at bottom of window. CH, CL = row, column of windows upper left corner. DH, DL = row, column of windows lower right corner.

INT 10H/ AH = 08H


Read character and attribute at cursor position. Input:
BH = page number.

Return:
AH = attribute AL = character

INT 10H/ AH = 0CH


Change color for a single pixel. Input:
AL = pixel color. CX = column. DX = row.

Example:
MOV AL, 13H MOV AH, 0 INT 10H ; set graphics video mode MOV AL, 1100B MOV CX, 10H MOV DX, 20H MOV AH, 0CH INT 10h ; set pixel

Das könnte Ihnen auch gefallen