您的位置:逆风者 汇编技术 正文
原作者:www.upwinder.com 添加时间:2007-09-02 原文发表:2007-08-31 人气:32 来源:未知

本文章共2013字,分2页,当前第1页,快速翻页:
 

;==========================================
;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_str db "Current date is: yyyy-mm-dd", 0Ah, 0Dh, "$"
time_str db "Current time is: hh.mm.ss:xx", 0Ah, 0Dh, "$"
min_size dw ?
padd_chr db ?


;===========================
;Code segment starts here
;===========================
.code
main proc
mov ax, seg @data ;First we get the data segment address
mov ds, 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

mov ah, 2Ah ;Then we call int 21h,2Ah, which will give
int 21h ;us the current date

lea di, date_str ;Then we load the address of the date_str string
add di, 17 ;and set si to point at the first y in yyyy-...


mov ax, cx ;Next we mov cx to ax and
call todec ;call todec
inc di ;We skip the '-' character...

xor ax, ax ;Then we empty ax
mov al, dh ;And set the low-byte of ax to dh
call todec
inc di ;Skip character in string...

xor ax, ax ;Empty ax
mov al, dl ;Set low-byte to dl
call todec ;Convert it to base10


lea di, time_str ;Now we load the time_str string
add di, 17 ;And set the correct pointer offset

mov ah, 2Ch ;And then we call int 21h,2Ch
int 21h ;which will give us the current time


xor ax, ax ;Empty ax
mov al, ch ;Set low-byte to ch
call todec ;Convert it to base10
inc di ;Skip character

mov al, cl ;Set low-byte to cl
call todec ;Convert to base10
inc di ;Skip character

mov al, dh ;Set low-byte to dh
call todec ;Convert to base10
inc di ;Skip character

mov al, dl ;Set low-byte to dl
call todec ;Convert to base10


mov dx, offset date_str ;Now load offset of the date_str string into dx
call print ;And print the (modified) string

mov dx, offset time_str ;Load offset of the time_str string into dx
call print ;And print the (modified) string

mov ax, 4C00h ;Do a clean exit(error code=00)
int 21h

;===================================================================
;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
;===================================================================
todec proc
push ax ;Save all registers
push bx
push cx
push dx


xor cx,cx ;Empty the POP counter
mov bx,10 ;Base divisor
decloop:
xor dx,dx ;Set the high 16-bits to 0
div bx ;Preform division(dx=remainder, ax=quotient)
inc cx ;Increase the counter
push dx ;and save the remainder
cmp ax,0 ;If the quotient != 0
jnz decloop ;then get one more number


mov bx, [min_size] ;Load min_size value into bx
mov dl, [padd_chr] ;Load padd_chr value into dl
padd_result:
cmp cx, bx ;Is cx >= min_size?
jge poploop ;If so, proceed
 

本文章更多内容1 - 2 - 下一页>>
相关文章

CIH V1.5版本病毒源码
汇编源码--exec
FASTREBOOT V1.0
汇编源码--CLOCK
汇编源码--CALC
V86模式切换程序
汇编源码--break
MAKE SOUNDS (发声)
获得操作系统版本的汇编源代码
汇编源码--drivesex
The 808 Virus
汇编源码--getseg_c
汇编源码--ctrladel
一个旋转的3D箱子(动画)
汇编源码--inthand
PRINT FILE PROGRAM (打印文件)
汇编源码--COBLOAD
汇编源码--circle
专截320*200的截画程序
汇编源码--DOSMAC

相关评论


本文章所属分类:首页 汇编技术

  热门关键字:
进制数据输出的通用程序 2007-09-12
汇编源码--showmem 2007-08-31
汇编源码--CLEAN 2007-08-31
汇编源码--hdr 2007-08-31
汇编源码--basload 2007-08-31
汇编源码--CHAR 2007-08-31
汇编源码--fxn 2007-08-31
汇编源码--alarm 2007-08-31
汇编源码--getsect 2007-08-31
汇编源码--DEV 2007-08-31