sbx 发表于 2020-8-27 17:57:40

汇编实验14

本帖最后由 sbx 于 2020-8-27 18:00 编辑

实验14;编程:在屏幕中间显示当前的/年/月/日/时/秒
程序一:
assume cs:code
code segment
s1:db 'yy/mm/dd hh:mm:ss'
s2:db 9,8,7,4,2,0

start:mov ax,cs
mov ds,ax
mov si,offset s2
mov di,0
mov cx,6
s:
push cx
mov al,
out 70h,al                           ;将al送入端口70h
in al,71h                           ;从端口71h处读出单元内容

mov ah,al
mov cl,4
shr ah,cl            ;ah中为十位数码值
and al,00001111b             ;ah中为个位数码值

add ah,30h
add al,30h

mov bx,0b800h
mov es,bx
mov byte ptr es:,'/'
mov byte ptr es:,'/'
mov byte ptr es:,' '
mov byte ptr es:,':'
mov byte ptr es:,':'


cmp di,4
je n1
cmp di,10
je n1
cmp di,16
je n1
cmp di,22
je n1
cmp di,28
je n1
jmp short n2

n1:add di,2
n2:mov byte ptr es:,ah
add di,2
mov byte ptr es:,al
add di,2
inc si
pop cx
loop s

mov ax,4c00h
int 21h

code ends
end start

sbx 发表于 2020-9-16 11:31:48

assume cs:code,ds:data
data segment
db 'yy/mm/dd hh:mm:ss'
db 9,8,7,4,2,0
data ends

code segment
start:
mov ax,data
mov ds,ax
mov si,17
mov di,0

mov cx,6
s:push cx

mov al,
out 70h,al
in al,71h

mov ah,al
mov cl,4
shr ah,cl
and al,00001111b

add ah,30h
add al,30h
mov ,ah
mov ,al

inc si
add di,3

pop cx
loop s

mov si,0

mov ax,0b800h
mov es,ax
mov di,12*160+32*2

mov cx,17
s1:mov al,
mov es:,al
inc si
add di,2
loop s1

mov ax,4c00h
int 21h

code ends
end start

sbx 发表于 2020-9-16 11:41:21

assume cs:code,ds:data
data segment
db 'yy/mm/dd hh:mm:ss','$'
db 9,8,7,4,2,0
data ends

code segment
start:
mov ax,data
mov ds,ax
mov si,18
mov di,0

mov cx,6
s:push cx

mov al,
out 70h,al
in al,71h

mov ah,al
mov cl,4
shr ah,cl
and al,00001111b

add ah,30h
add al,30h
mov ,ah
mov ,al

inc si
add di,3

pop cx
loop s

mov ah,2
mov bh,0
mov dh,12
mov dl,32
int 10h

mov dx,0
mov ah,9
int 21h

mov ax,4c00h
int 21h

code ends
end start

sbx 发表于 2020-9-17 21:18:10

assume cs:code,ds:data
data segment
time db 'yy/mm/dd hh:mm:ss','$'
cmos db 9,8,7,4,2,0
data ends

code segment
start:
mov ax,data
mov ds,ax

mov si,0
mov di,0

mov cx,6
s:push cx

mov al,cmos
out 70h,al      ;将al送入地址端口70h

in al,71h         ;从数据端口71h处读出单元内容

;al分成两个表示BCD码值的数据al、ah
mov ah,al
mov cl,4         ;右移4位
shr ah,cl          ;十位的BCD码
and al,00001111b   ;个位的BCD码

add ah,30h         ;BCD码+30h=10进制数对应的ASCII码
add al,30h
mov time,ah    ;ASCII码写入time段
mov time,al;ASCII码写入time段

inc si
add di,3

pop cx
loop s

;名称:BIOS中断(int 10h)

;功能:(ah)=2置光标到屏幕指定位置、(ah)=9在光标位置显示字符

;参数:(al)=字符、(bh)=页数、(dh)=行号、(dl)=例号

;      (bl)=颜色属性、(cx)=字符重复个数

mov ah,2
mov bh,0
mov dh,12
mov dl,32
int 10h
;名称:DOS中断(int 21h)

;功能:(ah)=9显示用'$'结束的字符串、(ah)=4ch程序返回

;参数:ds:dx指向字符串、(al)=返回值

mov dx,offset time
mov ah,9
int 21h

;结束
mov ax,4c00h
int 21h

code ends
end start
页: [1]
查看完整版本: 汇编实验14