2007-03-18 21:28:51 +01:00
|
|
|
|
model tiny,stdcall
|
|
|
|
|
p586N
|
|
|
|
|
locals
|
|
|
|
|
jumps
|
|
|
|
|
codeseg
|
|
|
|
|
option procalign:byte
|
|
|
|
|
|
|
|
|
|
include "..\include\mem.h"
|
|
|
|
|
include "..\include\divers.h"
|
|
|
|
|
|
|
|
|
|
org 0h
|
|
|
|
|
|
|
|
|
|
header exe <"CE",1,0,0,offset exports,,,>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exporting
|
|
|
|
|
declare checksyntax
|
|
|
|
|
declare cmpitems
|
|
|
|
|
declare gettypeditem
|
|
|
|
|
declare gettyped
|
|
|
|
|
declare whatisitem
|
|
|
|
|
declare whatis
|
|
|
|
|
declare strtoadress
|
|
|
|
|
declare strisadress
|
|
|
|
|
declare strisname
|
|
|
|
|
declare strisbase
|
|
|
|
|
declare strtoint
|
|
|
|
|
declare left
|
|
|
|
|
declare right
|
|
|
|
|
declare middle
|
|
|
|
|
declare fill
|
|
|
|
|
declare replaceallchar
|
|
|
|
|
declare searchchar
|
|
|
|
|
declare invert
|
|
|
|
|
declare cmpstr
|
|
|
|
|
declare evalue
|
|
|
|
|
declare insert
|
|
|
|
|
declare delete
|
|
|
|
|
declare copy
|
|
|
|
|
declare concat
|
|
|
|
|
declare compressdelimiter
|
|
|
|
|
declare setnbitems
|
|
|
|
|
declare getitemsize
|
|
|
|
|
declare getitem
|
|
|
|
|
declare getpointeritem
|
|
|
|
|
declare getnbitems
|
|
|
|
|
declare getlength
|
|
|
|
|
declare setlength
|
|
|
|
|
declare uppercase
|
|
|
|
|
declare onecase
|
|
|
|
|
declare lowercase
|
|
|
|
|
declare invertcase
|
|
|
|
|
ende
|
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
|
;Librairie qui prend en charge le format de STR ASCIIZ
|
|
|
|
|
;# nombre 8
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;? str 7
|
2004-06-12 23:34:04 +02:00
|
|
|
|
;& nom 6
|
|
|
|
|
|
|
|
|
|
;High Low
|
|
|
|
|
;0 variable 4 hex
|
|
|
|
|
;1 byte 3 dec
|
|
|
|
|
;2 word 2 oct
|
|
|
|
|
;3 3 octets 1 bin
|
|
|
|
|
;4 dword 5 adresse
|
|
|
|
|
;5 5 octets 6 nom
|
|
|
|
|
;6 ... 7 str
|
|
|
|
|
; 8 nombre
|
|
|
|
|
|
|
|
|
|
;Renvoie carry si la syntaxe de ds:si n'est pas respect<63> par rapport a es:di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
PROC checksyntax FAR
|
|
|
|
|
ARG @src:word,@dest:word,@delim:word
|
|
|
|
|
USES ax,bx,cx,dx,si,di,ds,es
|
|
|
|
|
LOCAL @@temp:word:256
|
|
|
|
|
push ss
|
2004-06-12 23:34:04 +02:00
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
lea si,[@@temp]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
call copy,[@src],si
|
|
|
|
|
call xch
|
|
|
|
|
call compressdelimiter,si,[@delim]
|
|
|
|
|
call getnbitems,si,[@delim]
|
|
|
|
|
mov bx,ax
|
|
|
|
|
call xch
|
|
|
|
|
call getnbitems,di,[@delim]
|
|
|
|
|
cmp bx,ax
|
|
|
|
|
jne @@notequalatall
|
2004-06-12 23:34:04 +02:00
|
|
|
|
xor cx,cx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@itemer:
|
|
|
|
|
call xch
|
|
|
|
|
call whatisitem,si,cx,[@delim]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov dx,ax
|
2007-03-18 21:28:51 +01:00
|
|
|
|
call xch
|
|
|
|
|
call whatisitem,di,cx,[@delim]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp ax,dx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@prob
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,6
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jb @@equal
|
|
|
|
|
call cmpitems
|
|
|
|
|
je @@equal
|
|
|
|
|
@@prob:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp dl,4
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@nonumber
|
|
|
|
|
cmp dl,8
|
|
|
|
|
je @@equal
|
|
|
|
|
;cmp al,4
|
|
|
|
|
;jne @@notequalatall
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp dh,ah
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@notequalatall
|
|
|
|
|
jmp @@equal
|
|
|
|
|
@@nonumber:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,7
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@nostr
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp ah,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@notequalatall
|
|
|
|
|
jmp @@equal
|
|
|
|
|
@@nostr:
|
|
|
|
|
cmp al,6
|
|
|
|
|
jne @@noname
|
|
|
|
|
cmp dl,6
|
|
|
|
|
jne @@noname
|
|
|
|
|
cmp ah,0
|
|
|
|
|
jne @@notequalatall
|
|
|
|
|
jmp @@equal
|
|
|
|
|
@@noname:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,8
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@equal
|
|
|
|
|
jmp @@notequalatall
|
|
|
|
|
@@equal:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc cx
|
|
|
|
|
cmp cx,bx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@itemer
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@ackno:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@notequalatall:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
stc
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@ackno
|
|
|
|
|
endp checksyntax
|
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
|
xch:
|
|
|
|
|
push es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
push ds
|
2004-06-12 23:34:04 +02:00
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
pop ds
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;Compare les <20>l<EFBFBD>ments cx de deux chaine ds:si et es:di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
PROC cmpitems FAR
|
|
|
|
|
ARG @src:word,@dest:word,@item:word,@delim:word
|
|
|
|
|
USES ax,cx,si,di,es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
call getpointeritem,[@src],[@item],[@delim]
|
|
|
|
|
mov si,ax
|
|
|
|
|
call getitemsize,[@src],[@item],[@delim]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
mov cx,ax
|
|
|
|
|
cld
|
2004-06-12 23:34:04 +02:00
|
|
|
|
rep cmpsb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp cmpitems
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;Renvoie l'<27>l<EFBFBD>ment cx de ds:si dans edx si nb et dans es:di si str ou name
|
2007-03-18 21:28:51 +01:00
|
|
|
|
PROC gettypeditem FAR
|
|
|
|
|
ARG @src:word,@item:word,@delim:word
|
|
|
|
|
USES bx,cx,si,di
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov cx,[@item]
|
|
|
|
|
call getpointeritem,si,cx,[@delim]
|
|
|
|
|
mov di,ax
|
|
|
|
|
inc cx
|
|
|
|
|
call getpointeritem,si,cx,[@delim]
|
|
|
|
|
mov si,ax
|
|
|
|
|
dec si
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov cl,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
xchg cl,[ds:si]
|
|
|
|
|
call gettyped,di
|
|
|
|
|
xchg cl,[ds:si]
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp gettypeditem
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;Renvoie eax si nb et dans ds:eax si str ou name
|
|
|
|
|
PROC gettyped FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES si
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
xor eax,eax
|
|
|
|
|
call whatis,si
|
|
|
|
|
cmp al,1
|
|
|
|
|
je @@bin
|
|
|
|
|
cmp al,2
|
|
|
|
|
je @@oct
|
|
|
|
|
cmp al,3
|
|
|
|
|
je @@dec
|
|
|
|
|
cmp al,4
|
|
|
|
|
je @@hex
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,5
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@pointer
|
|
|
|
|
mov ax,si
|
|
|
|
|
jmp @@endofgettypeditem
|
|
|
|
|
@@bin:
|
|
|
|
|
call strtoint,si,2
|
|
|
|
|
jmp @@endofgettypeditem
|
|
|
|
|
@@oct:
|
|
|
|
|
call strtoint,si,8
|
|
|
|
|
jmp @@endofgettypeditem
|
|
|
|
|
@@dec:
|
|
|
|
|
call strtoint,si,10
|
|
|
|
|
jmp @@endofgettypeditem
|
|
|
|
|
@@hex:
|
|
|
|
|
call strtoint,si,16
|
|
|
|
|
jmp @@endofgettypeditem
|
|
|
|
|
@@pointer:
|
|
|
|
|
call strtoadress,si
|
|
|
|
|
@@endofgettypeditem:
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
endp gettyped
|
|
|
|
|
|
|
|
|
|
;Renvoie dans ax le type de la str0 point<6E>e par ds:%0 <20>l<EFBFBD>ment %1 delim %3
|
|
|
|
|
PROC whatisitem FAR
|
|
|
|
|
ARG @src:word,@item:word,@delim:word
|
|
|
|
|
USES bx,cx,si,di
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov cx,[@item]
|
|
|
|
|
call getpointeritem,si,cx,[@delim]
|
|
|
|
|
mov di,ax
|
|
|
|
|
inc cx
|
|
|
|
|
call getpointeritem,si,cx,[@delim]
|
|
|
|
|
mov si,ax
|
|
|
|
|
dec si
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov cl,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
xchg cl,[ds:si]
|
|
|
|
|
call whatis,di
|
|
|
|
|
xchg cl,[ds:si]
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp whatisitem
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Renvoie dans ax le type de la str0 point<6E>e par ds:%0
|
2004-06-12 23:34:04 +02:00
|
|
|
|
;High Low
|
|
|
|
|
;0 variable 4 hex
|
|
|
|
|
;1 byte 3 dec
|
|
|
|
|
;2 word 2 oct
|
|
|
|
|
;3 3 octets 1 bin
|
|
|
|
|
;4 dword 5 adresse
|
|
|
|
|
;5 5 octets 6 name
|
|
|
|
|
;6 ... 7 str
|
2007-03-18 21:28:51 +01:00
|
|
|
|
PROC whatis FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES bx,cx,edx,si
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
xor cx,cx
|
|
|
|
|
mov cl,2
|
|
|
|
|
call strisbase,si,cx
|
|
|
|
|
jnc @@finbase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov cl,8
|
2007-03-18 21:28:51 +01:00
|
|
|
|
call strisbase,si,cx
|
|
|
|
|
jnc @@finbase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov cl,10
|
2007-03-18 21:28:51 +01:00
|
|
|
|
call strisbase,si,cx
|
|
|
|
|
jnc @@finbase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov cl,16
|
2007-03-18 21:28:51 +01:00
|
|
|
|
call strisbase,si,cx
|
|
|
|
|
jc @@testadress
|
|
|
|
|
@@finbase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov bx,cx
|
|
|
|
|
xor ch,ch
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov al,[cs:bx+offset basenn-2]
|
|
|
|
|
push eax
|
|
|
|
|
call strtoint,si,cx
|
|
|
|
|
mov edx,eax
|
|
|
|
|
pop eax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp edx,0000FFFFh
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@bits32
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp dx,00FFh
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@bits16
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov ah,1
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@endofwhat
|
|
|
|
|
@@bits16:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov ah,2
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@endofwhat
|
|
|
|
|
@@bits32:
|
|
|
|
|
mov ah,4
|
|
|
|
|
jmp @@endofwhat
|
|
|
|
|
@@testadress:
|
|
|
|
|
call strisadress,si
|
|
|
|
|
jc @@testname
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov ax,0005h
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@endofwhat
|
|
|
|
|
@@testname:
|
|
|
|
|
call strisname
|
|
|
|
|
jc @@testnumber
|
|
|
|
|
xor ah,ah
|
|
|
|
|
cmp [byte ptr si],'&'
|
|
|
|
|
je @@okname
|
|
|
|
|
call getlength,si
|
|
|
|
|
mov ah,al
|
|
|
|
|
@@okname:
|
|
|
|
|
mov al,06h
|
|
|
|
|
jmp @@endofwhat
|
|
|
|
|
@@testnumber:
|
|
|
|
|
cmp [byte ptr si],'#'
|
|
|
|
|
jne @@testvarstr
|
|
|
|
|
xor ah,ah
|
|
|
|
|
mov al,08h
|
|
|
|
|
jmp @@endofwhat
|
|
|
|
|
@@testvarstr:
|
|
|
|
|
xor ah,ah
|
|
|
|
|
cmp [byte ptr si],'?'
|
|
|
|
|
je @@okvarstr
|
|
|
|
|
call getlength,si
|
|
|
|
|
mov ah,al
|
|
|
|
|
@@okvarstr:
|
|
|
|
|
mov al,07h
|
|
|
|
|
@@endofwhat:
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
endp whatis
|
|
|
|
|
|
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
;Renvoie non carry si la str ds:si point<6E>e peut <20>tre une adresse
|
2007-03-18 21:28:51 +01:00
|
|
|
|
PROC strtoadress FAR
|
2004-06-12 23:34:04 +02:00
|
|
|
|
;push
|
|
|
|
|
stc
|
|
|
|
|
;pop
|
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp strtoadress
|
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
;Renvoie en es:di le pointeur str0 ds:si
|
2007-03-18 21:28:51 +01:00
|
|
|
|
PROC strisadress FAR
|
2004-06-12 23:34:04 +02:00
|
|
|
|
;push
|
|
|
|
|
stc
|
|
|
|
|
;pop
|
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp strisadress
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Renvoie non carry si la str ds:%0 point<6E>e peut <20>tre un nom de fichier
|
|
|
|
|
PROC strisname FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES ax,si,di
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
@@isname:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov al,[si]
|
|
|
|
|
inc si
|
|
|
|
|
cmp al,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@itsok
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov di,offset non
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@verify:
|
|
|
|
|
mov ah,[cs:di]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc di
|
|
|
|
|
cmp ah,0FFh
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@isname
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp ah,al
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@verify
|
2004-06-12 23:34:04 +02:00
|
|
|
|
stc
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@itsdead
|
|
|
|
|
@@itsok:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
clc
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@itsdead:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp strisname
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
non db '/<>|"?*:\',01,0FFh
|
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Renvoie non carry si le texte point<6E> par %0 est de la base %1
|
|
|
|
|
PROC strisbase FAR
|
|
|
|
|
ARG @src:word,@base:word
|
|
|
|
|
USES ax,cx,si,di,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push cs
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov si,[@src]
|
|
|
|
|
@@isstrbase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov al,[si]
|
|
|
|
|
cmp al,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@okbase
|
|
|
|
|
mov cx,[@base]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
xor ch,ch
|
|
|
|
|
mov di,cx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
cmp al,[es:di-2+offset basen]
|
|
|
|
|
je @@verifbase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
xor ch,ch
|
|
|
|
|
inc cl
|
|
|
|
|
mov di,offset base
|
|
|
|
|
cld
|
|
|
|
|
repne scasb
|
|
|
|
|
cmp cx,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@nobase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc si
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@isstrbase
|
|
|
|
|
@@okbase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
clc
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@endbase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@verifbase:
|
|
|
|
|
cmp [byte ptr si+1],0
|
|
|
|
|
je @@okbase
|
|
|
|
|
@@nobase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
stc
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@endbase
|
|
|
|
|
endp strisbase
|
|
|
|
|
|
|
|
|
|
base db '0123456789ABCDEF'
|
|
|
|
|
basen db 'b o d h'
|
|
|
|
|
basenn db 1,0,0,0,0,0,2,0,3,0,0,0,0,0,4
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Converti un str %0 de base %1 en int dans eax
|
|
|
|
|
PROC strtoint FAR
|
|
|
|
|
ARG @src:word,@base:word
|
|
|
|
|
USES ebx,ecx,edx,si,edi,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push cs
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov si,[@src]
|
|
|
|
|
@@gotos:
|
|
|
|
|
cmp [byte ptr si+1], 0
|
|
|
|
|
je @@oklo
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc si
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@gotos
|
|
|
|
|
@@oklo:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov edi,1
|
2007-03-18 21:28:51 +01:00
|
|
|
|
xor ebx,ebx
|
|
|
|
|
@@baseto:
|
|
|
|
|
cmp [@src],si
|
|
|
|
|
ja @@endbaseto
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov al,[si]
|
|
|
|
|
xor ecx,ecx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov cl,[byte ptr @base]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc cl
|
|
|
|
|
push di
|
|
|
|
|
mov di,offset base
|
|
|
|
|
cld
|
|
|
|
|
repne scasb
|
|
|
|
|
pop di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@noop
|
|
|
|
|
sub cl,[byte ptr @base]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
neg cl
|
|
|
|
|
mov eax,edi
|
|
|
|
|
mul ecx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
add ebx,eax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov eax,edi
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov cl,[byte ptr @base]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mul ecx
|
|
|
|
|
mov edi,eax
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@noop:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
dec si
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@baseto
|
|
|
|
|
@@endbaseto:
|
|
|
|
|
mov eax,ebx
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
endp strtoint
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
|
|
|
|
|
;Renvoie en ds:%1 la partie de %2 caract<63>res a partir de la gauche de ds:%0
|
|
|
|
|
PROC left FAR
|
|
|
|
|
ARG @src:word,@dest:word,@nb:word
|
|
|
|
|
USES ax,cx,si,di,es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
mov cx,[@nb]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov al,0
|
|
|
|
|
stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp left
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Renvoie en ds:%1 la partie de %2 caract<63>res a partir de la droite de ds:%0
|
|
|
|
|
PROC right FAR
|
|
|
|
|
ARG @src:word,@dest:word,@nb:word
|
|
|
|
|
USES ax,cx,si,di,es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
call getlength,si
|
|
|
|
|
add si,ax
|
|
|
|
|
sub si,[@nb]
|
|
|
|
|
mov cx,[@nb]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov al,0
|
|
|
|
|
stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp right
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Renvoie en ds:%1 la partie de %3 caract<63>res a partir de la position %2 de ds:%0
|
|
|
|
|
PROC middle FAR
|
|
|
|
|
ARG @src:word,@dest:word,@item:word,@nb:word
|
|
|
|
|
USES ax,cx,si,di,es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
mov cx,[@nb]
|
|
|
|
|
add si,[@item]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov al,0
|
|
|
|
|
stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp middle
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Rempli de %3 caract<63>res %2 a partir de la position %1 de ds:%0
|
|
|
|
|
PROC fill FAR
|
|
|
|
|
ARG @src:word,@item:word,@char:word,@nb:word
|
|
|
|
|
USES ax,cx,si,di,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov di,[@src]
|
|
|
|
|
add di,[@item]
|
|
|
|
|
mov ax,[@char]
|
|
|
|
|
mov cx,[@nb]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
|
|
|
|
rep stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp fill
|
|
|
|
|
|
|
|
|
|
;Remplace tout les caract<63>res %1 de ds:%0 par des caract<63>res %2
|
|
|
|
|
PROC replaceallchar FAR
|
|
|
|
|
ARG @src:word,@char1:word,@char2:word
|
|
|
|
|
USES ax,cx,dx,di,es
|
|
|
|
|
mov di,[@src]
|
|
|
|
|
call getlength,di
|
|
|
|
|
mov cx,ax
|
|
|
|
|
mov ax,[@char1]
|
|
|
|
|
mov dx,[@char2]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@findandchange:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
repne scasb
|
|
|
|
|
cmp cx,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@endofchange
|
|
|
|
|
mov [es:di-1],dl
|
|
|
|
|
jmp @@findandchange
|
|
|
|
|
@@endofchange:
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp replaceallchar
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Recherche un caract<63>re dl dans la cha<68>ne ds:%0
|
|
|
|
|
PROC searchchar FAR
|
|
|
|
|
ARG @src:word,@char:word
|
|
|
|
|
USES cx,di,es
|
|
|
|
|
mov di,[@src]
|
|
|
|
|
call getlength,di
|
|
|
|
|
mov cx,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov ax,[@char]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
repne scasb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov ax,di
|
|
|
|
|
dec ax
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp searchchar
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Inverse la chaine point<6E>e en ds:%0
|
|
|
|
|
PROC invert FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES ax,cx,si,di
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
call getlength,si
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov di,si
|
2007-03-18 21:28:51 +01:00
|
|
|
|
add di,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
dec di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@revert:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov al,[si]
|
2007-03-18 21:28:51 +01:00
|
|
|
|
xchg al,[di]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov [si],al
|
|
|
|
|
inc si
|
|
|
|
|
dec di
|
|
|
|
|
cmp si,di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@finishinvert
|
2004-06-12 23:34:04 +02:00
|
|
|
|
dec di
|
|
|
|
|
cmp si,di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@finishinvert
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@revert
|
|
|
|
|
@@finishinvert:
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp invert
|
|
|
|
|
|
|
|
|
|
;Compares 2 chaines de caract<63>res DS:%0 et DS:%1 zerof si non equal
|
|
|
|
|
PROC cmpstr FAR
|
|
|
|
|
ARG @src:word,@dest:word
|
|
|
|
|
USES cx,dx,si,di
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
call getlength,si
|
|
|
|
|
mov cx,ax
|
|
|
|
|
call getlength,di
|
|
|
|
|
cmp cx,ax
|
|
|
|
|
jne @@notequal
|
2004-06-12 23:34:04 +02:00
|
|
|
|
repe cmpsb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@notequal:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp cmpstr
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Compares 2 chaines de caract<63>res DS:%0 et DS:%1 zerof si non equal et renvoie le nb de caract<63>re egaux dans ax
|
|
|
|
|
PROC evalue FAR
|
|
|
|
|
ARG @src:word,@dest:word
|
|
|
|
|
USES cx,si,di,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push es
|
|
|
|
|
pop ds
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
call getlength ,di
|
|
|
|
|
mov cx,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
repe cmpsb
|
|
|
|
|
pushf
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@noident
|
|
|
|
|
sub ax,cx
|
2004-06-12 23:34:04 +02:00
|
|
|
|
popf
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@noident:
|
|
|
|
|
sub ax,cx
|
|
|
|
|
dec ax
|
|
|
|
|
clc
|
|
|
|
|
popf
|
|
|
|
|
ret
|
|
|
|
|
endp evalue
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Insert une chaine ds:%0 en ds:%1 a partir du caract<63>re %2
|
|
|
|
|
PROC insert FAR
|
|
|
|
|
ARG @src:word,@dest:word,@item:word
|
|
|
|
|
USES ax,cx,si,di,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
pop ds
|
|
|
|
|
mov si,[@dest]
|
|
|
|
|
call getlength,si
|
|
|
|
|
mov cx,ax
|
|
|
|
|
add si,ax
|
|
|
|
|
mov di,si
|
|
|
|
|
call getlength,[@src]
|
|
|
|
|
add di,ax
|
|
|
|
|
sub cx,[@item]
|
|
|
|
|
inc cx
|
|
|
|
|
std
|
2004-06-12 23:34:04 +02:00
|
|
|
|
rep movsb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
add di,[@item]
|
|
|
|
|
mov cx,ax
|
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp insert
|
|
|
|
|
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Detruit %2 caract<63>res a partir du caract<63>re %1 de DS:%0
|
|
|
|
|
PROC delete FAR
|
|
|
|
|
ARG @src:word,@item:word,@size:word
|
|
|
|
|
USES ax,cx,dx,si,di,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov si,[@src]
|
|
|
|
|
call getlength,si
|
|
|
|
|
mov cx,ax
|
|
|
|
|
sub cx,[@size]
|
|
|
|
|
sub cx,[@item]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc cx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
add si,[@item]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov di,si
|
2007-03-18 21:28:51 +01:00
|
|
|
|
add si,[@size]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp delete
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
;Copie une chaine de ds:si en es:di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
PROC copy FAR
|
|
|
|
|
ARG @src:word,@dest:word
|
|
|
|
|
USES ax,cx,si,di
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
call getlength,si
|
|
|
|
|
mov cx,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov al,0
|
|
|
|
|
stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp copy
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Concat<61>ne le chaine ds:si avec ds:di
|
|
|
|
|
PROC concat FAR
|
|
|
|
|
ARG @src:word,@dest:word
|
|
|
|
|
USES ax,cx,si,di,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
2007-03-18 21:28:51 +01:00
|
|
|
|
pop es
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
call getlength,si
|
|
|
|
|
mov cx,ax
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
call getlength,di
|
|
|
|
|
add di,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov al,0
|
|
|
|
|
stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp concat
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;D<>truit les d<>limiteur qui sont cons<6E>cutifs dans ds:%0 -> renvoie le nb d'item
|
|
|
|
|
PROC compressdelimiter FAR
|
|
|
|
|
ARG @src:word,@delim:word
|
|
|
|
|
USES cx,dx,si,di,es
|
|
|
|
|
mov di,[@src]
|
|
|
|
|
call getlength,di
|
|
|
|
|
mov cx,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov ax,[@delim]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
xor dx,dx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@compressitems:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
repne scasb
|
|
|
|
|
inc dx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@againcomp:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp [di],al
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@nosup
|
|
|
|
|
call delete,di,0,1
|
|
|
|
|
jmp @@againcomp
|
|
|
|
|
@@nosup:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp cx,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@compressitems
|
|
|
|
|
mov ax,dx
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
endp compressdelimiter
|
|
|
|
|
|
|
|
|
|
;Met le nombre d'<27>l<EFBFBD>ments de ds:%0 <20> %1
|
|
|
|
|
PROC setnbitems FAR
|
|
|
|
|
ARG @src:word,@size:word,@delim:word
|
|
|
|
|
USES ax,cx,di,es
|
|
|
|
|
mov di,[@src]
|
|
|
|
|
cmp [@size],0
|
|
|
|
|
je @@onlyzero
|
|
|
|
|
call getnbitems,di,[@delim]
|
|
|
|
|
cmp [@size],ax
|
|
|
|
|
je @@noadjust
|
|
|
|
|
jb @@subsome
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
sub ax,[@size]
|
|
|
|
|
neg ax
|
|
|
|
|
mov cx,ax
|
|
|
|
|
call getlength,di
|
|
|
|
|
add di,ax
|
|
|
|
|
mov ax,[@delim]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov ah,'a'
|
|
|
|
|
rep stosw
|
2007-03-18 21:28:51 +01:00
|
|
|
|
xor al,al
|
2004-06-12 23:34:04 +02:00
|
|
|
|
stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jmp @@noadjust
|
|
|
|
|
@@subsome:
|
|
|
|
|
call getpointeritem,[@src],[@size],[@delim]
|
|
|
|
|
dec ax
|
|
|
|
|
mov di,ax
|
|
|
|
|
@@onlyzero:
|
|
|
|
|
mov [byte ptr di],0
|
|
|
|
|
@@noadjust:
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp setnbitems
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Renvoie la taille ax de l'<27>l<EFBFBD>ment %0
|
|
|
|
|
PROC getitemsize FAR
|
|
|
|
|
ARG @src:word,@item:word,@delim:word
|
|
|
|
|
USES cx,dx
|
|
|
|
|
mov cx,[@item]
|
|
|
|
|
call getpointeritem,[@src],cx,[@delim]
|
|
|
|
|
mov dx,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc cx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
call getpointeritem,[@src],cx,[@delim]
|
|
|
|
|
sub ax,dx
|
|
|
|
|
dec ax
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp getitemsize
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Renvoie en ds:%1 l'<27>l<EFBFBD>ment %2 de ds:%0
|
|
|
|
|
PROC getitem FAR
|
|
|
|
|
ARG @src:word,@dest:word,@item:word,@delim:word
|
|
|
|
|
USES ax,cx,si,di,es
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
call getpointeritem,[@src],[@item],[@delim]
|
|
|
|
|
mov si,ax
|
|
|
|
|
call getitemsize,[@src],[@item],[@delim]
|
|
|
|
|
mov di,[@dest]
|
|
|
|
|
mov cx,ax
|
|
|
|
|
cld
|
2004-06-12 23:34:04 +02:00
|
|
|
|
rep movsb
|
|
|
|
|
mov al,0
|
|
|
|
|
stosb
|
2007-03-18 21:28:51 +01:00
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp getitem
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;renvoi un pointeur ax sur l'<27>l<EFBFBD>ment %1 de ds:%0
|
|
|
|
|
PROC getpointeritem FAR
|
|
|
|
|
ARG @src:word,@item:word,@delim:word
|
|
|
|
|
USES cx,dx,di,es
|
|
|
|
|
mov di,[@src]
|
|
|
|
|
cmp [@item],0
|
|
|
|
|
je @@finishpointer
|
|
|
|
|
push ds
|
|
|
|
|
pop es
|
|
|
|
|
call getlength,di
|
|
|
|
|
mov cx,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov ax,[@delim]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
xor dx,dx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@countnbitems:
|
|
|
|
|
cmp [@item],dx
|
|
|
|
|
je @@finishpointer
|
|
|
|
|
cld
|
2004-06-12 23:34:04 +02:00
|
|
|
|
repne scasb
|
|
|
|
|
inc dx
|
|
|
|
|
cmp cx,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@countnbitems
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc di
|
2007-03-18 21:28:51 +01:00
|
|
|
|
@@finishpointer:
|
|
|
|
|
mov ax,di
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp getpointeritem
|
|
|
|
|
|
|
|
|
|
;Renvoie le nombre d'<27>l<EFBFBD>ments ax de ds:%0
|
|
|
|
|
PROC getnbitems FAR
|
|
|
|
|
ARG @src:word,@delim:word
|
|
|
|
|
USES cx,dx,di,es
|
|
|
|
|
mov di,[@src]
|
|
|
|
|
call getlength,di
|
|
|
|
|
mov cx,ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov ax,[@delim]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
xor dx,dx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
cld
|
|
|
|
|
@@countitems:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
repne scasb
|
|
|
|
|
inc dx
|
|
|
|
|
cmp cx,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jne @@countitems
|
|
|
|
|
mov ax,dx
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp getnbitems
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;renvoie la taille en octets AX de la chaine point<6E>e en ds:%0
|
|
|
|
|
PROC getlength FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES cx,di,es
|
2004-06-12 23:34:04 +02:00
|
|
|
|
push ds
|
|
|
|
|
pop es
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov di,[@src]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov al,0
|
|
|
|
|
mov cx,0FFFFh
|
|
|
|
|
cld
|
|
|
|
|
repne scasb
|
|
|
|
|
neg cx
|
|
|
|
|
dec cx
|
|
|
|
|
dec cx
|
2007-03-18 21:28:51 +01:00
|
|
|
|
mov ax,cx
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp getlength
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Met la taille en octets de la chaine point<6E>e ds:%0 a %1
|
|
|
|
|
PROC setlength FAR
|
|
|
|
|
ARG @src:word,@size:word
|
|
|
|
|
USES si
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
add si,[@size]
|
|
|
|
|
mov [byte ptr si],0
|
|
|
|
|
clc
|
2004-06-12 23:34:04 +02:00
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp setlength
|
|
|
|
|
|
|
|
|
|
;met en majuscule la chaine ds:%0
|
|
|
|
|
PROC uppercase FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES si,ax
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
@@uppercase:
|
|
|
|
|
mov al,[ds:si]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc si
|
|
|
|
|
cmp al,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@enduppercase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'a'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jb @@uppercase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'z'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@uppercase
|
|
|
|
|
sub [byte ptr si-1],'a'-'A'
|
|
|
|
|
jmp @@uppercase
|
|
|
|
|
@@enduppercase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp uppercase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;met en majuscule la premi<6D>re lettre chaine ds:%0
|
|
|
|
|
PROC onecase FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES ax
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
mov al,[ds:si]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'a'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jb @@oneenduppercase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'z'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@oneenduppercase
|
|
|
|
|
sub [byte ptr si],'a'-'A'
|
|
|
|
|
@@oneenduppercase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp onecase
|
|
|
|
|
|
|
|
|
|
;met en minuscule la chaine ds:%0
|
|
|
|
|
PROC lowercase FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES si,ax
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
@@lowercase:
|
|
|
|
|
mov al,[ds:si]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc si
|
|
|
|
|
cmp al,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@endlowercase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'A'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jb @@lowercase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'Z'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@lowercase
|
|
|
|
|
add [byte ptr si-1],'a'-'A'
|
|
|
|
|
jmp @@lowercase
|
|
|
|
|
@@endlowercase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp lowercase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-18 21:28:51 +01:00
|
|
|
|
;Inverse la casse la chaine ds:%0
|
|
|
|
|
PROC invertcase FAR
|
|
|
|
|
ARG @src:word
|
|
|
|
|
USES si,ax
|
|
|
|
|
mov si,[@src]
|
|
|
|
|
@@invertcase:
|
|
|
|
|
mov al,[ds:si]
|
2004-06-12 23:34:04 +02:00
|
|
|
|
inc si
|
|
|
|
|
cmp al,0
|
2007-03-18 21:28:51 +01:00
|
|
|
|
je @@endinvertcase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'A'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jb @@invertcase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'Z'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jbe @@goinvertcase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'a'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
jb @@invertcase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
cmp al,'z'
|
2007-03-18 21:28:51 +01:00
|
|
|
|
ja @@invertcase
|
|
|
|
|
sub [byte ptr si-1],'a'-'A'
|
|
|
|
|
jmp @@invertcase
|
|
|
|
|
@@goinvertcase:
|
|
|
|
|
add [byte ptr si-1],'a'-'A'
|
|
|
|
|
jmp @@invertcase
|
|
|
|
|
@@endinvertcase:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2007-03-18 21:28:51 +01:00
|
|
|
|
endp invertcase
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|