Changeset 52 in xtideuniversalbios for trunk/Assembly_Library/Src/String
- Timestamp:
- Oct 12, 2010, 6:51:07 PM (14 years ago)
- google:author:
- aitotat
- Location:
- trunk/Assembly_Library/Src/String
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Src/String/String.asm
r46 r52 2 2 ; Project name : Assembly Library 3 3 ; Created date : 12.7.2010 4 ; Last update : 1 .10.20104 ; Last update : 12.10.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Functions for handling characters. … … 16 16 ; Returns: 17 17 ; AX: Word converted from string 18 ; DI: Offset to NULL or first invalid character19 ; CF: Set if conversionsuccessfull20 ; Cleared if invalid string18 ; SI: Updated 19 ; CF: Cleared if successfull 20 ; Set if error during conversion 21 21 ; Corrupts registers: 22 ; DX22 ; Nothing 23 23 ;-------------------------------------------------------------------- 24 24 ALIGN JUMP_ALIGN 25 25 String_ConvertWordToAXfromStringInDSSIwithBaseInBX: 26 xor dx, dx27 cld26 push di 27 push dx 28 28 29 ALIGN JUMP_ALIGN 30 .ConvertWordToAXfromStringInDSSIwithBaseInBX: 31 lodsb ; Load character from DS:SI to AL 32 call Char_ConvertIntegerToALfromDigitInALwithBaseInBX 33 jnc SHORT .InvalidCharacter 34 xor ah, ah 35 push ax ; Push integer 36 xchg ax, dx ; Copy WORD to AX 37 mul bx ; DX:AX = word in AX * base in BX 38 pop dx ; Pop integer 39 add dx, ax ; WORD back to DX 40 jmp SHORT .ConvertWordToAXfromStringInDSSIwithBaseInBX 29 xor di, di 30 mov dx, StringProcess_ConvertToWordInDIWithBaseInBX 31 call StringProcess_DSSIwithFunctionInDX 32 xchg ax, di 41 33 42 ALIGN JUMP_ALIGN 43 .InvalidCharacter: 44 sub al, 1 ; Set CF if NULL character, clear CF otherwise 45 xchg ax, dx ; Return WORD in AX 34 pop dx 35 pop di 46 36 ret 47 37 48 38 49 39 ;-------------------------------------------------------------------- 50 ; String_Copy ToESDIfromDSSIwithoutTerminatingESDI40 ; String_CopyDSSItoESDIandGetSizeToCX 51 41 ; Parameters: 52 42 ; DS:SI: Ptr to source NULL terminated string … … 59 49 ;-------------------------------------------------------------------- 60 50 ALIGN JUMP_ALIGN 61 String_Copy ToESDIfromDSSIwithoutTerminatingESDI:51 String_CopyDSSItoESDIandGetSizeToCX: 62 52 push ax 53 63 54 xor cx, cx 64 65 55 ALIGN JUMP_ALIGN 66 . GetAndStoreNewCharacter:56 .CopyNextCharacter: 67 57 lodsb ; Load from DS:SI to AL 68 58 test al, al ; NULL to end string? … … 70 60 stosb ; Store from AL to ES:DI 71 61 inc cx ; Increment number of characters written 72 jmp SHORT . GetAndStoreNewCharacter62 jmp SHORT .CopyNextCharacter 73 63 74 64 ALIGN JUMP_ALIGN … … 79 69 80 70 ;-------------------------------------------------------------------- 81 ; String_ ConvertDSSItoLowerCase71 ; String_GetLengthFromDSSItoCX 82 72 ; Parameters: 83 ; DS:SI: Ptr to NULL terminated string to convert73 ; DS:SI: Ptr to NULL terminated string 84 74 ; Returns: 85 ; Nothing75 ; CX: String length in characters 86 76 ; Corrupts registers: 87 77 ; Nothing 88 78 ;-------------------------------------------------------------------- 89 79 ALIGN JUMP_ALIGN 90 String_ConvertDSSItoLowerCase: 80 String_GetLengthFromDSSItoCX: 81 push ax 91 82 push si 92 push ax93 83 94 ALIGN JUMP_ALIGN 95 .ConvertNextCharacter: 96 lodsb 97 test al, al ; NULL to end string? 98 jz SHORT .EndOfString 99 call Char_ALtoLowerCaseLetter 100 mov [si-1], al 101 jmp SHORT .ConvertNextCharacter 84 call Memory_ExchangeDSSIwithESDI 85 xor ax, ax ; Find NULL 86 mov cx, -1 ; Full segment if necessary 87 repne scasb 88 mov cx, di 89 call Memory_ExchangeDSSIwithESDI 102 90 103 ALIGN JUMP_ALIGN 104 .EndOfString: 91 pop si 92 stc 93 sbb cx, si ; Subtract NULL 105 94 pop ax 106 pop si107 95 ret
Note:
See TracChangeset
for help on using the changeset viewer.