Changeset 44 in xtideuniversalbios for trunk/Assembly_Library/Src/Display/DisplayPrint.asm


Ignore:
Timestamp:
Sep 27, 2010, 7:23:36 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Spaces can now be generated before format specifier when printing formatted string.
Background character and attribute can now be easily specified before compiling.

File:
1 edited

Legend:

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

    r42 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   26.6.2010
    4 ; Last update   :   18.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for display output.
     
    6565
    6666;--------------------------------------------------------------------
    67 ; DisplayPrint_SignedDecimalIntegerFromAX
     67; DisplayPrint_SignedWordFromAXWithBaseInBX
    6868;   Parameters:
    6969;       AX:     Word to display
    70 ;       DS:     BDA segment (zero)
    71 ;       ES:DI:  Ptr to cursor location in video RAM
    72 ;   Returns:
    73 ;       BX:     Number of characters printed
    74 ;       DI:     Updated offset to video RAM
    75 ;   Corrupts registers:
    76 ;       AX, DX
    77 ;--------------------------------------------------------------------
    78 ALIGN JUMP_ALIGN
    79 DisplayPrint_SignedDecimalIntegerFromAX:
    80     mov     bx, 10
    81     test    ah, 1<<7            ; Sign bit set?
    82     jz      SHORT DisplayPrint_WordFromAXWithBaseInBX
     70;       BX:     Integer base (binary=2, octal=8, decimal=10, hexadecimal=16)
     71;       DS:     BDA segment (zero)
     72;       ES:DI:  Ptr to cursor location in video RAM
     73;   Returns:
     74;       DI:     Updated offset to video RAM
     75;   Corrupts registers:
     76;       AX, DX
     77;--------------------------------------------------------------------
     78ALIGN JUMP_ALIGN
     79DisplayPrint_SignedWordFromAXWithBaseInBX:
     80    test    ax, ax
     81    jns     SHORT DisplayPrint_WordFromAXWithBaseInBX
    8382
    8483    push    ax
     
    8786    pop     ax
    8887    neg     ax
    89     call    DisplayPrint_WordFromAXWithBaseInBX
    90     inc     bx                  ; Increment character count for '-'
    91     ret
    92 
     88    ; Fall to DisplayPrint_WordFromAXWithBaseInBX
    9389
    9490;--------------------------------------------------------------------
     
    10096;       ES:DI:  Ptr to cursor location in video RAM
    10197;   Returns:
    102 ;       BX:     Number of characters printed
    10398;       DI:     Updated offset to video RAM
    10499;   Corrupts registers:
     
    108103DisplayPrint_WordFromAXWithBaseInBX:
    109104    push    cx
     105    push    bx
    110106
    111107    xor     cx, cx
     
    118114    test    ax, ax              ; All divided?
    119115    jnz     SHORT .DivideLoop   ;  If not, loop
    120     mov     dx, cx              ; Character count to DX
    121 ALIGN JUMP_ALIGN
    122 .PrintLoop:
    123     pop     bx                  ; Pop digit
    124     mov     al, [cs:bx+.rgcDigitToCharacter]
    125     call    DisplayPrint_CharacterFromAL
    126     loop    .PrintLoop
    127     mov     bx, dx              ; Return characters printed
    128 
     116
     117    mov     bx, .rgcDigitToCharacter
     118ALIGN JUMP_ALIGN
     119.PrintNextDigit:
     120    pop     ax                  ; Pop digit
     121    eSEG    cs
     122    xlatb
     123    call    DisplayPrint_CharacterFromAL
     124    loop    .PrintNextDigit
     125
     126    pop     bx
    129127    pop     cx
    130128    ret
     
    140138;       ES:DI:  Ptr to cursor location in video RAM
    141139;   Returns:
    142 ;       BX:     Number of characters printed
    143140;       DI:     Updated offset to video RAM
    144141;   Corrupts registers:
     
    147144ALIGN JUMP_ALIGN
    148145DisplayPrint_CharacterBufferFromBXSIwithLengthInCX:
    149     push    cx
    150 
    151     mov     es, bx                  ; Buffer now in ES:SI
    152     xor     bx, bx                  ; Zero character counter
    153     jcxz    .BufferPrinted
    154 ALIGN JUMP_ALIGN
    155 .CharacterOutputLoop:
    156     mov     al, [es:bx+si]
    157     inc     bx
    158     call    LoadDisplaySegmentAndPrintCharacterFromAL
    159     loop    .CharacterOutputLoop
    160 .BufferPrinted:
    161     mov     es, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
    162     pop     cx
     146    jcxz    .NothingToPrintSinceZeroLength
     147    push    si
     148    push    cx
     149
     150ALIGN JUMP_ALIGN
     151.PrintNextCharacter:
     152    mov     ds, bx
     153    lodsb
     154    LOAD_BDA_SEGMENT_TO ds, dx
     155    call    DisplayPrint_CharacterFromAL
     156    loop    .PrintNextCharacter
     157
     158    LOAD_BDA_SEGMENT_TO ds, dx
     159    pop     cx
     160    pop     si
     161.NothingToPrintSinceZeroLength:
    163162    ret
    164163
     
    171170;       ES:DI:  Ptr to cursor location in video RAM
    172171;   Returns:
    173 ;       BX:     Number of characters printed
    174172;       DI:     Updated offset to video RAM
    175173;   Corrupts registers:
     
    178176ALIGN JUMP_ALIGN
    179177DisplayPrint_NullTerminatedStringFromCSSI:
     178    push    bx
    180179    mov     bx, cs
    181     ; Fall to DisplayPrint_NullTerminatedStringFromBXSI
     180    call    DisplayPrint_NullTerminatedStringFromBXSI
     181    pop     bx
     182    ret
     183
    182184
    183185;--------------------------------------------------------------------
     
    188190;       ES:DI:  Ptr to cursor location in video RAM
    189191;   Returns:
    190 ;       BX:     Number of characters printed
    191192;       DI:     Updated offset to video RAM
    192193;   Corrupts registers:
     
    195196ALIGN JUMP_ALIGN
    196197DisplayPrint_NullTerminatedStringFromBXSI:
    197     mov     es, bx                  ; String now in ES:SI
    198     xor     bx, bx                  ; Zero character counter
    199 ALIGN JUMP_ALIGN
    200 .CharacterOutputLoop:
    201     mov     al, [es:bx+si]
    202     test    al, al
    203     jz      SHORT .AllCharacterPrinted
    204     inc     bx
    205 
    206     call    LoadDisplaySegmentAndPrintCharacterFromAL
    207     jmp     SHORT .CharacterOutputLoop
    208 ALIGN JUMP_ALIGN
    209 .AllCharacterPrinted:
    210     mov     es, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
    211     ret
    212 
    213 ;--------------------------------------------------------------------
    214 ; LoadDisplaySegmentAndPrintCharacterFromAL
    215 ;   Parameters:
    216 ;       AL:     Character to print
    217 ;       DI:     Offset to cursor location in video RAM
    218 ;       DS:     BDA segment (zero)
    219 ;   Returns:
    220 ;       DI:     Updated offset to video RAM
    221 ;   Corrupts registers:
    222 ;       AX, DX
    223 ;--------------------------------------------------------------------
    224 ALIGN JUMP_ALIGN
    225 LoadDisplaySegmentAndPrintCharacterFromAL:
    226     push    es
    227     mov     es, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
    228     call    DisplayPrint_CharacterFromAL
    229     pop     es
    230     ret
    231 
    232 
    233 ;--------------------------------------------------------------------
    234 ; DisplayPrint_Newline
    235 ;   Parameters:
    236 ;       DS:     BDA segment (zero)
    237 ;       ES:DI:  Ptr to cursor location in video RAM
    238 ;   Returns:
    239 ;       DI:     Updated offset to video RAM
    240 ;   Corrupts registers:
    241 ;       AX, DX
    242 ;--------------------------------------------------------------------
    243 ALIGN JUMP_ALIGN
    244 DisplayPrint_Newline:
    245     mov     al, CR
    246     call    DisplayPrint_CharacterFromAL
    247     mov     al, LF
    248     jmp     SHORT DisplayPrint_CharacterFromAL
     198    push    si
     199    push    cx
     200
     201    xor     cx, cx
     202ALIGN JUMP_ALIGN
     203.PrintNextCharacter:
     204    mov     ds, bx              ; String segment to DS
     205    lodsb
     206    mov     ds, cx              ; BDA segment to DS
     207    test    al, al              ; NULL?
     208    jz      SHORT .EndOfString
     209    call    DisplayPrint_CharacterFromAL
     210    jmp     SHORT .PrintNextCharacter
     211
     212ALIGN JUMP_ALIGN
     213.EndOfString:
     214    pop     cx
     215    pop     si
     216    ret
    249217
    250218
     
    297265.ClearRowLoop:
    298266    mov     cl, bl                          ; Area width now in CX
    299     mov     al, ' '                         ; Clear with space
     267    mov     al, SCREEN_BACKGROUND_CHARACTER
    300268    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
    301269
     
    327295ALIGN JUMP_ALIGN
    328296DisplayPrint_RepeatCharacterFromALwithCountInCX:
     297    jcxz    .NothingToRepeat
     298    push    cx
     299
     300ALIGN JUMP_ALIGN
     301.RepeatCharacter:
    329302    push    ax
    330303    call    DisplayPrint_CharacterFromAL
    331304    pop     ax
    332     loop    DisplayPrint_RepeatCharacterFromALwithCountInCX
    333     ret
     305    loop    .RepeatCharacter
     306
     307    pop     cx
     308.NothingToRepeat:
     309    ret
     310
     311
     312;--------------------------------------------------------------------
     313; DisplayPrint_Newline
     314;   Parameters:
     315;       DS:     BDA segment (zero)
     316;       ES:DI:  Ptr to cursor location in video RAM
     317;   Returns:
     318;       DI:     Updated offset to video RAM
     319;   Corrupts registers:
     320;       AX, DX
     321;--------------------------------------------------------------------
     322ALIGN JUMP_ALIGN
     323DisplayPrint_Newline:
     324    mov     al, CR
     325    call    DisplayPrint_CharacterFromAL
     326    mov     al, LF
     327    ; Fall to DisplayPrint_CharacterFromAL
    334328
    335329
Note: See TracChangeset for help on using the changeset viewer.