Changeset 202 in xtideuniversalbios for trunk/Assembly_Library


Ignore:
Timestamp:
Nov 22, 2011, 2:08:32 PM (13 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Library/BIOS: Minor optimizations to DisplayFormatCompressed.asm and BootMenuEvent.asm
  • XTIDECFG: Trimmed trailing CRLFs from some of the text files in Help (also fixed a typo)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/Display/DisplayFormatCompressed.asm

    r195 r202  
    11; Project name  :   Assembly Library
    22; Description   :   Functions for displaying formatted strings.
    3 ;                   ** Compressed Strings edition **
    4 ;
    5 ; Authors       :   Greg Lindhorst
    6 ;               :   gregli@hotmail.com
    7 ;               :       
    8 ;               :   Tomi Tilli
    9 ;               :   aitotat@gmail.com
    10 ;               :
    11 ; Description   :   This is a plug replacement for DisplayFormat.asm,
    12 ;                   working instead with precompiled and slightly compressed strings.
     3;                   ** Compressed Strings edition **
     4;                   This is a plug replacement for DisplayFormat.asm,
     5;                   working instead with precompiled and slightly compressed strings.
    136;
    147; Strings are compressed in a simple manner:
    158;   1. The two most common characters, space and null, are removed
    16 ;   2. Format specifiers are reduced to a single byte, including length information
     9;   2. Format specifiers are reduced to a single byte, including length information
    1710;
    1811; Format of bytes in the string are:
    1912;     01 xxxxxx     Character in x plus StringsCompressed_NormalBase
    2013;     10 xxxxxx     Character in x plus StringsCompressed_NormalBase, followed by a null (last character)
    21 ;     11 xxxxxx     Character in x plus StringsCompressed_NormalBase, followed by a space       
     14;     11 xxxxxx     Character in x plus StringsCompressed_NormalBase, followed by a space
    2215;     00 1 yyyyy    Character/Format in lookup table StringsCopmressed_TranslatesAndFormats
    2316;     00 0 yyyyy    Character/Format in lookup table StringsCompressed_TranslatesAndFormats, followed by a null
     
    3124;
    3225; The assignments of the first two bits above is not by accident.  The translates/format branch is 00
    33 ; which is easy to test for.  The '01' for "normal" (no null or space) and '001' for translates/format "normal" 
     26; which is easy to test for.  The '01' for "normal" (no null or space) and '001' for translates/format "normal"
    3427; match, allowing the translates/format codes to be shifted left by 1 and then tested with the same instructions.
    3528;
    36 ; It is always possible to say that a null character follows the current character - thus there is 
     29; It is always possible to say that a null character follows the current character - thus there is
    3730; no way (nor need) to specify a zero character.
    3831;
     
    4134; much "preload", just in case a branch is taken, but that is cheaper (in size) than adding additional branches.
    4235;
    43        
     36
    4437; Section containing code
    4538SECTION .text
     
    4942;
    5043; Names of format handlers are DisplayFormatCompressed_Format_* where * is
    51 ; replaced with the format code after the '%' in the original string, 
     44; replaced with the format code after the '%' in the original string,
    5245; with '-' replaced with '_'.
    5346;
     
    8780    jz      DisplayFormat_ParseCharacters
    8881    ; fall through
    89        
     82
    9083DisplayFormatCompressed_Format_2_u:
    9184    mov     bh,2                        ; only two characters (instead of the default 5)
    9285    ; fall through
    93        
     86
    9487DisplayFormatCompressed_Format_u:
    9588DisplayFormatCompressed_Format_5_u:
     
    10194    div     si                          ; DX:AX / 10 => AX=quot, DX=rem
    10295    push    dx                          ; Push digit
    103        
    104     dec     bh                         
     96
     97    dec     bh
    10598    jnz     .DivLoop
    10699
     
    114107                                                ; if it is zero, DisplayPrint_CharacterFromAL will not emit
    115108
    116     or      bh, al                      ; skip leading zeros, bh keeps track if we have emitted anythng non-zero
     109    or      bh, al                      ; skip leading zeros, bh keeps track if we have emitted anything non-zero
    117110    jnz     .PrintDigit                 ; note that bh starts at zero, from the loop above
    118111
    119     test    ch,2                        ; are we padding with leading spaces? 
     112    test    ch,2                        ; are we padding with leading spaces?
    120113    jnz     .PrintLoop                  ; test the even/odd of the format byte in the string
    121114
    122     mov     al,' '-'0'                  ; emit space, but let the following instuctions add '0'
    123 
    124 .PrintDigit:   
    125     add     al,'0'                      ; Digit to character
    126     cmp     al,'9'                      ; for hex output, greater than '9'?
    127     jle     .NoHexAdjustment
    128     add     al,'A'-'9'-1                ; adjust for hex output ('A' to 'F')
    129 .NoHexAdjustment:       
     115    mov     al, 89h                     ; emit space
     116
     117.PrintDigit:
     118    add     al, 90h                     ; Convert binary digit in AL to ASCII hex digit (0 - 9 or A - F)
     119    daa
     120    adc     al, 40h
     121    daa
    130122
    131123    call    DisplayPrint_CharacterFromAL
     
    133125    jmp     .PrintLoop
    134126
    135        
     127
    136128;--------------------------------------------------------------------
    137129; DisplayFormat_ParseCharacters
     
    146138;   Corrupts registers:
    147139;       AX, BX, CX, DX, BP
    148 ;--------------------------------------------------------------------       
     140;--------------------------------------------------------------------
    149141
    150142DisplayFormatCompressed_BaseFormatOffset:
    151        
     143
    152144DisplayFormat_ParseCharacters_FromAX:
    153145    mov     si,ax
    154146    ; fall through to DisplayFormat_ParseCharacters
    155147
    156 ALIGN JUMP_ALIGN       
    157 DisplayFormat_ParseCharacters: 
    158 ;
    159 ; This routine is used to outptu all strings from the ROM.  The strings in ROMVARS are not compressed,
     148ALIGN JUMP_ALIGN
     149DisplayFormat_ParseCharacters:
     150;
     151; This routine is used to output all strings from the ROM.  The strings in ROMVARS are not compressed,
    160152; and must be handled differently.
    161153;
     
    165157
    166158.decode:
    167     mov     al,[cs:si]          ; load next byte of the string
    168     inc     si
     159    eSEG    cs
     160    lodsb                       ; load next byte of the string
    169161
    170162    mov     ch,al               ; save a copy for later processing of high order bits
     
    175167    and     al,03fh                             ; "Normal" character, mask off high order bits
    176168    add     al,StringsCompressed_NormalBase     ; and add character offset (usually around 0x40)
    177        
     169
    178170.output:
    179     call    DisplayPrint_CharacterFromAL       
     171    call    DisplayPrint_CharacterFromAL
    180172
    181173.process_after_output:
     
    189181
    190182ALIGN JUMP_ALIGN
    191 DisplayFormatCompressed_TranslatesAndFormats:       
     183DisplayFormatCompressed_TranslatesAndFormats:
    192184;
    193185; This routine is here (above DisplayFormat_ParseCharacters) to reduce the amount of code between
     
    201193
    202194    cmp     al,StringsCompressed_FormatsBegin           ; determine if this is a translation or a format
    203                                                        
     195
    204196    mov     al,[cs:bx]                                  ; fetch translation/formats byte
    205197
     
    208200                                                        ; note that the flags for this conditional jump were
    209201                                                        ; set with the cmp al,StringsCompressed_FormatsBegin
    210        
     202
    211203    mov     dx,DisplayFormatCompressed_BaseFormatOffset   ; calculate address to jump to for format handler
    212204    sub     dx,ax
     
    231223    jmp     DisplayFormat_ParseCharacters.process_after_output  ; continue postprocessing, check for end of string
    232224
    233 
    234 
    235 
    236 
    237 
    238        
    239 
    240        
    241    
    242 
    243 
Note: See TracChangeset for help on using the changeset viewer.