當前位置:編程學習大全網 - 編程語言 - 用匯編語言或C語言結合isis編寫“電子時鐘”程序

用匯編語言或C語言結合isis編寫“電子時鐘”程序

code segment

assume cs:code,ds:code

org 100h

start:

push cs

pop ds

mov ax,3

int 10h

mov ax,0b800h

mov es,ax

cld

Q0:lea dx,Tips ;提示輸入時間

mov ah,9

int 21h

;輸入當前時、分、秒值

call input_bcd

mov HH,al

mov ax,0e3ah ;':'

int 10h

call input_bcd

mov MM,al

mov ax,0e3ah ;':'

int 10h

call input_bcd

mov dh,al

mov ch,HH

cmp ch,23H

ja Q1

mov cl,MM

cmp cl,59H

ja Q1

cmp dh,59H

jbe Q2

Q1:lea dx,Err

mov ah,9

int 21h

jmp Q0

Q2:mov ah,3

int 1ah

call xssj

mov ah,4ch

int 21h

input_bcd:

mov cl,4

call key

shl al,cl

mov dl,al

call key

add al,dl

ret

key:

mov ah,0

int 16h

cmp al,'0'

jb key

cmp al,'9'

ja key

mov ah,0eh

int 10h

sub al,'0'

ret

xssj:

mov di,(80*10+30)*2

T1:mov ah,04 ;CX=2009 DX=0222

int 1ah;讀取日期

;出口參數:CX=年,DX=月/日

mov al,ch;顯示年

call disp

mov al,cl

call disp

mov al,'-'

stosb

mov al,0ah;綠色

stosb

mov al,dh;顯示月

call disp

mov al,'-'

stosb

mov al,0ah;綠色

stosb

mov al,dl;顯示日

call disp

mov al,20h

stosb

mov al,0ah;綠色

stosb

mov ah,02 ;CX=1252 DX=0300

int 1ah;讀取當前時間

;出口參數:CX=時/分;DH=秒

mov al,ch;顯示時

call disp

mov al,':'

stosb

mov al,0ah;綠色

stosb

mov al,cl;顯示分

call disp

mov al,':'

stosb

mov al,0ah;綠色

stosb

mov al,dh;顯示秒

call disp

mov ah,01

int 16h;讀鍵盤

jz xssj ;無字符輸入,繼續顯示時間

mov ah,0

int 16h

cmp al,1bh

jnz xssj

ret

disp:

push cx

mov ah,al

mov cx,4

shr al,cl

and al,0fh

or al,30h

stosb

mov al,0ah;綠色

stosb

mov al,ah

and al,0fh

or al,30h

stosb

mov al,0ah;綠色

stosb

pop cx

ret

Tips db ' Input Current Time'

db 0dh,0ah,' HH:MM:SS $'

Err db 0dh,0ah,'Input Error!',0dh,0ah,'$'

HH db 0

MM db 0

code ends

end start

  • 上一篇:11月20日徐州新增無癥狀感染者12例11月20日徐州新增無癥狀感染者12例
  • 下一篇:安卓手機app怎麽實現qq第三方登錄接口
  • copyright 2024編程學習大全網