• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >汇编语言 > (汇编源代码 )获取当前系统时间

(汇编源代码 )获取当前系统时间

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2017-06-28

匿名通过本文主要向大家介绍了汇编语言源程序代码,汇编语言源代码,汇编源代码,一元云购系统源代码,客户管理系统源代码等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div>

;==========================================
;A little assembly app that shows the current date and time.
;It can be done a lot easier, but this way you will
;see how to do some basic memory manipulation, and how to use 'variables'.
;==========================================
.model small
.stack
  ;===========================
;Data segment starts here
;===========================
.data
date_strdb"Current date is: yyyy-mm-dd", 0Ah, 0Dh, "$"
time_strdb"Current time is: hh.mm.ss:xx", 0Ah, 0Dh, "$"
min_sizedw?
padd_chrdb ?
;===========================
;Code segment starts here
;===========================
.code
mainproc
movax, seg @data ;First we get the data segment address
movds, ax ;and store it into ds
  mov[min_size], 02h ;Results should always be at least two digits
mov[padd_chr], '0' ;Use '0' as padding-character
  movah, 2Ah ;Then we call int 21h,2Ah, which will give
int21h ;us the current date
  leadi, date_str ;Then we load the address of the date_str string
adddi, 17 ;and set si to point at the first y in yyyy-...
movax, cx ;Next we mov cx to ax and
calltodec ;call todec
incdi ;We skip the '-' character...
  xorax, ax ;Then we empty ax
moval, dh ;And set the low-byte of ax to dh
calltodec
incdi ;Skip character in string...
  xorax, ax ;Empty ax
moval, dl ;Set low-byte to dl
calltodec ;Convert it to base10
leadi, time_str ;Now we load the time_str string
adddi, 17 ;And set the correct pointer offset
  movah, 2Ch ;And then we call int 21h,2Ch
int21h ;which will give us the current time
xorax, ax ;Empty ax
moval, ch ;Set low-byte to ch
calltodec ;Convert it to base10
incdi ;Skip character
  moval, cl ;Set low-byte to cl
calltodec ;Convert to base10
incdi ;Skip character
  moval, dh ;Set low-byte to dh
calltodec ;Convert to base10
incdi ;Skip character
  moval, dl ;Set low-byte to dl
calltodec ;Convert to base10
movdx, offset date_str;Now load offset of the date_str string into dx
callprint ;And print the (modified) string
  movdx, offset time_str;Load offset of the time_str string into dx
callprint ;And print the (modified) string
  movax, 4C00h ;Do a clean exit(error code=00)
int21h
  ;===================================================================
;todec - converts the contents of ax into base10 ascii character(s)
;    of length bx
;    min_size defines minimum length of result, and padd_char
;    defines the padding character.
;The result(s) are stored at ds:di
;===================================================================
todecproc
pushax ;Save all registers
pushbx
pushcx
pushdx
xorcx,cx ;Empty the POP counter
movbx,10 ;Base divisor
decloop: 
xordx,dx ;Set the high 16-bits to 0
divbx ;Preform division(dx=remainder, ax=quotient)
inccx ;Increase the counter
pushdx ;and save the remainder
cmpax,0 ;If the quotient != 0
jnzdecloop ;then get one more number
movbx, [min_size] ;Load min_size value into bx
movdl, [padd_chr] ;Load padd_chr value into dl
padd_result:
cmpcx, bx ;Is cx >= min_size?
jgepoploop ;If so, proceed
  movbyte ptr ds:[di], dl;Else padd with padd_chr
incdi ;and increase string pointer
decbx ;decrease bx
jmppadd_result ;and test for more padding
  poploop:
popdx ;Get the number of the stack
adddl,'0' ;and add '0' to it
movbyte ptr ds:[di], dl;Modify the string at ds:di
incdi ;Increase the string pointer
deccx ;Decrease the loop counter
jnzpoploop
popdx ;Restore all registers
popcx
popbx
popax
ret  ;And return from call
todecendp
;===========================================================
;print - prints the string pointed to by dx using int 21h,09
;===========================================================
printproc
pushax ;Save ax
pushds ;and ds onto the stack
  movax, @data ;Then get the address of the data segment
movds, ax ;and store it into ds
movax, 0900h 
int21h ;and then print the message pointed to by dx
popds ;Retrieve ds
popax ;and ax from stack
  ret
printendp
  mainendp
endmain

</div> </div> </div> </div>
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 汇编源代码之一个有趣的打字游戏
  • 汇编源代码之获得操作系统版本
  • 汇编源代码之简单密码输入
  • (汇编源代码 )获取当前系统时间
  • (汇编源代码 )简单的取系统时间小程序

相关文章

  • 2017-06-17中断传送方式
  • 2017-06-17标志位设置指令
  • 2017-06-17伪指令
  • 2017-06-17伪操作
  • 2017-06-17打印I/O
  • 2017-06-28汇编教程之树型视图控件
  • 2017-06-28汇编教程:多文档界面(MDI)
  • 2017-06-28树型视图控件详解
  • 2017-06-28汇编语言的艺术-准备工作(四)
  • 2017-06-28列表视图控件介绍

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 计算机中数和字符的表示
    • 程序开始和结束伪操作
    • PE文件结构剖析
    • 汇编教程之通用控件
    • 汇编程序功能
    • 事件对象在多线程编程中的应用
    • 通用控件详解
    • 汇编教程之窗口子类化
    • 移位指令在汇编Win32消息处理中的一些问题
    • 加法指令

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有