资源描述
实验四 系统功能调用
一、实验目的:
1掌握DOS系统功能调用的方法,验证常用的系统功能调用的功能。
2学习利用系统功能调用进行程序设计。
二、实验内容:
1、 系统功能调用的方法:
(1)传送入口参数到指定寄存器中;
(2)功能号送入AH寄存器中;
(3)INT 21H。
例如:实现从键盘输入单字符:
MOV AH,1
INT 21H …;结果在AL中
学会使用下列常用的系统功能调用,并逐一验证它们的功能:
(1)键盘输入单字符(1号系统功能调用);
(2)键盘输入字符串(0AH号系统功能调用);
(3)输出单字符(2号系统功能调用);
(4)输出字符串(9号系统功能调用);
(5)无回显键盘输入单字符(8号系统功能调用);
(6)返回操作系统(4CH号系统功能调用)。
2、 编制一段完整的程序,实现下列功能:
从键盘输入一串大写字母,将其转换为小写字母并在屏幕上显示出来。
(提示:使用0AH和9号系统功能调用)。
三、实验步骤:
1、编制程序;
2、编译程序;
3、连接程序;
4、调试程序;
5、运行程序并察看结果。
四、实验程序设计:
例1:系统功能调用
sta segment stack
s1 dw 100 dup(?)
sta ends
data segment
buf db 20
db ?
db 20 dup(?)
db '$'
data ends
code segment
assume cs:code,ds:data
org 100h
start proc far
push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
;no.1 dos system function call,input single character from keyboard
mov ah,1
int 21h
;no.2 dos system function call,output single character
mov dl,al
mov ah,2
int 21h
;CR and LF
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
;no.0ah dos system function call, input string from keyboard
mov dx,offset buf
mov ah,0ah
int 21h
;CR and LF
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
;no.9 dos system function call,output string to keyboard
mov dx,offset buf+2
mov ah,9
int 21h
;CR and LF
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
;no.8 dos system function call,input single character from keyboard but not display on the screen
mov ah,8
int 21h
;no.2 dos system function call,output single character
mov dl,al
mov ah,2
int 21h
;to pause program execution for us to observe the result
mov ah,1
int 21h
;no.4ch dos system function call,return operating system
mov ah,4ch
int 21h
start endp
code ends
end start
例2:从键盘输入一串大写字母,将其转换为小写字母并在屏幕上显示出来。
sta segment stack
s1 dw 100 dup(?)
sta ends
data segment
buf db 20
db ?
db 20 dup(?)
db '$'
data ends
code segment
assume cs:code,ds:data
org 100h
start proc far
push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
mov dx,offset buf
mov ah,0ah
int 21h
;CR and LF
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
mov cx,19
lea si,buf+2
lp: mov bl,[si]
add bl,20h
mov [si],bl
inc si
loop lp
mov dx,offset buf+2
mov ah,9
int 21h
mov ah,1
int 21h
ret
start endp
code ends
end start
五:实验结果
1、程序1运行结果:
AA
ABCDEFGHIJKLMNOPQRS
ABCDEFGHIJKLMNOPQRS
T
2、程序2运行结果:
ABCDEFGHIJKLMNOPQRS
Abcdefghijklmnopqrs
6
展开阅读全文