找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 2303|回复: 0

【DOS编程】简单显示当前日期、时间

[复制链接]

37

主题

153

回帖

1997

积分

用户组: 超级版主

UID
8
精华
1
威望
14 点
宅币
1759 个
贡献
24 次
宅之契约
0 份
在线时间
279 小时
注册时间
2014-1-27
发表于 2014-12-4 19:59:27 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×

  1. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;                                                                                    ;;
  2. ;;  INT 7CH , A simple code used to display the current time&data.                  ;;
  3. ;;                                                    BY 13*0217  2014-12-4         ;;
  4. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
  5. assume cs:codesg

  6. codesg segment
  7.    
  8.      start:  mov ax,cs
  9.              mov ds,ax
  10.              mov si,offset do0
  11.              mov ax,0h
  12.              mov es,ax
  13.              mov di,200h
  14.              mov cx,offset do0ends - offset do0
  15.              cld
  16.              rep movsb
  17.              mov ax,0
  18.              mov es,ax
  19.              mov word ptr es:[7ch*4],200h
  20.              mov word ptr es:[7ch*4+2],0h
  21.              mov ax,4c00h
  22.              int 21h
  23. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;
  24. ;; The interrupt type code named 7ch,CPU could call its process.                     ;
  25. ;; The interrupt fuction maybe needs color.                                          ;                             
  26. ;; the time format:xx year-yy month-zz day && qq time-ww minute-ee second.           ;
  27. ;; It would be display the time information in the center of screen that we want do. ;
  28. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;
  29.        do0:  jmp short do0start
  30.              db 'yy/mm/dd tt:mm:ss ',0,0
  31.          s:  db 9,8,7,4,2,0
  32.   do0start:  mov ax,cs
  33.              mov ds,ax
  34.              mov si,202h
  35.              mov di,216h
  36.         _x:  mov cx,ds:[si]
  37.              jcxz ok
  38.              mov al,ds:[di]
  39.              out 70h,al
  40.              in  al,71h
  41.              mov ah,al
  42.              mov cl,4
  43.              shr ah,cl
  44.              and al,00001111b
  45.              add ah,30h
  46.              add al,30h
  47.              mov byte ptr ds:[si],ah
  48.              mov byte ptr ds:[si+1],al
  49.              add si,3h
  50.              inc di
  51.              jmp short _x
  52.         ok:  call show_str
  53.              iret
  54.   show_str:  mov ax,0b800h
  55.              mov es,ax
  56.              mov si,202h
  57.              sub di,di
  58.              mov dx,0c22h          ; The time would be displayed in the position.
  59.              mov al,0a0h
  60.              mul dh
  61.              add di,ax
  62.              mov al,2h
  63.              mul dl
  64.              add di,ax
  65.       _str:  mov cx,ds:[si]
  66.              jcxz ui
  67.              mov es:[di],cl
  68.              mov es:[di+1],bl
  69.              add di,2h
  70.              inc si
  71.              jmp short _str
  72.         ui:  ret  
  73.    do0ends:  nop

  74. codesg ends
  75. end start
复制代码

附上一段测试代码:


  1. assume cs:codesg

  2. codesg segment
  3.       
  4.      start:  mov ax,0003h
  5.              int 10h
  6.             mov bl,04h
  7.             int 7ch
  8.              mov ax,4c00h
  9.             int 21h
  10. codesg ends

  11. end start
复制代码

回复

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-3-29 15:59 , Processed in 0.043734 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表