《汇编语言》第二版,就是王爽写的那一本,里面的实验十四,要显示一个钟表,但是怎么让表走起来?
一下是我写的中断,中断名7dhassumecs:codecodesegmentstart:movax,csmovds,axmovsi,offsettimemovax,0m...
一下是我写的中断,中断名7dh
assume cs:code
code segment
start: mov ax,cs
mov ds,ax
mov si,offset time
mov ax,0
mov es,ax
mov di,200h
mov cx,offset timend-offset time
cld
rep movsb
mov ax,0
mov es,ax
mov word ptr es:[125*4],200h
mov word ptr es:[125*4+2],0
mov ax,4c00h
int 21h
time: mov bx,0b80ah
mov es,bx
mov bp,3fh
mov ch,9h
ymd: mov si,bp
add si,bp
mov al,ch
out 70h,al
in al,71h
mov ah,al
mov cl,4h
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[si],ah
mov byte ptr es:[si+2],al
mov bl,7h
cmp ch,bl
je blank
mov byte ptr es:[si+4],2fh
sub ch,1
add bp,3
jmp ymd
blank: mov byte ptr es:[si+4],20h
mov bp,48h
mov ch,4h
hms: mov si,bp
add si,bp
mov al,ch
out 70h,al
in al,71h
mov ah,al
mov cl,4h
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[si],ah
mov byte ptr es:[si+2],al
mov bl,0
cmp ch,bl
je bre
mov byte ptr es:[si+4],3ah
sub ch,2
add bp,3
jmp hms
bre: iret
timend: nop
code ends
end start
如果让表走起来可以弄个死循环,循环调用这个中断,CPU占用率达到100%,老师说大约只占用CPU的1%就可以实现,请问高手该怎么做? 展开
assume cs:code
code segment
start: mov ax,cs
mov ds,ax
mov si,offset time
mov ax,0
mov es,ax
mov di,200h
mov cx,offset timend-offset time
cld
rep movsb
mov ax,0
mov es,ax
mov word ptr es:[125*4],200h
mov word ptr es:[125*4+2],0
mov ax,4c00h
int 21h
time: mov bx,0b80ah
mov es,bx
mov bp,3fh
mov ch,9h
ymd: mov si,bp
add si,bp
mov al,ch
out 70h,al
in al,71h
mov ah,al
mov cl,4h
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[si],ah
mov byte ptr es:[si+2],al
mov bl,7h
cmp ch,bl
je blank
mov byte ptr es:[si+4],2fh
sub ch,1
add bp,3
jmp ymd
blank: mov byte ptr es:[si+4],20h
mov bp,48h
mov ch,4h
hms: mov si,bp
add si,bp
mov al,ch
out 70h,al
in al,71h
mov ah,al
mov cl,4h
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[si],ah
mov byte ptr es:[si+2],al
mov bl,0
cmp ch,bl
je bre
mov byte ptr es:[si+4],3ah
sub ch,2
add bp,3
jmp hms
bre: iret
timend: nop
code ends
end start
如果让表走起来可以弄个死循环,循环调用这个中断,CPU占用率达到100%,老师说大约只占用CPU的1%就可以实现,请问高手该怎么做? 展开
1个回答
展开全部
编程:以“年/月/日 时:分:秒”的格式,显示当前的日期、时间。
assume cs:code
code segment
s:db 9,8,7,4,2,0
start:mov ax,cs
mov ds,ax
mov si,offset s ;ds:si指向标号S
mov ax,0b800h
mov es,ax ;es存放显示缓冲区段地址
mov di,0
lo:mov cx,3
day:push cx
mov al,ds:[si]
out 70h,al
in al,71h ;al存放日期
mov cl,4
mov ah,al
shr ah,cl
and al,00001111b ;将高位和低位的数据放在ah,al
add ah,30h
add al,30h
mov es:[12*160+30*2+di],ah ;日期高10位放到显存
mov es:[12*160+30*2+di+2],al;日期低10位放到显存
mov byte ptr es:[12*160+30*2+di+4],'/'
inc si
add di,6
pop cx
loop day
sub di,2
mov byte ptr es:[12*160+30*2+di],' ' ;去除最后的符号
add di,2
mov cx,3
time:push cx
mov al,ds:[si]
out 70h,al
in al,71h ;al存放日期
mov cl,4
mov ah,al
shr ah,cl
and al,00001111b ;将高位和低位的数据放在ah,al
add ah,30h
add al,30h
mov es:[12*160+30*2+di],ah ;日期高10位放到显存
mov es:[12*160+30*2+di+2],al;日期低10位放到显存
mov byte ptr es:[12*160+30*2+di+4],':'
inc si
add di,6
pop cx
loop time
sub di,2
mov byte ptr es:[12*160+30*2+di],' ' ;去除最后的符号
mov si,0
mov di,0
in al,60h
cmp al,10h
je quit
jmp lo ;上四句为动态显示时间
quit:mov ax,4c00h
int 21h
code ends
end start
assume cs:code
code segment
s:db 9,8,7,4,2,0
start:mov ax,cs
mov ds,ax
mov si,offset s ;ds:si指向标号S
mov ax,0b800h
mov es,ax ;es存放显示缓冲区段地址
mov di,0
lo:mov cx,3
day:push cx
mov al,ds:[si]
out 70h,al
in al,71h ;al存放日期
mov cl,4
mov ah,al
shr ah,cl
and al,00001111b ;将高位和低位的数据放在ah,al
add ah,30h
add al,30h
mov es:[12*160+30*2+di],ah ;日期高10位放到显存
mov es:[12*160+30*2+di+2],al;日期低10位放到显存
mov byte ptr es:[12*160+30*2+di+4],'/'
inc si
add di,6
pop cx
loop day
sub di,2
mov byte ptr es:[12*160+30*2+di],' ' ;去除最后的符号
add di,2
mov cx,3
time:push cx
mov al,ds:[si]
out 70h,al
in al,71h ;al存放日期
mov cl,4
mov ah,al
shr ah,cl
and al,00001111b ;将高位和低位的数据放在ah,al
add ah,30h
add al,30h
mov es:[12*160+30*2+di],ah ;日期高10位放到显存
mov es:[12*160+30*2+di+2],al;日期低10位放到显存
mov byte ptr es:[12*160+30*2+di+4],':'
inc si
add di,6
pop cx
loop time
sub di,2
mov byte ptr es:[12*160+30*2+di],' ' ;去除最后的符号
mov si,0
mov di,0
in al,60h
cmp al,10h
je quit
jmp lo ;上四句为动态显示时间
quit:mov ax,4c00h
int 21h
code ends
end start
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询