source: xtideuniversalbios/trunk/Assembly_Library/Src/String/StringProcess.asm@ 319

Last change on this file since 319 was 162, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Size optimizations, mostly by excluding code from the BIOS.
  • Cleaned the source a bit, fixed spelling and grammar mistakes.
File size: 2.9 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for processing characters in a string.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Character processing callback function prototype for StringProcess_DSSIwithFunctionInDX.
9; Parameters:
10; AL: Character to process
11; CX: Character number (index for next character)
12; DS:SI: Ptr to next character
13; BX,DI,ES: Free to use by processing function
14; Returns:
15; CF: Clear to continue with next character
16; Set to stop processing
17; BX,DI,ES: Free to use by processing function
18; Corrupts registers:
19; AX
20;--------------------------------------------------------------------
21
22
23;--------------------------------------------------------------------
24; StringProcess_DSSIwithFunctionInDX
25; Parameters:
26; DX: Character processing function
27; DS:SI: Ptr to NULL terminated string to convert
28; Returns:
29; CX: Number of characters processed
30; CF: Clear if all characters processed
31; Set if terminated by processing function
32; Corrupts registers:
33; Nothing (processing function can corrupt BX,DI,ES)
34;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36StringProcess_DSSIwithFunctionInDX:
37 push si
38 push ax
39
40 xor cx, cx
41ALIGN JUMP_ALIGN
42.ProcessNextCharacter:
43 lodsb
44 test al, al ; NULL to end string
45 jz SHORT .EndOfString ; Return with CF cleared
46 inc cx
47 call dx
48 jnc SHORT .ProcessNextCharacter
49
50ALIGN JUMP_ALIGN
51.EndOfString:
52 pop ax
53 pop si
54 ret
55
56
57;--------------------------------------------------------------------
58; StringProcess_ConvertToLowerCase (callback function for StringProcess_DSSIwithFunctionInDX)
59; Parameters:
60; AL: Character to convert to lower case
61; DS:SI: Ptr to next character
62; Returns:
63; CF: Clear to continue processing
64; Corrupts registers:
65; AL
66;--------------------------------------------------------------------
67ALIGN JUMP_ALIGN
68StringProcess_ConvertToLowerCase:
69 call Char_ALtoLowerCaseLetter
70 mov [si-1], al
71 clc
72 ret
73
74
75;--------------------------------------------------------------------
76; StringProcess_ConvertToWordInDIWithBaseInBX (callback function for StringProcess_DSSIwithFunctionInDX)
77; Parameters:
78; AL: Character to convert to lower case
79; BX: Numeric base (2, 10 or 16)
80; Returns:
81; CF: Clear to continue processing
82; Set if error
83; Corrupts registers:
84; AX
85;--------------------------------------------------------------------
86ALIGN JUMP_ALIGN
87StringProcess_ConvertToWordInDIWithBaseInBX:
88 call Char_ConvertIntegerToALfromDigitInALwithBaseInBX
89 cmc
90 jc SHORT .InvalidCharacter
91 push dx
92
93 xor ah, ah ; Digit converted to integer now in AX
94 xchg ax, di
95 mul bx ; Old WORD *= base
96 jc SHORT .Overflow
97 add di, ax ; Add old WORD to new integer
98
99.Overflow:
100 pop dx
101.InvalidCharacter:
102 ret
Note: See TracBrowser for help on using the repository browser.