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

📄 launcher.asm

📁 基于Menuet OS的用户应用程序及其系统应用程序(用户:BMP/jpg图片查看器 系统:CPU 状态监控程序等)
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;
;   LAUNCHER.ASM
;
;   Compile with FASM for Menuet
;   
;   Mike Hibbett   Added reading the settings from a text file
;
   
use32
   
               org    0x0
   
               db     'MENUET01'              ; 8 byte id
               dd     0x01                    ; header version
               dd     START                   ; start of code
               dd     I_END                   ; size of image
               dd     0x100000                 ; memory for app
               dd     0x7fff0                  ; esp
               dd     0x0 , 0x0               ; I_Param , I_Icon
               
   
START: 
    call    make_table          ; Create the pretty icon
      
    call    draw_window
   
    ; For some reason, draw_window needs to be called first
    ; Maybe it adds a delay
    
    call    readBootFile        ; Load the startup data file

    call    draw_window

    mov     ecx,40
   
newdelay2:

    ; Delay for 50ms

    mov     eax,5
    mov     ebx,2
    int     0x40
    call    update_candy   
    loop    newdelay2
   
still:
    mov     eax,11                  ; wait here for event
    int     0x40
   
    cmp     eax,1                   ; redraw request ?
    je      red
    cmp     eax,2                   ; key in buffer ?
    je      key
    cmp     eax,3                   ; button in buffer ?
    je      button
   
    call    launch_applications
   
    jmp     still
   
red:                                ; redraw
    call    draw_window
    jmp     still
   
key:                                ; key
    mov     eax,2                   ; just read it and ignore
    int     0x40
    jmp     still
   
button: 
    mov     eax,17                  ; get id
    int     0x40
   
    cmp     ah,1                    ; button id=1 ?
    jne     noclose
   
    mov     eax,-1                  ; close this program
    int     0x40

noclose:   
    jmp     still


;***************************************************************************
;   Function
;      readBootFile
;
;   Description
;
;***************************************************************************
readBootFile:
    mov   eax,6    ; Read file from ramdisk
    mov   ebx,bootFilename
    mov   ecx,0
    mov   edx,0xffffffff
    mov   esi,I_END + 4096      ; The first 4096 are reserved for the file list
    int   0x40
    
    cmp   eax,0xffffffff
    jnz   filefound    
    ret
    
filefound:
    add     eax, I_END + 4096
    mov     [fileEnd], eax          ; Store the end pos of file in memory
    
    ; OK, lets parse the text file.
    ; I assume that lines are terminated by CR or LF or CR/LF or LF/CR ..
    ; .. Just to be safe :o)
    ; Lines beginning with # are comments and are skipped
    ; Lines with only white space are skipped
    ; Line format is APPNAME PARAMETER DELAY
    ; APPNAME,PARAMETER and DELAY contain no whitespace
    ; APPNAME has no path or extension
    ; APPNAME,PARAMETER are no longer than 16 characters long
    ; DELAY is postive interger number and is the delay in ms
    ; Fields are seperated by 1 or more whitespace characters
    ; End the file with an empty line
    ; Whitespace is space or tab
    ; Garbage in, garbage out. 
    
    mov     esi, I_END +4096        ; esi is source file data
    mov     edi, file_list          ; edi is place to write

    xor     eax, eax
    mov     [files], eax            ; We have 0 boot options at start
    
findline:    
    call    findParam               ; point to next parameter, skip comments
    cmp     esi, [fileEnd]
    jae      fileLoaded              ; Have we reached the end of the file?
    push    edi
    call    storeParam              ; copy string to file_list
    pop     edi
    add     edi, 16
    call    skipWhite               ; past any whitespace
    push    edi
    call    storeParam              ; copy string to file_list
    pop     edi
    add     edi, 64
    call    skipWhite               ; past any whitespace
    call    storeDecimal            ; get decimal string to binary, store
    
    mov     eax, [files]
    inc     eax
    mov     [files], eax

    cmp     esi, [fileEnd]
    jae      fileLoaded              ; Have we reached the end of the file?
    
    
    cmp     eax, 50                 ; We can only have 50 maximum
    je      fileLoaded
    jmp     findline                ; Get more

fileLoaded:
    mov     eax, [files]
    cmp     eax, 0
    jne     rbExit
    
    ; Restore the default boot load size
    mov     eax, 3
    mov     [files], eax
rbExit:    
    
    ret



;***************************************************************************
;   Function
;       findParam
;
;   Description
;       skips comments and blank lines until the next parameter if found
;       source is in esi; dont touch edi
;
;***************************************************************************
findParam:
    ; Exit if at end of file
    cmp     esi, [fileEnd]
    jb     fp001
    ret                             ; Abort
    
fp001:
    mov     al, [esi]               ; get file character
    
    ; is it a comment line?
    cmp     al, '#'
    jne     fp002
    
    call    nextLine                ; Move to next line
    jmp     findParam
    
fp002:
    call    skipWhite               ; Move past any spaces
    
    cmp     esi, [fileEnd]          ; Have we reached the end of the file?
    jae     findParam               ; If yes, jump back to start to force exit

    ; Was it an empty line?
    mov     al, [esi]
    cmp     al, 0x0a
    je      fp003                   
    cmp     al, 0x0d
    je      fp003
    ret                             ; We have the parameter!

fp003:
    ; It was an empty line; Read past the end of line marker
    ; and return to findParam for next line
    inc     esi
    mov     al, [esi]
    cmp     al, 0x0a
    je      fp004                  
    cmp     al, 0x0d
    je      fp004
    jmp     findParam

fp004:
    inc     esi
    jmp     findParam
    
    

;***************************************************************************
;   Function
;       nextLine
;
;   Description
;       skips to the beginning of the next line
;
;***************************************************************************
nextLine:
    ; Exit if at end of file
    cmp     esi, [fileEnd]
    jb     nl001
    ret                             ; Abort
    
nl001:
    mov     al, [esi]
    cmp     al, 0x0a
    je      nl002           ; We have reached the end
    cmp     al, 0x0d
    je      nl002
    inc     esi
    jmp     nextLine
    
nl002:                      ; Now skip the CR/LF bits
    inc     esi
    mov     al, [esi]
    cmp     al, 0x0a
    je      nl003                  
    cmp     al, 0x0d
    je      nl003
    ret                     ; Now at start of new line
        
nl003:
    inc     esi      
    ret                     ; Now at start of new line    
    
    
    

;***************************************************************************
;   Function
;       skipWhite
;
;   Description
;       skips any tabs or spaces
;
;***************************************************************************
skipWhite:
    ; Exit if at end of file
    cmp     esi, [fileEnd]
    jb     sw001
    ret                             ; Abort

sw001:
    mov     al, [esi]
    cmp     al, ' '
    je      sw002                   ; skip space char
    cmp     al, 0x09        
    je      sw002                   ; skip tab char
    ret

sw002:
    inc     esi
    jmp     skipWhite
    
    
 

;***************************************************************************
;   Function
;       storeParam
;
;   Description
;       copies the string to the file table
;
;***************************************************************************
storeParam:
    ; Clear any previous string in the array
    push    edi
    mov     al, ' '
    mov     ecx, 64                 ; Yes, this is safe on the first parameter
    cld
    rep     stosb
    pop     edi
    
sp000:
    ; Exit if at end of file
    cmp     esi, [fileEnd]
    jb     sp001
    ret                             ; Abort

sp001:
;    cld
;    movsb
    mov     al, [esi]
    mov     [edi], al

⌨️ 快捷键说明

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