1 assume cs:code
2 ;安装程序,使用指令out和in指令
3 code segment
4 start:
5 mov ax,cs
6 mov ds,ax
7 mov si,offset sub1
8 mov ax,0020h
9 mov es,ax
10 mov di,0
11 mov cx,offset sub2 - offset sub1
12 cld
13 rep movsb ;复制程序
14
15 mov ax,0
16 mov es,ax
17 mov word ptr es:[7ch*4],200h
18 mov word ptr es:[7ch*4+2],0
19 mov ax,4c00h
20 int 21h ;入口地址附加
21 sub1:
22 out 70h,al ;向端口70h写入字节数据al
23 in al,71h ;向端口71h读入字节数据al
24
25 mov ah,al
26 mov cl,4
27 shr ah,cl ;高位BCD码
28 and al,00001111b ;低位BCD码
29
30 add ah,30h
31 add al,30h ;转化为ASCLL码
32
33 mov bx,0b800h
34 mov es,bx
35 mov byte ptr es:[12*160+40*2+di],ah
36 mov byte ptr es:[12*160+41*2+di],al ;向显示屏写入数据
37
38 add di,4 ;每次偏移+4
39 iret
40 sub2:
41 nop
42 code ends
43
44 end start
1 assume cs:code
2 ;测试程序
3 code segment
4 start:
5 mov di,0
6 mov al,9
7 int 7ch
8 mov byte ptr es:[12*160+40*2+di],'/'
9 add di,2
10 mov al,8
11 int 7ch
12 mov byte ptr es:[12*160+40*2+di],'/'
13 add di,2
14 mov al,7
15 int 7ch
16 mov byte ptr es:[12*160+40*2+di],' '
17 add di,2
18 mov al,4
19 int 7ch
20 mov byte ptr es:[12*160+40*2+di],':'
21 add di,2
22 mov al,2
23 int 7ch
24 mov byte ptr es:[12*160+40*2+di],':'
25 add di,2
26 mov al,0
27 int 7ch
28 mov ax,4c00h
29 int 21h
30 code ends
31
32 end start