实验14的函数实现
关于实验14,用年/月/日 时:分:秒格式显示问题,本人用了函数的实现方式,感觉思路更清晰些,现分享如下:assume cs:code
data segment
db 9,8,7,4,2,0 ;把日期在CMOS RAM中的存储单元作为本程序数据段
data ends
code segment
start: mov ax,data
mov ds,ax
mov si,0
mov bx,160*10+12*2 ;指向显示地址的起始偏移地址
mov di,0 ;相对bx的地址偏移量
mov cx,3 ;前三次循环,取出年月日,中间用'/'隔开
lp1: call lpdata ;函数lpdata用来取出数据段数据,并转化为ASCII码
call store ;函数store用来在显示段存储要显示的数据
call signed1 ;函数signed1用来设置日期间的'/'
add di,2
inc si
loop lp1
sub di,2
mov dl,' ' ;把日期后的第三个'/'用''代替
mov es:,dl
mov es:.1,0
add di,2
mov cx,3 ;这3次循环用来取出时间数据,并转化为ASCII码
lp2: call lpdata
call store
call signed2 ;signed2用来设置时间间的':'
add di,2
inc si
loop lp2
sub di,2
mov dl,'' ;把显示时间的最后一个':'用''代替
mov es:,dl
mov es:.1,0
mov ax,4c00h
int 21h
lpdata: push cx
mov al,ds:
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
pop cx
ret
store: push dx
mov dx,0b800h
mov es,dx
mov es:,ah
mov es:.1,2
add di,2
mov es:,al
mov es:.1,2
pop dx
ret
signed1: add di,2
mov dl,'/'
mov es:,dl
mov es:.1,2
ret
signed2: add di,2
mov dl,':'
mov es:,dl
mov es:.1,2
ret
mov ax,4c00h
int 21h
code ends
end start
It looks like you've shared an assembly language program that retrieves and displays the current date and time in the format `YYYY/MM/DD HH:MM:SS`. Could you clarify what specific help you need with this code? Are you looking for debugging assistance, optimization suggestions, or an explanation of certain parts?
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
页:
[1]