home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUIN
/
ASCIIZ.PAS
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
1KB
|
54 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 594 of 614
From : Sean Palmer 1:104/123.0 18 Jun 93 03:52
To : All
Subj : asciiz to string
────────────────────────────────────────────────────────────────────────────────
Anyone have any use for these?
these routines change formats 'in place' without changing the number of
bytes, ever, so you can safely use {$V-} here, DJ! 8)}
unit asciiz; {routines for converting strings to asciiz and back}
interface
procedure asciiz2string(var a:string);
procedure string2asciiz(var s:string);
implementation
{note: any asciiz must be length 255 or less}
procedure asciiz2string(var a:string);assembler;asm
push ds;
cld;
lds si,a;
mov cx,0;
@L:
xchg al,byte ptr[si];
inc si;
or al,al;
jnz @L;
mov ax,si
mov si,word ptr a
sub ax,si {calc length}
dec ax
mov [si],al
pop ds;
end;
procedure string2asciiz(var s:string);assembler;asm
push ds;
lds si,s
les di,s
lodsb
mov cl,al
xor ch,ch
cld
rep movsb
xor al,al
stosb
pop ds
end;
end.