汇编学习(九)8086汇编拾遗 (8)
端口:
从CPU的角度,简单来看,CPU将这些硬件设备进行了统一的编址。一些硬件被编进的地址就变成了对CPU 读取地址的接口。
端口的读写指令只有2条:
in: 从端口读入数据
out:从端口读出数据
注意这里只能使用AX 或 AL 来存放从端口读入的或从端口读出的数据。
assume cs:code code segment start: mov al,2 out 70h,al in al,71h mov al,2 out 70h,al mov al,0 out 71h,al mov ax,4c00h int 21h code ends end start
shr 和 shl 指令 逻辑左移,逻辑右移。 使用加法和位移指令计算 ax = ax*10
assume cs:code
code segment
start:
mov ax,2
shl ax,1
mov bx,ax
shl ax,1
shl ax,1
add ax,bx
mov ax,4c00h
int 21h
code ends
end start
显示当前的日期:
assume cs:code
data segment
time db 'yy/mm/dd hh:mm:ss$'
table db 9,8,7,4,2,0
data ends
code segment
start:
mov ax,data
mov ds,ax
mov si,offset table
mov di,offset time
mov cx,6
s:
push cx
mov al,ds:[si]
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
add al,00001111b
add ah,30h
add al,30h
mov ds:[di],ah
mov ds:[di+1],al
inc si
add di,3
pop cx
loop s
mov ah,0
mov bh,0
mov dh,10
mov dl,40
int 10h
mov dx,offset time
mov ah,9
int 21h
mov ax,4c00h
int 21h
code ends
end start
还没有评论,来说两句吧...