这个是我写的 微机实验 数字钟 的代码,仅供参考。 ;simple calculagraph made by fanpei data segment m2 db 0 m1 db 0 s2 db 0 s1 db 0 addition_5 db 0 sub_count db 0 old_seg dw 0 old_off dw 0 ps db 62h,79h,20h,66h,61h,6eh,70h,65h,69h,21h,24h data ends stack_seg segment stack db 250 dup(0) stack_seg ends code segment assume cs:code,ds:data,ss:stack_seg main proc far mov ax,data mov ds,ax mov dx,offset ps mov ah,09h int 21h mov ah,0 int 16h call int_set mov ah,0 int 16h call int_repair mov ah,4ch int 21h main endp change_place proc near mov ah,02h mov bh,0 mov dh,5 mov dl,0 int 10h ret change_place endp int_set proc near cli push ds mov ah,35h mov al,1ch int 21h mov old_seg,es mov old_off,bx mov ax,seg myfunction mov ds,ax mov dx,offset myfunction mov ah,25h mov al,1ch int 21h pop ds sti ret int_set endp int_repair proc near cli mov ax,old_seg mov ds,ax mov dx,old_off mov ah,25h mov al,1ch int 21h sti ret int_repair endp add_minutes proc near;进位控制 mov ax,data mov ds,ax inc s1 cmp s1,10 jne proc_ends s1_equal_10: mov s1,0 inc s2 cmp s2,6 jne proc_ends s2_equal_6: mov s2,0 inc m1 cmp m1,10 jne proc_ends m1_equal_10: mov m1,0 inc m2 cmp m2,10 jne proc_ends m2_equal_6: mov m2,0 proc_ends: ret add_minutes endp print_minute proc near mov ax,data mov ds,ax add s1,48 add s2,48 add m1,48 add m2,48 mov ah,02h mov dl,m2 int 21h mov dl,m1 int 21h mov dl,':' int 21h mov dl,s2 int 21h mov dl,s1 int 21h sub s1,48 sub s2,48 sub m1,48 sub m2,48 ret print_minute endp myfunction proc near;1ch号中断替换函数 cli mov ax,data mov ds,ax inc addition_5 cmp addition_5,5 jne no_equal_5 equal_5: mov addition_5,0 jmp equal_5_2 no_equal_5: inc sub_count equal_5_2: cmp sub_count,18 jne int_1c_end mov sub_count,0 call add_minutes;时间进位 call change_place call print_minute int_1c_end: sti iret myfunction endp code ends end main