rtc.asm

来自「XOSL 多操作系统管理工具 源代码 多系统引导工具」· 汇编 代码 · 共 74 行

ASM
74
字号
;
; Extended Operating System Loader (XOSL)
; Copyright (c) 1999 by Geurt Vos
;
; This code is distributed under GNU General Public License (GPL)
;
; The full text of the license can be found in the GPL.TXT file,
; or at http://www.gnu.org
;

                .model  large
                .386p
                .data
HourSec         dd      3600

                .code

                public  @ResetTimer$qv

;void ResetTimer()
@ResetTimer$qv  proc
                push    bp
                mov     bp,5

GetTime:        mov     ah,2
                int     1ah
                jnc     TimeRead
                dec     bp
                jns     GetTime
                jmp     RTDone

TimeRead:       movzx   bx,ch
                xor     ch,ch
                shr     dx,8
                push    bx
                call    BCD2Hex
                pop     bx
                push    dx
                call    BCD2Hex
                pop     dx
                push    cx
                call    BCD2Hex
                xor     eax,eax
                pop     ax

                imul    ax,60
                add     ax,dx
                imul    eax,65536
                xor     edx,edx
                idiv    HourSec

                xor     cx,cx
                mov     es,cx
                mov     es:[046ch],ax
                mov     es:[046eh],bx

RTDone:         pop     bp
                ret
                endp

BCD2Hex         proc    near
                push    bp
                mov     bp,sp
                mov     ax,[bp + 4]
                and     byte ptr [bp + 4],0fh
                shr     ax,4
                imul    ax,10
                add     [bp + 4],ax
                pop     bp
                ret
BCD2Hex         endp

                end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?