⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loader.asm

📁 自己编写的操作系统的源代码
💻 ASM
字号:
        page    60,132
        title   BOOTLOADER FOR UNIVERSE OPERATING SYSTEM
;******************************************************************************
;******************************************************************************
;**                                                                          **
;**                                 loader.asm                               **
;**                                                                          **
;**               Copyright (C) 2005-2006 Universe Corporation               **
;**                                                                          **
;**                            All Rights Reserved                           **
;**                                                                          **
;**                      Lanzhou University Of Tecnology                     **
;**                                                                          **
;**                              (0931)-2975931                              **
;**                                                                          **
;******************************************************************************
;******************************************************************************
;+ includes +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        include asm\equates.inc
        include asm\macros.inc
        include asm\structs.inc
;+ code segment +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
startup group   _loader
_loader segment word public use16 'CODE'
        assume  cs:startup
.486p
;------------------------------------------------------------------------------
        public  _LOADER_STARTS
_LOADER_STARTS  label   byte    ; marks start of module
;------------------------------------------------------------------------------
; initialize register
        cli                     ; disable interrupt
        mov     ax,DS_BOOT
        mov     ds,ax           ; set ds = 07c0h
        mov     ax,CS_BOOT
        mov     es,ax           ; set es = 0000h
        mov     ax,SS_BOOT
        mov     ss,ax           ; set ss = 9000h
        mov     sp,SP_BOOT      ; set sp = fbffh
        sti                     ; enable interrupt

; print startup screen
        mov     ax,0600h        ; clear screen
        mov     bh,00h
        mov     cx,0000h
        mov     dx,184fh
        int     10h

        mov     ah,01h          ; set cursor style - no cursor
        mov     cx,0100h
        int     10h

        push    word ptr 0000h  ; row 1, column 1
        push    word ptr offset ds:msg_banner
        push    word ptr BLACK_WHITE
        push    word ptr MSG_BANNER_L
        call    near ptr print_msg
        
        push    byte ptr 18h    ; row 25
        call    near ptr anti_mutually
        
        push    word ptr 1801h  ; row 25, column 2
        push    word ptr offset ds:msg_startup
        push    word ptr WHITE_BLACK
        push    word ptr MSG_STARTUP_L
        call    near ptr print_msg
        
; load all what should be loaded
        mov     bx,INIT_R_START ; load to starting address es:bx
        mov     ax,RD_SECS_NR
        mov     cx,0002h
        mov     dx,0080h
        int     13h

; jump to init_r module
        jmp_if  CS_BOOT,INIT_R_START
;- procedures -----------------------------------------------------------------
print_msg       proc near
;------------------------------------------------------------------------------
; usage:        print a message to display termination
;
; receives:     [si + 10] = cursor position
;               [si +  8] = offset of the message
;               [si +  6] = color  of the message
;               [si +  4] = length of the message
; returns:      nothing
; destroyed:    nothing
;------------------------------------------------------------------------------
        push    si
        mov     si,sp

        push    es
        push    bp
        push    ax
        push    bx
        push    cx
        push    dx

; set cursor position
        mov     ah,02h
        mov     bh,00h
        mov     dx,word ptr ss:[si + 10]
        int     10h
        
; print message
        mov     ax,DS_BOOT
        mov     es,ax
        mov     bp,word ptr ss:[si + 8]
        mov     ax,1301h
        mov     bx,word ptr ss:[si + 6]
        mov     cx,word ptr ss:[si + 4]
        int     10h
        
        pop     dx
        pop     cx
        pop     bx
        pop     ax
        pop     bp
        pop     es
        pop     si

        ret     8
print_msg       endp

anti_mutually   proc near
;------------------------------------------------------------------------------
; usage:        make a row of screen anti-mutually
;
; receives:     [bp + 4] = which row will to be made anti-mutually
; returns:      nothing
; destroyed:    nothing
;------------------------------------------------------------------------------
        push    bp
        mov     bp,sp
        
        push    ax
        push    bx
        push    cx
        push    dx

; set cursor position to row [bp + 4]
        mov     ah,02h
        mov     bh,00h
        mov     dh,byte ptr ss:[bp + 4]
        mov     dl,00h
        int     10h
        
; anti-mutually
        mov     ax,0920h
        mov     bx,WHITE_BLACK
        mov     cx,80
        int     10h

        pop     dx
        pop     cx
        pop     bx
        pop     ax
        pop     bp
        
        ret     1
anti_mutually   endp
;- data -----------------------------------------------------------------------
msg_banner:
        byte    'Universe Infinite Alpha Release',5 dup(' '),
                'Copyright (C) 2005-2006 Universe Corporation'
MSG_BANNER_L    equ     $ - msg_banner

msg_startup:
        byte    'Universe Infinite is starting up ...'
MSG_STARTUP_L   equ     $ - msg_startup

        org     510

; bootable signature
        word    0aa55h
;------------------------------------------------------------------------------
        public  _LOADER_ENDS
_LOADER_ENDS    label   byte    ; marks end of module
;------------------------------------------------------------------------------
_loader ends
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        end

⌨️ 快捷键说明

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