cos2000v1/lib/str0.asm

917 lines
20 KiB
NASM
Raw Normal View History

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