+ -
当前位置:首页 → 问答吧 → 求解 王爽汇编实验14

求解 王爽汇编实验14

时间:2011-12-06

来源:互联网

用了一个简单的跳转,动态显示时间,但是CPU占用率过高,求简单解决办法assume cs:code 
data segment 
  db 9,8,7,4,2,0 
  db '/', '/ ',':', ':'
data ends 
code segment 
  start:mov ax,data 
  mov ds,ax 
  mov ax,0b800h 
  mov es,ax 
  mov si,0 
  mov di,120
  mov cx,6 
  s:mov al,[si] 
  out 70h,al 
  in al,71h 
  call s1
  mov es:[di],ah 
  mov es:[di+2],al 
  mov bl,[si+6] 
  mov es:[di+4],bl 
  inc si 
  add di,6 
  loop s 
  mov cx,1000
  push ax
  pop ax
   
   
  jmp start 
   
  quit:mov ax,4c00h 
  int 21h 

  s1:push cx 
  mov ah,al 
  mov cl,4 
  shr ah,cl 
  and al,00001111b 
  add ah,30h 
  add al,30h 
  pop cx 
  ret 
code ends 
end start 


作者: fengshien   发布时间: 2011-12-06

assume cs:code  
code segment 
  db 9,8,7,4,2,0 
  db '// :: ' 
  start:mov ax,cs 
  mov ds,ax 
  mov si,0 
  mov ax,0 
  mov di,0 
   
  s:mov al,ds:[si] 
  mov dl,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 bx,0b800h 
  mov es,bx 

  mov byte ptr es:[160*12+40*2+di],ah 
  mov ah,ds:[si+6] 
  mov byte ptr es:[160*12+40*2+2+di],al 
  mov byte ptr es:[160*12+40*2+2+2+di],ah 
  add di,6 
  inc si 
  cmp dl,bl 
  jne short s 
  je short send 
   
  send:nop 
  mov ax,4c00h 
  int 21h 
code ends 
end start

作者: x90386   发布时间: 2011-12-06

这样 时钟不是就不动了吗

作者: fengshien   发布时间: 2011-12-06

引用 1 楼 x90386 的回复:

assume cs:code
code segment
db 9,8,7,4,2,0
db '// :: '
start:mov ax,cs
mov ds,ax
mov si,0
mov ax,0
m……

这不就不动了吗

作者: fengshien   发布时间: 2011-12-06

还要动态显示……
好吧,我帮你找了个别人写的……

Assembly code
assume  cs:code 
data segment 
        db 9,8,7,4,2,0 
data ends 

code segment 

start:  mov ax,data 
        mov ds,ax 
        mov si,0 

        mov ax,0b800h 
        mov es,ax 
        call next 
        mov di,0 
         

s:      mov al,[si] 
        out 70h,al 
        in al,71h 

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

        add ah,30h 
        add al,30h 

        mov es:[13*0a0h+30+di],ah 
        add di,2 
        mov es:[13*0a0h+30+di],al 
        add di,4 
        cmp byte ptr ds:[si],0 
        jz repeat 
        inc si 
        jmp short s 

next:                                             子程序 
        mov di,4 
        mov byte ptr es:[13*0a0h+30+di],'/'    
        add di,6 
        mov byte ptr es:[13*0a0h+30+di],'/' 
        add di,12 
        mov byte ptr es:[13*0a0h+30+di],':' 
        add di,6 
        mov byte ptr es:[13*0a0h+30+di],':' 
        ret 

repeat: mov di,0 
        mov si,0 
        in al,60h 
        cmp al,10h 
        jnz s
        mov ax,4c00h   int 21h
code ends 
end start


小修改了下,按q退出。

作者: x90386   发布时间: 2011-12-06