Changeset 202 in xtideuniversalbios for trunk/Assembly_Library/Src/Display
- Timestamp:
- Nov 22, 2011, 2:08:32 PM (13 years ago)
- google:author:
- krille_n_@hotmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Src/Display/DisplayFormatCompressed.asm
r195 r202 1 1 ; Project name : Assembly Library 2 2 ; 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. 13 6 ; 14 7 ; Strings are compressed in a simple manner: 15 8 ; 1. The two most common characters, space and null, are removed 16 ; 9 ; 2. Format specifiers are reduced to a single byte, including length information 17 10 ; 18 11 ; Format of bytes in the string are: 19 12 ; 01 xxxxxx Character in x plus StringsCompressed_NormalBase 20 13 ; 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 22 15 ; 00 1 yyyyy Character/Format in lookup table StringsCopmressed_TranslatesAndFormats 23 16 ; 00 0 yyyyy Character/Format in lookup table StringsCompressed_TranslatesAndFormats, followed by a null … … 31 24 ; 32 25 ; 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" 34 27 ; match, allowing the translates/format codes to be shifted left by 1 and then tested with the same instructions. 35 28 ; 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 37 30 ; no way (nor need) to specify a zero character. 38 31 ; … … 41 34 ; much "preload", just in case a branch is taken, but that is cheaper (in size) than adding additional branches. 42 35 ; 43 36 44 37 ; Section containing code 45 38 SECTION .text … … 49 42 ; 50 43 ; 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, 52 45 ; with '-' replaced with '_'. 53 46 ; … … 87 80 jz DisplayFormat_ParseCharacters 88 81 ; fall through 89 82 90 83 DisplayFormatCompressed_Format_2_u: 91 84 mov bh,2 ; only two characters (instead of the default 5) 92 85 ; fall through 93 86 94 87 DisplayFormatCompressed_Format_u: 95 88 DisplayFormatCompressed_Format_5_u: … … 101 94 div si ; DX:AX / 10 => AX=quot, DX=rem 102 95 push dx ; Push digit 103 104 dec bh 96 97 dec bh 105 98 jnz .DivLoop 106 99 … … 114 107 ; if it is zero, DisplayPrint_CharacterFromAL will not emit 115 108 116 or bh, al ; skip leading zeros, bh keeps track if we have emitted anyth ng non-zero109 or bh, al ; skip leading zeros, bh keeps track if we have emitted anything non-zero 117 110 jnz .PrintDigit ; note that bh starts at zero, from the loop above 118 111 119 test ch,2 ; are we padding with leading spaces? 112 test ch,2 ; are we padding with leading spaces? 120 113 jnz .PrintLoop ; test the even/odd of the format byte in the string 121 114 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 130 122 131 123 call DisplayPrint_CharacterFromAL … … 133 125 jmp .PrintLoop 134 126 135 127 136 128 ;-------------------------------------------------------------------- 137 129 ; DisplayFormat_ParseCharacters … … 146 138 ; Corrupts registers: 147 139 ; AX, BX, CX, DX, BP 148 ;-------------------------------------------------------------------- 140 ;-------------------------------------------------------------------- 149 141 150 142 DisplayFormatCompressed_BaseFormatOffset: 151 143 152 144 DisplayFormat_ParseCharacters_FromAX: 153 145 mov si,ax 154 146 ; fall through to DisplayFormat_ParseCharacters 155 147 156 ALIGN JUMP_ALIGN 157 DisplayFormat_ParseCharacters: 158 ; 159 ; This routine is used to outp tu all strings from the ROM. The strings in ROMVARS are not compressed,148 ALIGN JUMP_ALIGN 149 DisplayFormat_ParseCharacters: 150 ; 151 ; This routine is used to output all strings from the ROM. The strings in ROMVARS are not compressed, 160 152 ; and must be handled differently. 161 153 ; … … 165 157 166 158 .decode: 167 mov al,[cs:si] ; load next byte of the string168 inc si159 eSEG cs 160 lodsb ; load next byte of the string 169 161 170 162 mov ch,al ; save a copy for later processing of high order bits … … 175 167 and al,03fh ; "Normal" character, mask off high order bits 176 168 add al,StringsCompressed_NormalBase ; and add character offset (usually around 0x40) 177 169 178 170 .output: 179 call DisplayPrint_CharacterFromAL 171 call DisplayPrint_CharacterFromAL 180 172 181 173 .process_after_output: … … 189 181 190 182 ALIGN JUMP_ALIGN 191 DisplayFormatCompressed_TranslatesAndFormats: 183 DisplayFormatCompressed_TranslatesAndFormats: 192 184 ; 193 185 ; This routine is here (above DisplayFormat_ParseCharacters) to reduce the amount of code between … … 201 193 202 194 cmp al,StringsCompressed_FormatsBegin ; determine if this is a translation or a format 203 195 204 196 mov al,[cs:bx] ; fetch translation/formats byte 205 197 … … 208 200 ; note that the flags for this conditional jump were 209 201 ; set with the cmp al,StringsCompressed_FormatsBegin 210 202 211 203 mov dx,DisplayFormatCompressed_BaseFormatOffset ; calculate address to jump to for format handler 212 204 sub dx,ax … … 231 223 jmp DisplayFormat_ParseCharacters.process_after_output ; continue postprocessing, check for end of string 232 224 233 234 235 236 237 238 239 240 241 242 243
Note:
See TracChangeset
for help on using the changeset viewer.