装配打印系统日期

时间:2015-03-24 19:06:42

标签: date assembly x86 masm

由于cx寄存器大小,打印系统日期有问题。如何在没有任何重大变化的情况下解决它?

title casadatum

zas     segment stack
        db      256 dup(?) 
zas ends

strsize EQU 64

dat segment
   print db 'Current System Date is : $'
   date db  'dd:mm:rrrr$'
   nl db 10,13,'$' 
dat ends

code segment
                assume cs:code, ss:zas, ds:dat

get_date proc
          mov ah,2ah
          int 21h
          mov al,dl
          call convert
          mov [bx],ax
          mov al,dh
          call convert
          mov [bx+3],ax
          mov al,cx
          call convert
          mov [bx+6],ax     

        ret
        endp          


convert proc
        push dx
        mov ah,0
        mov dl,10
        div dl
        or ax, 3030h
        pop dx
        ret 
        endp    


start:

        mov ax, seg dat
        mov ds,ax

        LEA BX, date
        CALL GET_date

        lea dx,print
        mov ah,09h
        int 21h

        lea dx,date
        mov ah,09h
        int 21h

koniec:
        mov ah, 4ch
        int 21h

code ends
        end start

1 个答案:

答案 0 :(得分:2)

替换代码的这一部分

mov al,cx
call convert
mov [bx+6],ax

使用这些说明

mov al,100
xchg ax,cx
div cl
mov ch,ah
call convert
mov [bx+6],ax
mov al,ch
call convert
mov [bx+8],ax