回忆汇编

好久没有理会了,今天找本书随便瞅瞅。

李浪,熊江,齐忠。汇编语言及应用教程。华中科技大学出版社

新书,是我的喜欢,呵呵~

P216电子钟程序的实现

使用到的编辑器:Easmedit.exe

使用到的编译器:masm5.0

;----------------------------------------------------------------------
;Program: Timer
;Created by:  XHP
;Finished Date & Time: 2011-8-7
;----------------------------------------------------------------------


data segment
 buf1 db 'current time is : $'
 buf2 db 10
 db 10 dup(?)
data ends

stack segment stack
 db 100 dup(?)
stack ends

code segment
assume cs:code,ds:data,ss:stack
 cursor macro row,clm
  mov ah,2
  mov bh,0
  mov dh,row
  mov dl,clm
  int 10h
  endm
 win macro rowl,clml,rowr,clmr,color
  mov ah,6
  mov al,0
  mov ch,rowl
  mov cl,clml
  mov dh,rowr
  mov dl,clmr
  mov bh,color
  int 10h
  endm
 ascbcd macro reg
  inc bx
  inc bx
  mov reg,[bx]
  mov cl,4
  shl reg,cl
  inc bx
  mov al,[bx]
  and al,0fh
  or reg,al
  endm
 bcdasc macro reg
  inc bx
  inc bx
  mov al,reg
  mov cl,4
  shr al,cl
  or al,30h
  mov [bx],al
  inc bx
  mov al,reg
  and al,0fh
  or al,30h
  mov [bx],al
  endm
 incbcd macro reg,count
  mov al,reg
  inc al
  daa
  mov reg,al
  cmp al,count
  jnz dispy
  mov reg,0
  endm
 strdspy macro adrs
  lea dx,adrs
  mov ah,9
  int 21h
  endm
 clock proc far
 start: push ds
  mov ax,0
  push ax
  mov ax,data
  mov ds,ax
  win 0,0,24,79,7
  win 9,28,15,52,01010111B
  cursor 11,32
  strdspy buf1
  cursor 13,36
  lea dx,buf2
  mov ah,0ah
  int 21h
  lea bx,buf2
  ascbcd ch
  ascbcd dh
  ascbcd dl
 timer:call dely
  incbcd DL,60H
  incbcd DH,60H
  incbcd CH,24H
 dispy:lea bx,buf2
  bcdasc ch
  bcdasc dh
  bcdasc dl
  inc bx
  mov al,'$'
  mov [bx],al
  push dx
  cursor 13,36
  strdspy buf2
  pop dx
  jmp timer
  dely proc
  push cx
  push ax
  mov ax,3fffh
 x1: mov cx,0fffh
 x2: dec cx
  jne x2
  dec ax
  jne x1
  pop ax
  pop cx
  ret
 dely endp
 clock endp
code ends
end start

1、masm.exe 将*.asm生成*.obj、*.list、*.orf

2、link.exe 将.obj生成*.exe、*.map、*.lib

3、*.exe就是可以运行的

 

上述代码运行结果:

输入当前时间

看到电子时钟,时:分:秒的格式

 

貌似延时不对,扩大了倍数

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值