Changeset 192 in xtideuniversalbios


Ignore:
Timestamp:
Nov 16, 2011, 11:35:45 AM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Optimized away some long jumps, by rearranging routines within files, and file order within main.asm. Also added some 'relay' entry points for popular destinations, so that a short jump can go to an existing short jump and then on to the final destination, instead of using a long jump - clearly space over speed optimization. All 'relay's are limited to the UI code, and will not have an impact on IDE operational performance.

Location:
trunk/XTIDE_Universal_BIOS/Src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm

    r190 r192  
    2222ALIGN JUMP_ALIGN
    2323BootMenuPrint_FloppyMenuitem:
    24     js      BootMenuPrint_FloppyMenuitemInformation
     24    js      short BootMenuPrint_FloppyMenuitemInformation
    2525    call    PrintDriveNumberAfterTranslationFromDL
    2626    push    bp
     
    3030    add     dl, 'A'
    3131    push    dx                  ; Drive letter
    32     jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     32    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
    3333
    3434%if BootMenuPrint_FloppyMenuitem <> BootMenuEvent_FallThroughToFloppyMenuitem
    3535%error "BootMenuPrint.asm must follow BootMenuEvent.asm, and BootMenuPrint_FloppyMenuitem must be the first routine in BootMenuPrint.asm"
    3636%endif
    37        
    38 ;--------------------------------------------------------------------
    39 ; BootMenuPrint_ClearScreen
    40 ;   Parameters:
    41 ;       Nothing
    42 ;   Returns:
    43 ;       Nothing
    44 ;   Corrupts registers:
    45 ;       AX, DI
    46 ;--------------------------------------------------------------------
    47 ALIGN JUMP_ALIGN
    48 BootMenuPrint_ClearScreen:
    49     call    BootMenuPrint_InitializeDisplayContext
    50     xor     ax, ax
    51     CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
    52     mov     ax, ' ' | (MONO_NORMAL<<8)
    53     CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
    54     ret
    55 
    56 
    57 ;--------------------------------------------------------------------
    58 ; BootMenuPrint_InitializeDisplayContext
    59 ;   Parameters:
    60 ;       Nothing
    61 ;   Returns:
    62 ;       Nothing
    63 ;   Corrupts registers:
    64 ;       AX, DI
    65 ;--------------------------------------------------------------------
    66 ALIGN JUMP_ALIGN
    67 BootMenuPrint_InitializeDisplayContext:
    68     CALL_DISPLAY_LIBRARY InitializeDisplayContext
    69     ret
     37
     38       
     39;--------------------------------------------------------------------
     40; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
     41;   Parameters:
     42;       BX:DX:AX:   Sector count
     43;   Returns:
     44;       Size in stack
     45;   Corrupts registers:
     46;       AX, BX, CX, DX, SI
     47;--------------------------------------------------------------------
     48ALIGN JUMP_ALIGN
     49ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
     50    pop     si      ; Pop return address
     51    call    Size_ConvertSectorCountInBXDXAXtoKiB
     52    mov     cx, BYTE_MULTIPLES.kiB
     53    call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
     54    push    ax      ; Size in magnitude
     55    push    cx      ; Tenths
     56    push    dx      ; Magnitude character
     57    jmp     si
    7058
    7159
     
    10997    push    bp
    11098    mov     bp,sp
    111     jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
    112 
     99    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
     100
     101       
    113102;--------------------------------------------------------------------
    114103; BootMenuPrint_HardDiskMenuitem
     
    124113ALIGN JUMP_ALIGN
    125114BootMenuPrint_HardDiskMenuitem:
    126     js      BootMenuPrint_HardDiskMenuitemInformation
     115    js      short BootMenuPrint_HardDiskMenuitemInformation
    127116    call    PrintDriveNumberAfterTranslationFromDL
    128117    call    RamVars_IsDriveHandledByThisBIOS
     
    165154
    166155;--------------------------------------------------------------------
    167 ; PrintDriveNumberAfterTranslationFromDL
     156; BootMenuPrint_FloppyMenuitemInformation
    168157;   Parameters:
    169158;       DL:     Untranslated Floppy Drive number
    170159;       DS:     RAMVARS segment
    171160;   Returns:
    172 ;       Nothing
    173 ;   Corrupts registers:
    174 ;       AX, DI
    175 ;--------------------------------------------------------------------
    176 ALIGN JUMP_ALIGN
    177 PrintDriveNumberAfterTranslationFromDL:
    178     mov     ax, dx
    179     call    DriveXlate_ToOrBack
    180     xchg    dx, ax              ; Restore DX, WORD to print in AL
    181     xor     ah, ah
    182     push    bp
    183     mov     bp, sp
    184     mov     si, g_szDriveNum
    185     push    ax
    186     jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    187 
    188 
    189 ;--------------------------------------------------------------------
    190 ; BootMenuPrint_FloppyMenuitemInformation
    191 ;   Parameters:
    192 ;       DL:     Untranslated Floppy Drive number
    193 ;       DS:     RAMVARS segment
    194 ;   Returns:
    195161;       CF:     Set since menu event was handled successfully
    196162;   Corrupts registers:
    197163;       AX, BX, CX, DX, SI, DI, ES
    198164;--------------------------------------------------------------------
     165
     166FloppyTypes:
     167.rgbCapacityMultiplier equ 20           ; Multiplier to reduce word sized values to byte size
     168.rgbCapacity:
     169    db      360   / FloppyTypes.rgbCapacityMultiplier    ;  type 1
     170    db      1200  / FloppyTypes.rgbCapacityMultiplier    ;  type 2
     171    db      720   / FloppyTypes.rgbCapacityMultiplier    ;  type 3
     172    db      1440  / FloppyTypes.rgbCapacityMultiplier    ;  type 4
     173    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 5
     174    db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 6
     175
     176%if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
     177%error "FddThreeFive_Displacement incorrect"
     178%endif
     179       
    199180ALIGN JUMP_ALIGN
    200181BootMenuPrint_FloppyMenuitemInformation:
     
    258239
    259240ALIGN JUMP_ALIGN       
    260 .output:       
    261     jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    262        
    263 FloppyTypes:
    264 .rgbCapacityMultiplier equ 20           ; Multiplier to reduce word sized values to byte size
    265 .rgbCapacity:
    266     db      360   / FloppyTypes.rgbCapacityMultiplier    ;  type 1
    267     db      1200  / FloppyTypes.rgbCapacityMultiplier    ;  type 2
    268     db      720   / FloppyTypes.rgbCapacityMultiplier    ;  type 3
    269     db      1440  / FloppyTypes.rgbCapacityMultiplier    ;  type 4
    270     db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 5
    271     db      2880  / FloppyTypes.rgbCapacityMultiplier    ;  type 6
    272 
    273 %if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
    274 %error "FddThreeFive_Displacement incorrect"
    275 %endif
    276                
     241.output:
     242;;; fall-through
     243
     244;--------------------------------------------------------------------
     245; BootMenuPrint_FormatCSSIfromParamsInSSBP
     246;   Parameters:
     247;       CS:SI:  Ptr to string to format
     248;       BP:     SP before pushing parameters
     249;   Returns:
     250;       BP:     Popped from stack
     251;   Corrupts registers:
     252;       AX, DI
     253;--------------------------------------------------------------------
     254ALIGN JUMP_ALIGN
     255BootMenuPrint_FormatCSSIfromParamsInSSBP:
     256    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
     257    stc             ; Successfull return from menu event
     258    pop     bp
     259    ret     
     260
     261       
    277262;--------------------------------------------------------------------
    278263; Prints Hard Disk Menuitem information strings.
     
    346331
    347332    mov     si, g_szSizeSingle
    348     ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
    349 
    350 
    351 ;--------------------------------------------------------------------
    352 ; BootMenuPrint_FormatCSSIfromParamsInSSBP
    353 ;   Parameters:
    354 ;       CS:SI:  Ptr to string to format
    355 ;       BP:     SP before pushing parameters
    356 ;   Returns:
    357 ;       BP:     Popped from stack
    358 ;   Corrupts registers:
    359 ;       AX, DI
    360 ;--------------------------------------------------------------------
    361 ALIGN JUMP_ALIGN
    362 BootMenuPrint_FormatCSSIfromParamsInSSBP:
    363     CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
    364     stc             ; Successfull return from menu event
    365     pop     bp
    366     ret
    367 
    368 
    369 ;--------------------------------------------------------------------
    370 ; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    371 ;   Parameters:
    372 ;       BX:DX:AX:   Sector count
    373 ;   Returns:
    374 ;       Size in stack
    375 ;   Corrupts registers:
    376 ;       AX, BX, CX, DX, SI
    377 ;--------------------------------------------------------------------
    378 ALIGN JUMP_ALIGN
    379 ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
    380     pop     si      ; Pop return address
    381     call    Size_ConvertSectorCountInBXDXAXtoKiB
    382     mov     cx, BYTE_MULTIPLES.kiB
    383     call    Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
    384     push    ax      ; Size in magnitude
    385     push    cx      ; Tenths
    386     push    dx      ; Magnitude character
    387     jmp     si
    388 
    389 
     333    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
     334
     335       
    390336;--------------------------------------------------------------------
    391337; BootMenuPrint_ClearInformationArea
     
    402348    stc
    403349    ret
     350
     351       
     352;--------------------------------------------------------------------
     353; BootMenuPrint_ClearScreen
     354;   Parameters:
     355;       Nothing
     356;   Returns:
     357;       Nothing
     358;   Corrupts registers:
     359;       AX, DI
     360;--------------------------------------------------------------------
     361ALIGN JUMP_ALIGN
     362BootMenuPrint_ClearScreen:
     363    call    BootMenuPrint_InitializeDisplayContext
     364    xor     ax, ax
     365    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
     366    mov     ax, ' ' | (MONO_NORMAL<<8)
     367    CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
     368    ret
     369
     370       
     371;--------------------------------------------------------------------
     372; PrintDriveNumberAfterTranslationFromDL
     373;   Parameters:
     374;       DL:     Untranslated Floppy Drive number
     375;       DS:     RAMVARS segment
     376;   Returns:
     377;       Nothing
     378;   Corrupts registers:
     379;       AX, DI
     380;--------------------------------------------------------------------
     381ALIGN JUMP_ALIGN
     382PrintDriveNumberAfterTranslationFromDL:
     383    mov     ax, dx
     384    call    DriveXlate_ToOrBack
     385    xchg    dx, ax              ; Restore DX, WORD to print in AL
     386    xor     ah, ah
     387    push    bp
     388    mov     bp, sp
     389    mov     si, g_szDriveNum
     390    push    ax
     391       
     392BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
     393    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    404394
    405395
     
    514504    push    cx          ; Key attribute for last space
    515505    mov     si, g_szHotkey
    516     jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
    517 
    518 
     506    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
     507
     508
     509;--------------------------------------------------------------------
     510; BootMenuPrint_InitializeDisplayContext
     511;   Parameters:
     512;       Nothing
     513;   Returns:
     514;       Nothing
     515;   Corrupts registers:
     516;       AX, DI
     517;--------------------------------------------------------------------
     518ALIGN JUMP_ALIGN
     519BootMenuPrint_InitializeDisplayContext:
     520    CALL_DISPLAY_LIBRARY InitializeDisplayContext
     521    ret
     522
     523
     524       
     525
     526
     527       
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm

    r191 r192  
    137137PrintValuesFromStack:
    138138    mov     si, g_szCfgFormat
    139     jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     139    jmp     BootPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
    140140
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootPrint.asm

    r143 r192  
    44; Section containing code
    55SECTION .text
     6
     7;--------------------------------------------------------------------
     8; BootPrint_FailedToLoadFirstSector
     9;   Parameters:
     10;       AH:     INT 13h error code
     11;   Returns:
     12;       Nothing
     13;   Corrupts registers:
     14;       AX, CX, SI, DI
     15;--------------------------------------------------------------------
     16ALIGN JUMP_ALIGN
     17BootPrint_FailedToLoadFirstSector:
     18    push    bp
     19    mov     bp, sp
     20    eMOVZX  cx, ah
     21    push    cx                  ; Push INT 13h error code
     22    mov     si, g_szReadError
     23       
     24BootPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:       
     25    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
     26       
    627
    728;--------------------------------------------------------------------
     
    3354
    3455    mov     si, g_szTryToBoot
    35     jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     56    jmp     short BootPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay     
    3657
    3758
    38 ;--------------------------------------------------------------------
    39 ; BootPrint_FailedToLoadFirstSector
    40 ;   Parameters:
    41 ;       AH:     INT 13h error code
    42 ;   Returns:
    43 ;       Nothing
    44 ;   Corrupts registers:
    45 ;       AX, CX, SI, DI
    46 ;--------------------------------------------------------------------
    47 ALIGN JUMP_ALIGN
    48 BootPrint_FailedToLoadFirstSector:
    49     push    bp
    50     mov     bp, sp
    51     eMOVZX  cx, ah
    52     push    cx                  ; Push INT 13h error code
    53     mov     si, g_szReadError
    54     jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     59
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectPrint.asm

    r189 r192  
    2222    ePUSH_T ax, ROMVARS.szTitle         ; Bios title string
    2323    push    cs                          ; BIOS segment
     24       
     25DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:     
    2426    jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
    2527
     
    4244    push    ax                          ; Push "Master" or "Slave"
    4345    push    di                          ; Push port number
    44     jmp     BootMenuPrint_FormatCSSIfromParamsInSSBP
     46    jmp     DetectPrint_BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
    4547
    4648
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r186 r192  
    170170    %include "DetectDrives.asm"     ; For detecting IDE drives
    171171    %include "DetectPrint.asm"      ; For printing drive detection strings
    172 
     172       
    173173    ; Boot menu
    174174    %include "BootMenu.asm"         ; For Boot Menu operations
    175175    %include "BootMenuEvent.asm"    ; For menu library event handling
    176     %include "BootMenuPrint.asm"    ; For printing Boot Menu strings (needs to come after BootMenuEvent.asm)
     176                                    ; NOTE: BootMenuPrint needs to come immediately after BootMenuEvent
     177    %include "BootMenuPrint.asm"    ; For printing Boot Menu strings
     178    %include "BootPrint.asm"        ; For printing boot information
     179    %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
    177180    %include "FloppyDrive.asm"      ; Floppy Drive related functions
    178181    %include "BootSector.asm"       ; For loading boot sector
    179     %include "BootPrint.asm"        ; For printing boot information
    180     %include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
    181182
    182183    ; Boot loader
     
    187188
    188189    ; For all device types
     190    %include "Idepack.asm"
    189191    %include "Device.asm"
    190     %include "Idepack.asm"
    191192    %include "Timer.asm"            ; For timeout and delay
    192193
     
    194195    %include "IdeCommand.asm"
    195196    %include "IdeTransfer.asm"      ; Must be included after IdeCommand.asm
     197    %include "IdeWait.asm"
     198    %include "IdeError.asm"         ; Must be included after IdeWait.asm       
    196199    %include "IdeDPT.asm"
    197200    %include "IdeIO.asm"
    198201    %include "IdeIrq.asm"
    199     %include "IdeWait.asm"
    200     %include "IdeError.asm"         ; Must be included after IdeWait.asm
    201202
    202203%ifdef MODULE_SERIAL                ; Serial Port Device support
Note: See TracChangeset for help on using the changeset viewer.