[41] | 1 | ; File name : DisplayCharOut.asm |
---|
| 2 | ; Project name : Assembly Library |
---|
| 3 | ; Created date : 26.6.2010 |
---|
| 4 | ; Last update : 13.8.2010 |
---|
| 5 | ; Author : Tomi Tilli |
---|
| 6 | ; Description : Functions for outputting characters to video memory. |
---|
| 7 | ; These functions are meant to be called by Display_CharacterFromAL |
---|
| 8 | ; and Display_RepeatCharacterFromAL using function pointer |
---|
| 9 | ; stored in DISPLAY_CONTEXT. |
---|
| 10 | |
---|
| 11 | ; Section containing code |
---|
| 12 | SECTION .text |
---|
| 13 | |
---|
| 14 | ;-------------------------------------------------------------------- |
---|
| 15 | ; DisplayCharOut_TeletypeOutputWithAttribute |
---|
| 16 | ; DisplayCharOut_TeletypeOutput |
---|
| 17 | ; Parameters: |
---|
| 18 | ; AL: Character to output |
---|
| 19 | ; AH: Attribute to output |
---|
| 20 | ; DS: BDA segment (zero) |
---|
| 21 | ; ES:DI: Ptr to video memory where to output |
---|
| 22 | ; Returns: |
---|
| 23 | ; DI: Incremented for next character |
---|
| 24 | ; Corrupts registers: |
---|
| 25 | ; AX, DX |
---|
| 26 | ;-------------------------------------------------------------------- |
---|
| 27 | ALIGN JUMP_ALIGN |
---|
| 28 | DisplayCharOut_TeletypeOutputWithAttribute: |
---|
| 29 | cmp al, ' ' ; Printable character? |
---|
| 30 | jb SHORT DisplayCharOut_BiosTeletypeOutput |
---|
| 31 | stosw |
---|
| 32 | ret |
---|
| 33 | |
---|
| 34 | ALIGN JUMP_ALIGN |
---|
| 35 | DisplayCharOut_TeletypeOutput: |
---|
| 36 | cmp al, ' ' ; Printable character? |
---|
| 37 | jae SHORT DisplayCharOut_Character |
---|
| 38 | ; Fall to DisplayCharOut_BiosTeletypeOutput |
---|
| 39 | |
---|
| 40 | ;-------------------------------------------------------------------- |
---|
| 41 | ; DisplayCharOut_BiosTeletypeOutput |
---|
| 42 | ; Parameters: |
---|
| 43 | ; AL: Control character |
---|
| 44 | ; DS: BDA segment (zero) |
---|
| 45 | ; ES:DI: Ptr to video memory where to output |
---|
| 46 | ; Returns: |
---|
| 47 | ; DI: Incremented for next character |
---|
| 48 | ; Corrupts registers: |
---|
| 49 | ; AX, DX |
---|
| 50 | ;-------------------------------------------------------------------- |
---|
| 51 | ALIGN JUMP_ALIGN |
---|
| 52 | DisplayCharOut_BiosTeletypeOutput: |
---|
| 53 | push ax |
---|
| 54 | call DisplayCursor_SynchronizeCoordinatesToHardware |
---|
| 55 | pop ax |
---|
| 56 | call .OutputCharacterWithBIOS |
---|
| 57 | call DisplayCursor_GetHardwareCoordinatesToAX |
---|
| 58 | jmp DisplayCursor_SetCoordinatesFromAX |
---|
| 59 | |
---|
| 60 | ;-------------------------------------------------------------------- |
---|
| 61 | ; .OutputCharacterWithBIOS |
---|
| 62 | ; Parameters: |
---|
| 63 | ; AL: Character to output |
---|
| 64 | ; DS: BDA segment |
---|
| 65 | ; Returns: |
---|
| 66 | ; Nothing |
---|
| 67 | ; Corrupts registers: |
---|
| 68 | ; AX |
---|
| 69 | ;-------------------------------------------------------------------- |
---|
| 70 | ALIGN JUMP_ALIGN |
---|
| 71 | .OutputCharacterWithBIOS: |
---|
| 72 | push bx |
---|
| 73 | mov ah, TELETYPE_OUTPUT |
---|
| 74 | mov bh, [VIDEO_BDA.bActivePage] |
---|
| 75 | int BIOS_VIDEO_INTERRUPT_10h |
---|
| 76 | pop bx |
---|
| 77 | ret |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | ;-------------------------------------------------------------------- |
---|
| 81 | ; DisplayCharOut_Attribute |
---|
| 82 | ; DisplayCharOut_Character |
---|
| 83 | ; DisplayCharOut_CharacterWithAttribute |
---|
| 84 | ; Parameters: |
---|
| 85 | ; AL: Character to output |
---|
| 86 | ; AH: Attribute to output |
---|
| 87 | ; ES:DI: Ptr to video memory where to output |
---|
| 88 | ; Returns: |
---|
| 89 | ; DI: Incremented for next character |
---|
| 90 | ; Corrupts registers: |
---|
| 91 | ; AX |
---|
| 92 | ;-------------------------------------------------------------------- |
---|
| 93 | ALIGN JUMP_ALIGN |
---|
| 94 | DisplayCharOut_Attribute: |
---|
| 95 | xchg al, ah ; Swap character and attribute |
---|
| 96 | inc di ; Skip character |
---|
| 97 | stosb |
---|
| 98 | ret |
---|
| 99 | |
---|
| 100 | ALIGN JUMP_ALIGN |
---|
| 101 | DisplayCharOut_Character: |
---|
| 102 | stosb |
---|
| 103 | inc di ; Skip attribute |
---|
| 104 | ret |
---|
| 105 | |
---|
| 106 | ALIGN JUMP_ALIGN |
---|
| 107 | DisplayCharOut_CharacterWithAttribute: |
---|
| 108 | stosw |
---|
| 109 | ret |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | ;-------------------------------------------------------------------- |
---|
| 113 | ; DisplayCharOut_WriteCharacterToBuffer |
---|
| 114 | ; Parameters: |
---|
| 115 | ; AL: Character to output |
---|
| 116 | ; DS: BDA segment (zero) |
---|
| 117 | ; ES:DI: Ptr to destination string buffer |
---|
| 118 | ; DISPLAY_CONTEXT.wCharOutParam: Offset to end of buffer (one past last) |
---|
| 119 | ; Returns: |
---|
| 120 | ; ES:DI: Updated for next character |
---|
| 121 | ; Corrupts registers: |
---|
| 122 | ; AX, DX |
---|
| 123 | ;-------------------------------------------------------------------- |
---|
| 124 | ALIGN JUMP_ALIGN |
---|
| 125 | DisplayCharOut_WriteCharacterToBuffer: |
---|
| 126 | cmp di, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam] |
---|
| 127 | jae SHORT .BufferFull |
---|
| 128 | stosb |
---|
| 129 | .BufferFull: |
---|
| 130 | ret |
---|