ch6_1 Interrupt and external device operation

1. Direct custom table

1.1 Shift instruction

1.2 Operate video memory data

1.3 Labels describing memory cells

1.4 Data Direct Addressing Table

1.5 Direct Addressing Table for Code

2. Inner interruption

2.1 Interrupt and its processing

2.2 Write interrupt handler

2.3 Single-step interrupt

2.4 Interrupt caused by int instruction

2.5 BIOS, DOS interrupt handling

2.5.1 BIOS - Basic Input Output System

insert image description here

BIOS is a set of programs stored in the ROM of the system board
; capacity: 8KB
; address: starting from FE000H

The main content in the BIOS
(1) hardware system detection and initialization program
(2) interrupt routines for external interrupts and internal interrupts
(3) interrupt routines for I/O operations on hardware devices
(4) other and hardware System-dependent interrupt routines

Using BIOS function calls, programmers do not need to understand the details of hardware operations
, but can directly use instructions to set parameters and interrupt calls to BIOS routines
to complete related work!

Using BIOS function calls: (1) Convenient programming;
(2) Can write concise, readable, and easy-to-port programs.

2.5.2 Example of BIOS interrupt call

Task: Display 3 green 'a's with red background highlighting and flashing green on 5 rows and 12 columns of the screen

insert image description here
Use BIOS 10h interrupt
; when (ah)=2, call No. 2 subroutine of the 10h interrupt routine, and set the cursor position;
when (ah)=9, call No. 9 subroutine of the 10h interrupt routine, and set the cursor position position display character

assume cs:code
code segment
mov ah,2 ;置光标功能
mov bh,0 ;0页
mov dh,5 ;dh中放行号
mov dl,12 ;dl中放列号
int 10h
mov ah,9 ;显示字符功能
mov al,'a' ;字符
mov bl,11001010b;颜色属性
mov bh,0 ;0页
mov cx,3 ;字符重复个数
int 10h
mov ax,4c00h
int 21h
code ends
end

insert image description here

2.5.3 What are the BIOS interrupts and how to use them?

insert image description hereinsert image description here

2.5.4 DOS interrupt

insert image description here

2.5.5 Application of int 21HDOS interrupt routine

4ch function: program returns
; the function number is in ah, and the return result is stored in al
: usage:
mov ah,4ch
mov al,0
int 21h

insert image description here

:09h function: display character string at the cursor position
; ds:dx points to the character string to be displayed (end with '$')
: usage:
mov ah ,9
int 21h
: example: program to display characters in 5 lines and 12 columns of the screen string
"welcome to masm!"

assume cs:code
data segment
db 'Welcome to masm!','$'
data ends
code segment
start: mov ah,2 ; 置光标
mov bh,0 ;0页
mov dh,5 ; dh中放行号
mov dl,12 ; dl中放列号
int 10h
mov ax,data
mov ds,ax
mov dx,0 ;ds:dx指向字符串的首地址data:0
mov ah,9
int 21h
mov ax,4c00h
int 21h
code ends
end start

2.5.6 BIOS and DOS interrupt routine installation process

(1) Once the CPU is powered on, initialize (CS)=0FFFFH, (IP)=0, and automatically start program execution from FFFF:0 unit. There is a jump instruction at FFFF:0. After the CPU executes the instruction, it turns to
execute the hardware system detection and initialization program in the BIOS.

(2) The initialization program will establish the interrupt vector supported by the BIOS, that is, register the entry address of the interrupt routine provided by the BIOS in the interrupt vector table.

(3) After the hardware system detection and initialization are completed, call to int 19hboot the operating system. From then on, the computer will be controlled by the operating system.

(4) After DOS is started, in addition to completing other tasks, it also loads the interrupt routine provided by it into the memory, and establishes the corresponding interrupt vector

insert image description here

2.5.

2.5.

2.5.

insert image description here

Guess you like

Origin blog.csdn.net/chumingqian/article/details/132165866