[3] | 1 | ; File name : PrintString.asm
|
---|
| 2 | ; Project name : IDE BIOS
|
---|
| 3 | ; Created date : 19.3.2010
|
---|
| 4 | ; Last update : 31.3.2010
|
---|
| 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Functions for printing strings used in this IDE BIOS.
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | ; Section containing code
|
---|
| 10 | SECTION .text
|
---|
| 11 |
|
---|
| 12 | ;--------------------------------------------------------------------
|
---|
| 13 | ; Prints string with formatting parameters.
|
---|
| 14 | ; Do not call PrintString_JumpToFormat!!! Jump there only!
|
---|
| 15 | ;
|
---|
| 16 | ; PrintString_JumpToFormat
|
---|
| 17 | ; Parameters:
|
---|
| 18 | ; DH: Number of bytes pushed to stack
|
---|
| 19 | ; CS:SI: Ptr to string to format
|
---|
| 20 | ; Stack: Parameters for formatting placeholders.
|
---|
| 21 | ; Parameter for first placeholder must be pushed last
|
---|
| 22 | ; (to top of stack).
|
---|
| 23 | ; High word must be pushed first for 32-bit parameters.
|
---|
| 24 | ; Returns:
|
---|
| 25 | ; Nothing
|
---|
| 26 | ; Corrupts registers:
|
---|
| 27 | ; AX, CX, DX, SI
|
---|
| 28 | ;--------------------------------------------------------------------
|
---|
| 29 | ALIGN JUMP_ALIGN
|
---|
| 30 | PrintString_JumpToFormat:
|
---|
| 31 | mov cx, ds ; Backup DS
|
---|
| 32 | push cs ; Push string segment...
|
---|
| 33 | pop ds ; ...and pop it to DS
|
---|
| 34 | mov dl, ' ' ; Min length character
|
---|
| 35 | call Print_Format
|
---|
| 36 | mov ds, cx ; Restore DS
|
---|
| 37 | eMOVZX ax, dh ; Bytes in stack
|
---|
| 38 | add sp, ax ; Clean stack
|
---|
| 39 | ret
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | ;--------------------------------------------------------------------
|
---|
| 43 | ; Prints STOP terminated string from wanted segment.
|
---|
| 44 | ;
|
---|
| 45 | ; PrintString_FromCS
|
---|
| 46 | ; PrintString_FromES
|
---|
| 47 | ; PrintString_FromDS
|
---|
| 48 | ; Parameters:
|
---|
| 49 | ; SI: Offset to string to print
|
---|
| 50 | ; Returns:
|
---|
| 51 | ; Nothing
|
---|
| 52 | ; Corrupts registers:
|
---|
| 53 | ; AX, DX
|
---|
| 54 | ;--------------------------------------------------------------------
|
---|
| 55 | ALIGN JUMP_ALIGN
|
---|
| 56 | PrintString_FromCS:
|
---|
| 57 | push ds
|
---|
| 58 | push cs ; Push string segment...
|
---|
| 59 | pop ds ; ...and pop it to DS
|
---|
| 60 | call PrintString_FromDS
|
---|
| 61 | pop ds
|
---|
| 62 | ret
|
---|
| 63 |
|
---|
| 64 | ALIGN JUMP_ALIGN
|
---|
| 65 | PrintString_FromES:
|
---|
| 66 | push ds
|
---|
| 67 | push es ; Push string segment...
|
---|
| 68 | pop ds ; ...and pop it to DS
|
---|
| 69 | call PrintString_FromDS
|
---|
| 70 | pop ds
|
---|
| 71 | ret
|
---|
| 72 |
|
---|
| 73 | ALIGN JUMP_ALIGN
|
---|
| 74 | PrintString_FromDS:
|
---|
| 75 | mov dx, si ; DS:DX now points to string
|
---|
| 76 | PRINT_STR_LEN
|
---|
| 77 | ret
|
---|