Professional Documents
Culture Documents
8/31/2012
the Processors waited an entire second between each key stroke for the person to type another key .
This process was such a tremendous waste of time that designers developed
while the keyboard operator is thinking about what key to type next.
8/31/2012
some very useful functions, such as displaying data to the monitor, reading data from keyboard, etc.
They are used by identifying the interrupt option
Introduction
4
SOFTWARE INTERRUPT:
The 8086 INT instruction can be used to cause the 8086 to do any one of 256 possible interrupt types.
The desired type is specified as part of the instruction. Software interrupts produced by the INT instructions have many uses.
8/31/2012
INT Instruction
5
The term type in the instruction format refers to a number between 0 and 255 which identifies the interrupt. When an 8086 executes an INT instruction.
It will:
1. 2. 3.
Decrement the stack pointer by 2 and push the flags onto the stack. Decrement the stack pointer by 2 and push the contents of CS onto the stack. Decrement the stack pointer by 2 and push the offset of the next instruction after the INT
Get a new value for IP from an absolute memory address of 4 times the type specified in the instruction. For an INT 8 instruction. For example, the new IP will be read from address 00020H.
5.
Get a new value for CS from an absolute memory address of 4 times the type specified in
the instruction plus 2. For an INT 8 instruction, for example, the new value of CS will be read from address 00022H.
6.
performed.
8/31/2012
INT 21h / AH=1 - 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, 1 int 21h
8/31/2012
INT 21h / AH=5 - output character to printer. example: mov ah, 5 mov dl, 'a' int 21h
INT 21h / AH=7 - character input without echo to AL. example: mov ah, 7 int 21h INT 21h / AH=9 - output of a string at DS:DX. String must be terminated by '$'. example: msg db "hello world $ .code mov ax,@data mov ds,ax mov dx,offset msg mov ah,9 int 21h ret
8/31/2012
INT 21h / AH=0Ah - input of a string to DS:DX, Example: mov ax,@data mov ds,ax mov ah,0Ah int 21h
INT 21h / AH=25h - set interrupt vector; input: AL = interrupt number. DS:DX -> new interrupt handler. INT 21h / AH=2Ah - get system date; return: CX = year (1980-2099). DH = month. DL = day. AL = day of week (00h=Sunday)
8/31/2012
8/31/2012
INT 21h/3Dh;Open Existing file INT 21h/3Eh;Close file INT 21h/3Fh;Read from File INT 21h/40h;Write to file
8/31/2012
Example Programs
12
CHARACTER IN THE OUTPUT .model small .stack 100h .code mov ax, @data mov ds, ax mov ah, 1h ; keyboard input subprogram int 21h ; read character into al mov dl, al ; copy character to dl mov ah, 2h ; character output subprogram int 21h ; display character in dl end
8/31/2012
Example Programs
INPUT THE STRING:
13
.model small .stack 100h .code mov ax, @data mov ds , ax mov ah,0Ah int 21h end
THE OUTPUT .model small .data msg db "hello world $" .stack 100h .code mov ax, @data mov ds, ax mov dx, offset msg mov ah,9 int 21h ret end
8/31/2012
Example Programs
GET SYSTEM DATE AND
14
TIME:
// DATE:
.model small .stack 100h .code mov ax, @data mov ds, ax mov ah, 2Ah; int 21h ; end
//TIME:
.model small .stack 100h .code mov ax,@data mov ds,ax mov ah, 2Ch; int 21h ; end
8/31/2012
8/31/2012
INT 10h instruction is used for the video mode. Even this INT instruction has many operations that
AH = 0H AL = Video Mode.
8/31/2012
INT 10H/00H; set video mode INT 10H/01H; set cursor size INT 10H/02H; set cursor position INT 10H/03H; return cursor status
8/31/2012
position.
input: AL = character to display. BH = page number. BL = attribute. CX = number of times to write character.
INT 10h / AH = 0Ah - write character only at cursor position.
8/31/2012
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, 10 mov dx, 20 mov ah, 0ch int 10h ; set pixel. INT 10h / AH = 0Dh - get color of a single pixel.
input: CX = column. DX = row. output: AL = pixel color
8/31/2012
input: AL = write mode: bit 0: update cursor after writing; bit 1: string contains attributes. BH = page number. BL = attribute if string contains only characters (bit 1 of AL is zero). CX = number of characters in string (attributes are not counted). DL,DH = column, row at which to start writing. ES:BP points to string to be printed.
8/31/2012
8/31/2012
22
THANK YOU
8/31/2012