Memory Manipulation

Reference Section

_fmem_ccpy
_fmem_chr
_fmem_chri
_fmem_chrn
_fmem_chrni
_fmem_cmp
_fmem_cmpi
_fmem_cpy
_fmem_cpye
_fmem_cspn
_fmem_lwr
_fmem_mem
_fmem_memi
_fmem_mov
_fmem_pbrk
_fmem_pbrkn
_fmem_rev
_fmem_set
_fmem_skips
_fmem_skipw
_fmem_spn
_fmem_swab
_fmem_upr
_mem_ccpy
_mem_chr
_mem_chri
_mem_chrn
_mem_chrni
_mem_cmp
_mem_cmpi
_mem_cpy
_mem_cpye
_mem_cspn
_mem_lwr
_mem_mem
_mem_memi
_mem_mov
_mem_pbrk
_mem_pbrkn
_mem_rev
_mem_set
_mem_skips
_mem_skipw
_mem_spn
_mem_swab
_mem_upr

_fmem_ccpy


Descrip
Copies the contents of a block to another location, up to a given character or a maximum number of characters.

Syntax
#include <memmanip.h>
void far *_fmem_ccpy (void far *destblk, const void far *srcblk, int chr, unsigned int *num);

Notes
See _mem_ccpy.

Source file _MMFCCPY.ASM ASM equiv MEM_CCPY

_fmem_chr


Descrip
Searches a block for the first occurrence of a character.

Syntax
#include <memmanip.h>
void far *_fmem_chr(const void far *block, int chr, unsigned int *num);

Notes
See mem_chr.

Source file _MMFCHR.ASM ASM equiv MEM_CHR

_fmem_chri


Descrip
Searches a block for the first occurrence of a character, ignoring case.

Syntax
#include <memmanip.h>
void far *_fmem_chri(const void far *block, int chr, unsigned int *num);

Notes
See _mem_chri.

Source file _MMFCHRI.ASM ASM equiv MEM_CHRI

_fmem_chrn


Descrip
Searches a block for the first occurrence of a character which is not the given character.

Syntax
#include <memmanip.h>
void far *_fmem_chrn(const void far *block, int chr, unsigned int *num);

Notes
See mem_chrn.

Source file _MMFCHRN.ASM ASM equiv MEM_CHRN

_fmem_chrni


Descrip
Searches a block for the first occurrence of a character which is not the given character, ignoring case.

Syntax
#include <memmanip.h>
void far *_fmem_chrni(const void far *block, int chr, unsigned int *num);

Notes
See mem_chrni.

Source file _MMFCHNI.ASM ASM equiv MEM_CHRNI

_fmem_cmp


Descrip
Compares one block with another.

Syntax
#include <memmanip.h>
int _fmem_cmp(const void far *block1, const void far *block2, unsigned int num);

Notes
See _mem_cmp.
Source file _MMFCMP.ASM ASM equiv MEM_CMP

_fmem_cmpi


Descrip
Compares one block with another, ignoring case.

Syntax
#include <memmanip.h>
int _fmem_cmpi(const void far *block1, const void far *block2, unsigned int num);

Notes
See _mem_cmpi.

Source file _MMFCMPI.ASM ASM equiv MEM_CMPI

_fmem_cpy


Descrip
Copies the contents of a block to another location.

Syntax
#include <memmanip.h>
void far *_fmem_cpy(void far *destblk, const void far *srcblk, unsigned int num);

Notes
See _mem_cpy.

Source file _MMFCPY.ASM ASM equiv MEM_CPY

_fmem_cpye


Descrip
Copies the contents of a block to another location and returns the address of the end of the destination block.

Syntax
#include <memmanip.h>
void far *_fmem_cpye(void far *destblk, const void far *srcblk, unsigned int num);

Notes
See _mem_cpye.

Source file _MMFCPYE.ASM ASM equiv MEM_CPYE

_fmem_cspn


Descrip
Determines the number of characters at the beginning of a block which do not match any character in a given character set.

Syntax
#include <memmanip.h>
unsigned int _fmem_cspn(const void far *block, const void far *charset,
unsigned int num);

Notes
See _mem_cspn.

Source file _MMFCSPN.ASM ASM equiv MEM_CSPN

_fmem_lwr


Descrip
Converts uppercase characters in a block to lowercase.

Syntax
#include <memmanip.h>
void far *_fmem_lwr(void far *block, unsigned int num);

Notes
See _mem_lwr.

Source file _MMFLWR.ASM ASM equiv MEM_LWR

_fmem_mem


Descrip
Searches a block for the first occurrence of the contents of another block.

Syntax
#include <memmanip.h>
int _fmem_mem(void far * * lookblk, unsigned int *looksize, void far * * findblk, unsigned int *findsize);

Notes
See _mem_mem.

Source file _MMFMEM.ASM ASM equiv MEM_MEM

_fmem_memi


Descrip
Searches a block for the first occurrence of another block, ignoring case.

Syntax
#include <memmanip.h>
int _fmem_memi(void far * * lookblk, unsigned int *looksize, void far * * findblk, unsigned int *findsize);

Notes
See _mem_memi.

Source file _MMFMEMI.ASM ASM equiv MEM_MEMI

_fmem_mov


Descrip
Copies the contents of a block to another location.

Syntax
#include <memmanip.h>
void far *_fmem_mov(void far *destblk, const void far *srcblk, unsigned int num);

Notes
See _mem_mov.

Source file _MMFMOV.ASM ASM equiv MEM_MOV

_fmem_pbrk


Descrip
Searches a block for the first occurrence of any character which is in a set of characters.

Syntax
#include <memmanip.h>
void far *_fmem_pbrk(const void far *block, const void far *charset,
unsigned int *num);

Notes
See _mem_pbrk.

Source file _MMFPBRK.ASM ASM equiv MEM_PBRK

_fmem_pbrkn


Descrip
Searches a block for the first occurrence of any character which is not in a set of characters.

Syntax
#include <memmanip.h>
void far *_fmem_pbrkn(const void *block, const void far *charset, unsigned int *num);

Returns
A pointer to the first occurrence of a character in block that is not in charset if one was found.
num size of block from matching character to end of block

NULL if all of the characters in block were found in charset.

Notes
See _mem_pbrkn.

Source file _MMFPBKN.ASM ASM equiv MEM_PBRKN

_fmem_rev


Descrip
Reverses the order of the bytes in a block.

Syntax
#include <memmanip.h>
void *_mem_rev(void *block, unsigned int num);

Returns
A pointer to block.

Notes
See _mem_rev.

Source file _MMFREV.ASM ASM equiv MEM_REV

_fmem_set


Descrip
Sets all characters in a block to a specified character.

Syntax
#include <memmanip.h>
void far *_fmem_set(void far *block, int chr, unsigned int num);

Notes
See _mem_set.

Source file _MMFSET.ASM ASM equiv MEM_SET

_fmem_skips


Descrip
Skips past all space characters in a block.

Syntax
#include <memmanip.h>
void far *_fmem_skips(const void far *block, unsigned int *num);

Notes
See _mem_skips.

Source file _MMFSKPS.ASM ASM equiv MEM_SKIPS

_fmem_skipw


Descrip
Skips past all whitespace characters in a block.

Syntax
#include <memmanip.h>
void far *_fmem_skipw(const void far *block, unsigned int *num);

Notes
See _mem_skipw.

Source file _MMFSKPW.ASM ASM equiv MEM_SKIPW

_fmem_spn


Descrip
Determines the number of characters at the beginning of a block which match any character in a given character set.

Syntax
#include <memmanip.h>
unsigned int _fmem_spn(const void far *block, const void far *charset, unsigned int num);

Notes
See _mem_cspn.

Source file _MMFSPN.ASM ASM equiv MEM_CSPN

_fmem_swab


Descrip
Copies the contents of a block to another location after swapping adjacent even and odd numbered bytes.

Syntax
#include <memmanip.h>
void far *_fmem_swab(void far *destblk, const void far *srcblk, unsigned int num);

Notes
See _mem_swab.

Source file _MMFSWAB.ASM ASM equiv MEM_SWAB

_fmem_upr


Descrip
Converts lowercase characters in a block to uppercase.

Syntax
#include <memmanip.h>
void far *_fmem_upr(void far *block, unsigned int num);

Notes
See _mem_upr.

Source file _MMFUPR.ASM ASM equiv MEM_UPR

_mem_ccpy


Descrip
Copies the contents of a block to another location, up to a given character or a maximum number of characters.

Syntax
#include <memmanip.h>
void *_mem_ccpy(void far *destblk, const void *srcblk, int chr, unsigned int *num);

Returns
A pointer to the byte immediately following the last copied character if a character matching chr was found in the first num characters of srcblk.
num actual number of characters copied from srcblk to destblk
destblk a copy of all the characters in srcblk up to and including the first character from srcblk which matched chr

NULL if chr was not found in srcblk.
destblk a copy of the first num characters of srcblk

Notes
This function copies characters from srcblk to destblk. Copying begins with the first character of srcblk and continues until a character matching chr is copied or until num characters have been copied, whichever comes first. The returned pointer indicates the next available position in dstblk (after the copied characters).

srcblk and destblk must not overlap if destblk is higher in memory than srcblk.

C/C++ Example
	{
	   char buffer1[20], buffer2[20];
	   unsigned int num = 20;
	   ...
	   _mem_ccpy ((void *)buffer1, buffer2, 'A', &num);
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[20], buffer2[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea si,buffer1/* DS:SI->buffer1 */
	   lea di,buffer2/* ES:DI->buffer2 */
	   mov cx,20
	   mov al,'A'
	   mem_ccpy ();	/* copy buffer1 to buffer2 */
	    jc mem_ccpy_010/* if AL not found in block */
	   ... 	 	/* if AL found in block */
	   jmp short mem_ccpy_020

	mem_ccpy_010:
	   ... 	 	/* 'A' not found in block */
	mem_ccpy_020:
	   ...
	}

Source file _MMCCPY.ASM ASM equiv MEM_CCPY
See also
_buf_ccpy, _fmem_ccpy, _mem_cpy

_mem_chr


Descrip
Searches a block for the first occurrence of a character.

Syntax
#include <memmanip.h>
void *_mem_chr(const void *block, int chr, unsigned int *num);

Returns
A pointer to the first occurrence of chr in block.
num size of block from chr to end of block

NULL if chr was not found.

Notes
This function searches block for chr. The search stops at the first occurrence of chr or after num characters have been checked, whichever comes first. If a character matching chr is found, a pointer to the matching character in block is returned and num contains the size of block from the matching character to the end of block.

If num is zero, NULL is returned.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num;
	   ...
	   pointer = _mem_chr (buffer, 'A', &num);
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer/* ES:DI->buffer */
	   mov cx,20	/* CX = size of buffer */
	   mov al,'A'
	   mem_chrdi ();	/* search for the character */
	    jc mem_chr_010/* if AL not found in buffer */
	   ... 	 	/* if AL was found in buffer */
	mem_chr_010:
	    ...
	}

Source file _MMCHR.ASM ASM equiv MEM_CHR
See also
_fmem_chr, _mem_chr, _mem_chr, _str_chr

_mem_chri


Descrip
Searches a block for the first occurrence of a character, ignoring case.

Syntax
#include <memmanip.h>
void *_mem_chri(const void *block, int chr, unsigned int *num);

Returns
A pointer to the first occurrence of chr in block if chr was found.
num size of block from chr to end of block

NULL if chr was not found.

Notes
This function searches block for chr. The case of ASCII characters is ignored. The search stops at the first occurrence of chr or after num characters have been checked, whichever comes first. If a character matching chr is found, a pointer to the matching character in block is returned and num contains the size of block from the matching character to the end of block.

If num is zero, NULL is returned.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num;
	   ...
	   pointer = _mem_chri (buffer, 'A', &num);
	}

Inline Assembly Example
	#include <inline.h>
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	{
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES=SS */
	   lea di,buffer
	   mov cx,20	/* CX=bytes to copy */
	   mov al,'A'	/* AL=character to stop on */
	   mem_chridi ();	/* was char found? */
	    jc mem_chri_010/* n: continue */
	   ... 	 	/* y: handle character */
	mem_chri_010:
	   ...
	}

Source file _MMCHRI.ASM ASM equiv MEM_CHRI
See also
_fmem_chr, _str_chr

_mem_chrn


Descrip
Searches a block for the first occurrence of a character which is not the given character.

Syntax
#include <memmanip.h>
void *_mem_chrn(const void *block, int chr, unsigned int *num);

Returns
A pointer to the first occurrence of a character other than chr in block.
num size of block from chr to the end of block

NULL if all characters in block are identical to chr.

Notes
This function searches block for a character other than chr. The search stops at the first occurrence of a character other than chr or after num characters have been checked, whichever comes first. If a mismatching character is found, a pointer to that character in block is returned and num contains the size of block from the mismatching character to the end of block.

If num is zero, NULL is returned.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num;
	   ...
	   pointer = _mem_chrn (buffer, 'A', &num);
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer/* ES:DI->buffer */
	   mov cx,20	/* CX = size of buffer */
	   mov al,'A'
	   mem_chrndi ();	/* search the buffer */
	    jc mem_chrn_010/* if AL was found in buffer */
	   ... 	 	/* if other chr was found */
	mem_chrn_010:
	   ...
	}

Source file _MMCHRN.ASM ASM equiv MEM_CHRN
See also
_fmem_chr, _str_chr

_mem_chrni


Descrip
Searches a block for the first occurrence of a character which is not the given character, ignoring case.

Syntax
#include <memmanip.h>
void *_mem_chrni(const void *block, int chr, unsigned int *num);

Returns
A pointer to the first occurrence of a character other than chr in block
num size of block from non-matching chr to end of block.

NULL if all characters in block are identical to chr.

Notes
This function searches block for a character other than chr. The case of ASCII characters is ignored. The search stops at the first occurrence of a character other than chr or after num characters have been checked, whichever comes first. If a mismatching character is found, a pointer to that character in block is returned and num contains the size of block from the mismatching character to the end of block.

If num is zero, NULL is returned.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num;
	   ...
	   pointer = _mem_chrni (buffer, 'A', &num);
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer/* ES:DI->buffer */
	   mov cx,20	/* CX = size of buffer */
	   mov al,'A'
	   mem_chrnidi ();    /* search the buffer */
	    jc mem_chrni_010/* if AL was found in buffer */
	   ... 	 	/* if other chr was found */
	mem_chrni_010:
	}

Source file _MMCHRNI.ASM ASM equiv MEM_CHRNI
See also
_fmem_chr, _str_chr

_mem_cmp


Descrip
Compares one block with another.

Syntax
#include <memmanip.h>
int _mem_cmp(const void *block1, const void far *block2, unsigned int num);
Returns
1 if block1 > block2.

0 if block1 = block2.

-1 if block1 < block2.

Notes
This function compares each byte of block1 and block2. The comparison starts with the first byte of each block and continues until corresponding bytes differ or until num bytes have been compared. The return value indicates the result of the comparison.

If num is zero, 0 is returned.

C/C++ Example
	{
	char buffer1[20], buffer2[20];
	switch (_mem_cmp (buffer1, (void *)buffer2, 20))
	   {
	      case 1:/* buffer1 > buffer2 */
	         break;
	      case 0:/* buffer1 == buffer2 */
	         break;
	      case -1:/* buffer1 < buffer2 */
	         break;
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[20], buffer2[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea si,buffer1/* DS:SI->buffer1 */
	   lea di,buffer2/* ES:DI->buffer2 */
	   mov cx,20
	   mem_cmp ();	/* compare buffer1 to buffer2 */
	    jb mem_cmp_020/* if buffer1 < buffer2 */
	    je mem_cmp_010/* if buffer1 = buffer2 */
	   ... 	 	/* if buffer1 > buffer2 */
	   jmp short mem_cmp_030

	mem_cmp_010:
	   ... 	 	/* buffer1 == buffer2 */
	   jmp short mem_cmp_030

	mem_cmp_020:
	   ... 	 	/* buffer1 < buffer2 */
	mem_cmp_030:
	   ...
	}

Source file _MMCMP.ASM ASM equiv MEM_CMP
See also
_buf_cmp, _fmem_cmp, _mem_cmp, _str_cmp

_mem_cmpi


Descrip
Compares one block to another, ignoring case.

Syntax
#include <memmanip.h>
int _mem_cmpi(const void *block1, const void far *block2, unsigned int num);

Returns
1 if block1 > block2, ignoring case.

0 if block1 = block2, ignoring case.

-1 if block1 < block2, ignoring case.

Notes
This function compares each byte of block1 and block2. The case of ASCII characters is ignored. The comparison starts with the first byte of each block and continues until corresponding bytes differ or until num bytes have been compared. The return value indicates the result of the comparison.

If num is zero, 0 is returned.

C/C++ Example
	{
	   char buffer1[20], buffer2[20];
	   switch (_mem_cmpi (buffer1, (void *)buffer2, 20))
	   {
	      case 1:/* buffer1 > buffer2 */
	         break;
	      case 0:/* buffer1 == buffer2 */
	         break;
	      case -1:/* buffer1 < buffer2 */
	         break;
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[20], buffer2[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea si,buffer1/* DS:SI->buffer1 */
	   lea di,buffer2/* ES:DI->buffer2 */
	   mov cx,20
	   mem_cmpi ();	/* compare buffer1 to buffer2 */
	    jb mem_cmpi_020/* if buffer1 < buffer2 */
	    je mem_cmpi_010/* if buffer1 = buffer2 */
	   ... 	 	/* if buffer1 > buffer2 */
	   jmp short mem_cmpi_030

	mem_cmpi_010:
	   ... 	 	/* buffer1 == buffer2 */
	   jmp short mem_cmpi_030
	mem_cmpi_020:
	    ... 	  	 /* buffer1 < buffer2 */
	mem_cmpi_030:
	    ...
	}

Source file _MMCMPI.ASM ASM equiv MEM_CMPI
See also
_buf_cmp, _fmem_cmp, _mem_cmp, _str_cmp

_mem_cpy


Descrip
Copies the contents of a block to another location.

Syntax
#include <memmanip.h>
void *_mem_cpy(void far *destblk, const void *srcblk, unsigned int num);

Returns
A pointer to destblk.
destblk num bytes from srcblk

Notes
This function copies the first num bytes of srcblk into destblk. A pointer to dstblk is returned.

srcblk and destblk must not overlap if destblk is higher in memory than srcblk. If srcblk and destblk do overlap and destblk is higher in memory, _mem_mov should be used in place of _mem_cpy.

C/C++ Example
	{
	   char buffer1[20], buffer2[20];
	   unsigned int num = 20;
	   ...
	   _mem_cpy ((void *)buffer1, buffer2, num);
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[20], buffer2[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea si,buffer1/* DS:SI->buffer1 */
	   lea di,buffer2/* ES:DI->buffer2 */
	   mov cx,20
	   mem_cpy ();	/* copy buffer1 to buffer2 */
	   ...
	}

Source file _MMCPY.ASM ASM equiv MEM_CPY
See also
_buf_cpy, _fmem_cpy, _mem_ccpy, _mem_cpy, _str_cpy

_mem_cpye


Descrip
Copies the contents of a block to another location and returns the address of the end of the destination block.

Syntax
#include <memmanip.h>
void *_mem_cpye(void far *destblk, const void *srcblk, unsigned int num);

Returns
A pointer to the character after the last character copied into destblk.
destblk num bytes from srcblk

Notes
This function copies the first num bytes of srcblk into destblk. The returned pointer identifies the next available position in destblk (past the copied block). A subsequent call to _mem_cpy or _mem_cpye will append data to the result.

srcblk and destblk must not overlap if destblk is higher in memory
than srcblk.

C/C++ Example
	{
	   char buffer1[20], buffer2[20];
	   void *pointer = _mem_cpye ((void *)buffer1, buffer2, 20);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[20], buffer2[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea si,buffer1/* DS:SI->buffer1 */
	   lea di,buffer2/* ES:DI->buffer2 */
	   mov cx,20
	   mem_cpye ();	/* ES:DI->end of buffer2 */
	   ...
	}

Source file _MMCPYE.ASM ASM equiv MEM_CPYE
See also
_fmem_cpy, _mem__cpy, _str_cpy

_mem_cspn


Descrip
Determines the number of characters at the beginning of a block which do not match any character in a given character set.

Syntax
#include <memmanip.h>
unsigned int _mem_cspn(const void *block, const void far *charset, unsigned int num);

Returns
The length of the initial portion of block that contains no characters from charset.

Notes
This function compares each character in block against all the characters in charset. The function starts with the first character of block and continues until a character in block matches one of the characters in charset or until num characters have been checked, whichever comes first. The return value indicates the number of consecutive characters at block which do not match any character in charset.

If the size of charset is zero, then all characters in block are different than the characters in charset (none) and the size of block is returned.

The length of charset is indicated by the char value at (charset-1). See the example below for one method of defining such a character set.

C/C++ Example
	{
	   char buffer[20];
	   int num = 20;
	   ...
	   num = _mem_cspn (buffer, (void *)("\4.,:;"+1), num);
	   /* counts consecutive non-punctuation characters in buffer */
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[20], *punct = "\4.,:;";
	   ...
	   pushds
	   pop es	 	/* ES = DS */
	   mov di,punct
	   lea si,buffer/* DS:SI->buffer */
	   inc di	 	/* ES:DI->string+1 */
	   mov cx,20	/* CX = size of buffer */
	   mem_cspn ();	/* count consecutive non-punct
	   ... 	 	    chars in buffer */
	}

Source file _MMCSPN.ASM ASM equiv MEM_CSPN
See also
_fmem_cspn, _mem_pbrk, _str_cspn

_mem_lwr


Descrip
Converts uppercase characters in a block to lowercase.

Syntax
#include <memmanip.h>
void *_mem_lwr(void *block, unsigned int num);

Returns
A pointer to block.

Notes
This function converts ASCII uppercase letters (A-Z) in block to lowercase letters (a-z). No other characters are modified. num indicates the size of block.

C/C++ Example
	{
	   char buffer[20];
	   ...
	   _mem_lwr (buffer, 20);
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	    ...
	    pushss
	    pop es  	 /* ES = SS */
	    lea di,buffer/* ES:DI->buffer */
	    mov cx,20
	    mem_lwrdi ();	 /* convert buffer to lowercase */
	    ...
	}

Source file _MMLWR.ASM ASM equiv MEM_LWR
See also
_fmem_lwr, _mem_upr, _str_lwr, _to_lower

_mem_mem


Descrip
Searches a block for the first occurrence of the contents of another block.

Syntax
#include <memmanip.h>
int _mem_mem(void **lookblk, unsigned int *looksize, void **findblk, unsigned int *findsize);

Returns
1 if findblk began to match lookblk, but the end of lookblk was encountered before the match was completed.
findblk address of the character in findblk following the last one successfully matched
findsize number of remaining characters to match in findblk when the end of lookblk was encountered
lookblk address of the first character of the partial match in lookblk
looksize size of lookblk from the start of the partial match to the end of lookblk

0 if findblk was found in lookblk.
lookblk address of the start of the match in lookblk
looksize the size of lookblk from the start of the match to the end of lookblk

-1 if findblk was not found in lookblk.

Notes
This function searches lookblk for the first occurrence of findblk. 0 is returned if a matching sequence of characters is found. 1 is returned if a partial match is found at the end of lookblk. -1 is returned if no match is found.

If either block size is zero, -1 is returned.

C/C++ Example
	{
	   char buffer1[20], buffer2[20];
	   void *lookblk = buffer1, *findblk = buffer2;
	   unsigned int looksize, findsize;
	   int cond;

	   lookblk = "Spontaneous Assembly Library";
	   looksize = sizeof ("Spontaneous Assembly Library");
	   findblk = "Library";
	   findsize = sizeof ("Library");
	   cond = _mem_mem (&lookblk, &looksize, &findblk,
	   	  &findsize);
	   /* cond = 0 */
	   /* lookblk now points to 'Library' in lookblk */
	   /* looksize now equals the size of the block 
	   from 'L' in 'Library' (in lookblk) to the 
	   end of the block */
	   lookblk = "Spontaneous Assembly Library";
	   looksize = sizeof ("Spontaneous Assembly Library");
	   findblk = "Library files";
	   findsize = sizeof ("Library files");
	   cond = _mem_mem (&lookblk, &looksize, &findblk,
	   	  &findsize);
	   /* cond = 1 */
	   /* lookblk now points to 'Library' in lookblk */
	   /* looksize now equals the size of the block 
	   from 'L' in 'Library' to the end of the block */
	   /* findblk now points to ' files' in findblk */
	   /* findsize now equals the size of the block from
	   ' ' in ' files' (in findblk) to the end of the block */
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char lookblk[20], findblk[20];
	   ...
	   pushss
	   pop es
	   lea si,findblk/* DS:SI->findblk */
	   lea di,lookblk/* ES:DI->lookblk */
	   mov cx,20	/* CX = size of findblk */
	   mov dx,20	/* DX = size of lookblk */
	   mem_mem ();	/* search the memory block */
	    je mem_mem_010/* if a match was found */
	    jb mem_mem_020/* if no match was found */
	   ... 	 	/* partial match */
	   jmp short mem_mem_030

	mem_mem_010:
	   ... 	 	/* full match */
	   jmp short mem_mem_030

	mem_mem_020:
	   ... 	 	/* no match found */
	mem_mem_030:
	   ...
	}

Source file _MMMEM.ASM ASM equiv MEM_MEM
See also
_fmem_mem, _mem_mem, _str_str

_mem_memi


Descrip
Searches a block for the first occurrence of another block, ignoring case.

Syntax
#include <memmanip.h>
int _mem_memi(void **lookblk, unsigned int *looksize, void **findblk, unsigned int *findsize);

Returns
1 if findblk began to match lookblk, but the end of lookblk was encountered before the match was completed.
findblk address of the character in findblk following the last one successfully matched
findsize number of remaining characters to match in findblk when the end of lookblk was encountered
lookblk address of the first character of the partial match in lookblk
looksize size of lookblk from the start of the partial match to the end of lookblk

0 if findblk was found in lookblk.
lookblk address of the start of the match in lookblk
looksize the size of lookblk from the start of the match to the end of lookblk

-1 if findblk was not found in lookblk.

Notes
This function searches lookblk for the first occurrence of findblk. The case of ASCII characters is ignored. 0 is returned if a matching sequence of characters is found. 1 is returned if a partial match is found at the end of lookblk. -1 is returned if no match is found.

If either block size is zero, -1 is returned.

C/C++ Example
	{
	   char buffer1[20], buffer2[20];
	   void *lookblk = buffer1, *findblk = buffer2;
	   unsigned int looksize, findsize;
	   int cond;
	   lookblk = "Spontaneous Assembly Library";
	   looksize = sizeof ("Spontaneous Assembly Library");
	   findblk = "library";
	   findsize = sizeof ("library");
	   cond = _mem_memi (&lookblk, &looksize, &findblk,
	   	  &findsize);
	   /* cond = 0 */
	   /* lookblk now points to 'Library' in lookblk */
	   /* looksize now equals the size of the block from 'L'
	   (in lookblk) to the end of the block */
	   lookblk = "Spontaneous Assembly Library";
	   looksize = sizeof ("Spontaneous Assembly Library");
	   findblk = "library files";
	   findsize = sizeof ("library files");
	   cond = _mem_memi (&lookblk, &looksize, &findblk,
	   	  &findsize);
	   /* cond = 1 */
	   /* lookblk now points to 'Library' in lookblk */
	   /* looksize now equals the size of the block from 'L'
	   (in lookblk) to the end of the block */
	   /* findblk now points to ' files' in findblk */
	   /* findsize now equals the size of the block from ' '
	   (in findblk) to the end of the block */
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char lookblk[20], findblk[20];
	   ...
	   pushss
	   pop es
	   lea si,findblk/* DS:SI->findblk */
	   lea di,lookblk/* ES:DI->lookblk */
	   mov cx,20	/* CX = size of findblk */
	   mov dx,20	/* DX = size of lookblk */
	   mem_memi ();	/* search the memory block */
	    je mem_memi_010/* if a match was found */
	    jb mem_memi_020/* if no match was found */
	   ... 	 	/* if a partial match */
	   jmp short mem_memi_030

	mem_memi_010:
	   ... 	 	/* full match */
	   jmp short mem_memi_030
	mem_memi_020:
	   ... 	 	/* no match found */
	mem_memi_030:
	   ...
	}

Source file _MMMEMI.ASM ASM equiv MEM_MEMI
See also
_fmem_mem, _mem_mem, _str_str

_mem_mov


Descrip
Copies the contents of a block to another location.

Syntax
#include <memmanip.h>
void *_mem_mov(void far *destblk, const void *srcblk, unsigned int num);

Returns
A pointer to destblk.
destblk a copy of srcblk

Notes
This function copies the contents of srcblk into destblk. Sections of srcblk and destblk may overlap.

If the segments of the memory blocks are not the same, it is assumed that the blocks do not overlap. In this case, characters are simply copied from srcblk to destblk (from the first character to the last).

C/C++ Example
	{
	   char buffer[20];
	   ...
	   _mem_mov ((void *)(buffer+1), buffer, 20);
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer
	   inc di	 	/* ES:DI->buffer+1 */
	   lea si,buffer/* DS:SI->buffer */
	   mov cx,20
	   mem_mov ();	/* move buffer up one byte */
	   ...
	}

Source file _MMMOV.ASM ASM equiv MEM_MOV
See also
_fmem_mov, _mem_cpy, _mem_cpy, _str_cpy

_mem_pbrk


Descrip
Searches a block for the first occurrence of any character which is in a set of characters.

Syntax
#include <memmanip.h>
void *_mem_pbrk(const void *block, const void far *charset, unsigned int *num);

Returns
A pointer to the first occurrence of a character in block that is also in charset, if one was found.
num size of block from the matching character to the end of block

NULL if none of the characters in charset were found in block

Notes
This function searches block for the first occurrence of a character that matches one of the characters in charset. A pointer to the first occurrence of a matching character is returned; num contains the size of block from the matching character to the end of block.

If the size of charset is zero, or if the size of block is zero, NULL is returned.

The length of charset is indicated by the char value at (charset-1). See the example below for one method of defining such a character set.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num = 20;
	   ...
	   pointer = _mem_pbrk (buffer, (void *)("\3ABC"+1), &num);
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[20], *abcset = "\3ABC";
	   ...
	   pushds
	   pop es	 	/* ES = DS */
	   mov di,abcset
	   inc di	 	/* ES:DI -> string+1 */
	   lea si,buffer/* DS:SI->buffer */
	   mov cx,20	/* CX = size of buffer */
	   mem_pbrk ();	/* search for 'A', 'B', or 'C' */
	    jc mem_pbrk_010/* if a char not found */
	   ... 	 	/* if a char found */
	mem_pbrk_010:
	   ...
	}

Source file _MMPBRK.ASM ASM equiv MEM_PBRK
See also
_fmem_pbrk, _mem_pbrk, _str_pbrk

_mem_pbrkn


Descrip
Searches a block for the first occurrence of any character which is not in a set of characters.

Syntax
#include <memmanip.h>
void *_mem_pbrkn(const void *block, const void far *charset, unsigned int *num);

Returns
A pointer to the first occurrence of a character in block that is not in charset, if one was found.
num size of block from the matching character to the end of block

NULL if all of the characters in block were found in charset.

Notes
This function searches block for the first occurrence of a character that does not match any character in charset. A pointer to the first occurrence of such a character is returned; num contains the size of block from the mismatching character to the end of block.

If the size of charset is zero, or if the size of block is zero, NULL is returned.

The length of charset is indicated by the char value at (charset-1). See the example below for one method of defining such a character set.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num = 20;
	   ...
	   pointer = _mem_pbrkn (buffer, (void *)("\4.,:;"+1), &num);
	   /* find first non-punctuation character */
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[20], *punct = "\4.,:;";
	   ...
	   pushds
	   pop es	 	/* ES = DS */
	   mov di,punct
	   inc di	 	/* ES:DI -> charset+1 */
	   lea si,buffer/* DS:SI->buffer */
	   mov cx,20	/* CX = size of buffer */
	   mem_pbrkn ();	/* find first non-punct char */
	    jc mem_pbrkn_010/* if all chars matched */
	   ... 	 	/* if an unmatched character */
	mem_pbrkn_010:
	   ...
	}

Source file _MMPBRKN.ASM ASM equiv MEM_PBRKN
See also
_fmem_pbrk, _mem_cspn, _mem_pbrk, _str_pbrk

_mem_rev


Descrip
Reverses the order of the characters in a block.

Syntax
#include <memmanip.h>
void *_mem_rev(void *block, unsigned int num);

Returns
A pointer to block.
block all characters in reverse order

Notes
This function reverses all the characters in block. For example, a block containing '0123456789' would be changed to '9876543210'.

C/C++ Example
	{
	   char buffer[20];
	   ...
	   _mem_rev (buffer, 20);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   pushss
	   pop es	 /* ES = DS */
	   mov cx,20/* CX = size of buffer */
	   mem_revdi ();/* reverse bytes in buffer */
	   ...
	}

Source file _MMREV.ASM ASM equiv MEM_REV
See also
_fmem_rev, _str_rev

_mem_set


Descrip
Sets all characters in a block to a specified character.

Syntax
#include <memmanip.h>
void *_mem_set(void *block, int chr, unsigned int num);

Returns
A pointer to block.
block contains num instances of chr

Notes
This function fills block with num occurrences of the specified character (chr). A pointer to block is returned.

C/C++ Example
	{
	   char buffer[20];
	   _mem_set (buffer, 0, 20);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   ...
	    pushss
	    pop es  	 /* ES = SS */
	    lea di,buffer/* ES:DI->buffer */
	    mov cx,20
	    mov al,' '
	    mem_setdi ();	 /* set the block to spaces */
	    ...
	}

Source file _MMSET.ASM ASM equiv MEM_SET
See also
_fmem_set, _str_set

_mem_skips


Descrip
Skips past all space characters in a block.

Syntax
#include <memmanip.h>
void *_mem_skips(const void *block, unsigned int *num);

Returns
A pointer to the first non-space character in block.
num the number of bytes from the first non-space character to the end of block

Notes
This function skips past all space characters in block. A pointer to the first non-space character in block is returned; num contains the size of block from the first non-space character to the end of block.

This function defines space characters as the space and tab characters (0x20 and 0x09). If the size of block is zero, the function simply returns a pointer to block.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num = 20;
	   ...
	   pointer = _mem_skips (buffer, &num);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer/* ES:DI->buffer */
	   mov cx,20	/* CX = size of buffer */
	   mem_skipsdi ();    /* ES:DI->first non-space char */
	   ...
	}

Source file _MMSKIPS.ASM ASM equiv MEM_SKIPS
See also
_fmem_skips, _mem_skipw, _str_skips

_mem_skipw


Descrip
Skips past all whitespace characters in a block.

Syntax
#include <memmanip.h>
void *_mem_skipw(const void *block, unsigned int *num);

Returns
A pointer to the first non-whitespace character in block.
num the number of bytes from the first non-whitespace character to the end of block

Notes
This function skips past all whitespace characters in block. A pointer to the first non-whitespace character in block is returned; num contains the size of block from the first non-whitespace character to the end of block.

This function defines whitespace characters as the space, tab, carriage return, and linefeed characters (0x20, 0x09, 0x0D and 0x0A).

If num is zero, the function simply returns a pointer to block.

C/C++ Example
	{
	   char buffer[20];
	   void *pointer;
	   unsigned int num = 20;
	   ...
	   pointer = _mem_skipw (buffer, &num);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer/* ES:DI->buffer */
	   mov cx,20	/* CX = size of buffer */
	   mem_skipwdi ();/* ES:DI-> first non-whitespace char */
	   ...
	}

Source file _MMSKIPW.ASM ASM equiv MEM_SKIPW
See also
_fmem_skipw, _mem_skips, _str_skipw

_mem_spn


Descrip
Determines the number of characters at the beginning of a block which match any character in a given character set.

Syntax
#include <memmanip.h>
unsigned int _mem_spn(const void *block, const void far *charset, unsigned int num);

Returns
The length of the initial portion of block that contains only characters from charset.

Notes
This function compares each character in block against all the characters in charset. The comparison starts with the first character of block and continues until a character in block does not match one of the characters in charset or until num characters have been checked.

If the length of charset is zero, 0 is returned.
The length of charset is indicated by the char value at (charset-1). See the example below for one method of defining such a character set.

C/C++ Example
	{
	   char buffer[20];
	   int num;
	   ...
	   num = _mem_spn (buffer, (void *)("\3abc"+1),
	   	     sizeof (buffer));
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[20], *abcset = "\3abc";
	   ...
	   pushds
	   pop es	 	/* ES = DS */
	   mov di,string
	   lea si,buffer/* DS:SI->buffer */
	   inc di	 	/* ES:DI->string + 1 */
	   mov cx,20	/* CX = size of buffer */
	   mem_spn ();	/* find number of non-abc chars */
	   ...
	}

Source file _MMSPN.ASM ASM equiv MEM_SPN
See also
_fmem_spn, _str_spn

_mem_swab


Descrip
Copies the contents of a block to another location after swapping adjacent even and odd numbered bytes.

Syntax
#include <memmanip.h>
void *_mem_swab(void far *destblk, const void *srcblk, unsigned int num);

Returns
A pointer to destblk.
destblk copy of srcblk with all adjacent even and odd bytes swapped

Notes
This function copies the contents of srcblk into destblk a word at a time, swapping the high and low bytes of each word before placing it in destblk. If num is odd, the final unpaired byte is copied into destblk.

If destblk is higher in memory than srcblk, srcblk and destblk must not overlap. The address of the beginning of the table determines whether a byte is odd or even. If the number of bytes to copy is less than two, nothing is copied into destblk.

C/C++ Example
	{
	   char buffer[20];
	   pointer = _mem_swab ((void *)buffer, buffer, 20);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer/* ES:DI->buffer */
	   mov si,di
	   mov cx,20
	   mem_swab ();
	   ...
	}

Source file _MMSWAB.ASM ASM equiv MEM_SWAB
See also
_fmem_swab

_mem_upr


Descrip
Converts lowercase characters in a block to uppercase.

Syntax
#include <memmanip.h>
void *_mem_upr(void *block, unsigned int num);

Returns
A pointer to block.
block block with converted ASCII characters

Notes
This function converts ASCII lowercase letters (a-z) in block to uppercase letters (A-Z). No other characters are modified. The size of the block is indicated by num. A pointer to block is returned.

C/C++ Example
	{
	   char buffer[20];
	   ...
	   _mem_upr (buffer, 20);
	}

Inline Assembly Example
	#include <inline.h>
	{
	/* use "ES:DI" version of function to minimize reg profile, */
	/*   see SA 3.0 manual for more details */
	   char buffer[20];
	   ...
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,buffer/* ES:DI->buffer */
	   mov cx,20
	   mem_uprdi ();	/* convert buffer to uppercase */
	   ...
	}

Source file _MMUPR.ASM ASM equiv MEM_UPR
See also
_fmem_upr, _mem_lwr, _str_upr