代碼解釋如下:
;從CMOS RAM中讀取存儲的時間信息,顯示當前的系統時間在屏幕上assume cs:codedata segment db 'YY MM DD HH MM SS',0 ;時間以這個形式顯示data endscode segmentinfo: db 9,8,7,4,2,0 ;標志年 月 日 時 分 秒不同時間的位置start: call init_regtimeChange: call show_clock ;一直在這里循環不斷更新時間 jmp timeChange mov ax,4c00h int 21h;========================================================init_reg: mov ax,0B800h mov es,ax mov ax,cs mov ds,ax mov di,160*12 + 40*2 mov si,offset info mov cx,6 ret;========================================================show_clock: push dx push es push di push si push ds push cx showTime: mov al,ds:[si] out 70h,al ;向70h號端口輸出al in al,71h ;在71h號端口讀取數據放入al mov ah,al shr ah,1 ;這個了用4個shr,主要是為了不破壞cx的值 shr ah,1 shr ah,1 shr ah,1 and al,00001111B add ah,30h ;add 30h 就轉為能看懂的ASCII碼 add al,30h mov es:[di],ah mov es:[di+2],al inc si ;標志不同時間(月年日時分秒)的位置更新 add di,6 loop showTimeshowClockRet: pop cx pop ds pop si pop di pop es pop dx ret;======================================================== code endsend start
新聞熱點
疑難解答
圖片精選