1
by brian
clean slate |
1 |
; Copyright (C) 2000 MySQL AB
|
2 |
;
|
|
3 |
; This library is free software; you can redistribute it and/or
|
|
4 |
; modify it under the terms of the GNU Library General Public
|
|
5 |
; License as published by the Free Software Foundation; version 2
|
|
6 |
; of the License.
|
|
7 |
;
|
|
8 |
; This library is distributed in the hope that it will be useful,
|
|
9 |
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11 |
; Library General Public License for more details.
|
|
12 |
;
|
|
13 |
; You should have received a copy of the GNU Library General Public
|
|
14 |
; License along with this library; if not, write to the Free
|
|
15 |
; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
16 |
; MA 02111-1307, USA
|
|
17 |
||
18 |
TITLE Optimized strxmov for MSDOS / Intel 8086 |
|
19 |
||
20 |
ifndef M_I386 |
|
21 |
.8087
|
|
22 |
DOSSEG
|
|
23 |
.MODEL LARGE |
|
24 |
.CODE
|
|
25 |
||
26 |
PUBLIC _strxmov |
|
27 |
_strxmov PROC |
|
28 |
mov bx,sp |
|
29 |
add bx,4 |
|
30 |
push si |
|
31 |
push di |
|
32 |
mov cx,ds ; Save ds |
|
33 |
ASSUME DS: NOTHING |
|
34 |
ASSUME ES: NOTHING |
|
35 |
les di,DWORD PTR ss:[bx] ; dst |
|
36 |
jmp next_str |
|
37 |
||
38 |
start_str:
|
|
39 |
mov al,ds:[si] |
|
40 |
movsb ; move arg |
|
41 |
and al,al |
|
42 |
jnz start_str ; Not last |
|
43 |
dec di |
|
44 |
||
45 |
next_str:
|
|
46 |
add bx,4 |
|
47 |
lds si,DWORD PTR ss:[bx] |
|
48 |
mov ax,ds |
|
49 |
or ax,si |
|
50 |
jnz start_str |
|
51 |
||
52 |
mov byte ptr es:[di],0 ; Force end null (if no source) |
|
53 |
mov ds,cx |
|
54 |
mov ax,di ; Return ptr to last 0 |
|
55 |
mov dx,es |
|
56 |
pop di |
|
57 |
pop si |
|
58 |
ret
|
|
59 |
_strxmov ENDP |
|
60 |
||
61 |
else
|
|
62 |
||
63 |
include macros.asm |
|
64 |
||
65 |
begcode strxmov |
|
66 |
public _strxmov |
|
67 |
||
68 |
_strxmov PROC near |
|
69 |
ASSUME DS: NOTHING |
|
70 |
ASSUME ES: NOTHING |
|
71 |
push EBP |
|
72 |
mov EBP,ESP |
|
73 |
mov EDX,EBX ; Save EBX |
|
74 |
mov ECX,ESI ; Save ESI |
|
75 |
push EDI |
|
76 |
mov EDI,8[EBP] ; Get destination |
|
77 |
lea EBX,8[EBP] ; Get adress to first source - 4 |
|
78 |
xor al,al |
|
79 |
jmp next_str |
|
80 |
||
81 |
start_str: movsb |
|
82 |
cmp AL,[EDI-1] |
|
83 |
jne start_str |
|
84 |
dec EDI ; Don't copy last null |
|
85 |
||
86 |
next_str: add EBX,4 |
|
87 |
mov ESI,[EBX] |
|
88 |
or ESI,ESI |
|
89 |
jne start_str |
|
90 |
mov byte ptr [EDI],0 ; Force last null |
|
91 |
||
92 |
mov EAX,EDI ; Return ptr to null |
|
93 |
pop EDI |
|
94 |
mov ESI,ECX |
|
95 |
mov EBX,EDX |
|
96 |
pop EBP |
|
97 |
ret
|
|
98 |
_strxmov endp |
|
99 |
endcode strxmov |
|
100 |
||
101 |
endif
|
|
102 |
||
103 |
END
|