/*
   CyberRax Programming (C) 2003, 2004
   TITLE:   BYTES.H--
   DESCRIPTION:   Several byte and register related (helper) functions
   LAST MODIFIED:   06 Jul 2004
   PROCEDURES DEFINED IN THIS FILE:
       byte  LOAD_AL()
       word  LOAD_AX()
       dword LOAD_EAX()
       byte  STORE_AL()
       word  STORE_AX()
       dword STORE_EAX()
       void  REVERSE_EAX()
       void  REVERSE_EBX()
       void  REVERSE_ECX()
       void  REVERSE_EDX()
       word  AX2BX()
       word  AX2CX()
       word  AX2DX()
       word  AX2DI()
       word  AX2SI()
       word  AX2BP()
       word  AX2SP()
       void  BX2AX()
       void  CX2AX()
       void  DX2AX()
       void  DI2AX()
       void  SI2AX()
       void  BP2AX()
       void  SP2AX()
       byte  COMP(buffer1,buffer2,bytes)
       byte  COMPW(buffer1,buffer2,words)
       byte  COMPD(buffer1,buffer2,dwords)
       byte  COMPBACKWARD(buffer1,buffer2,bytes)
       byte  COMPBACKWARDW(buffer1,buffer2,words)
       byte  COMPBACKWARDD(buffer1,buffer2,dwords)
       byte  COMPNEAR(buffer1,buffer2,bytes)
       byte  COMPNEARW(buffer1,buffer2,words)
       byte  COMPNEARD(buffer1,buffer2,dwords)
       byte  COMPBACKWARDNEAR(buffer1,buffer2,bytes)
       byte  COMPBACKWARDNEARW(buffer1,buffer2,words)
       byte  COMPBACKWARDNEARD(buffer1,buffer2,dwords)
       byte  COMPTOFAR(buf2_segment,buf2_offset,buf1_offset,bytes)
       byte  COMPTOFARW(buf2_segment,buf2_offset,buf1_offset,words)
       byte  COMPTOFARD(buf2_segment,buf2_offset,buf1_offset,dwords)
       byte  COMPBACKWARDTOFAR(buf2_segment,buf2_offset,buf1_offset,bytes)
       byte  COMPBACKWARDTOFARW(buf2_segment,buf2_offset,buf1_offset,words)
       byte  COMPBACKWARDTOFARD(buf2_segment,buf2_offset,buf1_offset,dwords)
       byte  COMPFAR(buf1_segment,buf2_offset,buf2_segment,buf2_offset,bytes)
       byte  COMPFARW(buf1_segment,buf2_offset,buf2_segment,buf2_offset,words)
       byte  COMPFARD(buf1_segment,buf2_offset,buf2_segment,buf2_offset,dwords)
       byte  COMPBACKWARDFAR(buf1_seg,buf2_offs,buf2_seg,buf2_off,bytes)
       byte  COMPBACKWARDFARW(buf1_seg,buf2_offs,buf2_seg,buf2_offset,words)
       byte  COMPBACKWARDFARD(buf1_seg,buf2_offs,buf2_seg,buf2_offset,dwords)
       void  COPY(destoffs,sourceoffs,bytes)
       void  COPYW(destoffs,sourceoffs,words)
       void  COPYD(destoffs,sourceoffs,dwords)
       void  COPYBACKWARD(destoffs,sourceoffs,bytes)
       void  COPYBACKWARDW(destoffs,sourceoffs,words)
       void  COPYBACKWARDD(destoffs,sourceoffs,dwords)
       void  COPYTOFAR(destseg,destoffs,sourceoffs,bytes)
       void  COPYTOFARW(destseg,destoffs,sourceoffs,words)
       void  COPYTOFARD(destseg,destoffs,sourceoffs,dwords)
       void  COPYBACKWARDTOFAR(destseg,destoffs,sourceoffs,bytes)
       void  COPYBACKWARDTOFARW(destseg,destoffs,sourceoffs,words)
       void  COPYBACKWARDTOFARD(destseg,destoffs,sourceoffs,dwords)
       void  COPYFROMFAR(destoffs,sourceseg,sourceoffs,bytes)
       void  COPYFROMFARW(destoffs,sourceseg,sourceoffs,words)
       void  COPYFROMFARD(destoffs,sourceseg,sourceoffs,dwords)
       void  COPYBACKWARDFROMFAR(destoffs,sourceseg,sourceoffs,bytes)
       void  COPYBACKWARDFROMFARW(destoffs,sourceseg,sourceoffs,words)
       void  COPYBACKWARDFROMFARD(destoffs,sourceseg,sourceoffs,dwords)
       void  STORE(destoffs,value,bytes);
       void  STOREW(destoffs,value,words);
       void  STORED(destoffs,value,dwords);
       void  STORENEAR(destoffs,value,bytes)
       void  STORENEARW(destoffs,value,words)
       void  STORENEARD(destoffs,value,dwords)
       void  STOREFAR(destseg,destoffs,value,bytes)
       void  STOREFARW(destseg,destoffs,value,words)
       void  STOREFARD(destseg,destoffs,value,dwords)
   DEFINITIONS AFFECTING THIS CODE:
      KeepInsert1 - don't undefine Insert1
      Insert1     - insert COMP[?]() in COMPxxx[?](), STORE[?]() in
		      STORExxx[?]() and COPY[?]() in COPYxxx[?]() instead
		      of calling
		    These definitions are for hand-optimizing the code for
		      speed/size in case the mentioned procedures aren't
		      called by themselves. InsertX is undefinied by all
                      procedures which support it if the appropriate
		      KeepInsertX is not definied.
   NOTE:   this header file uses features of SPHINX/Sheker C-- and needs
	   heavy re-writing to work under original SPHINX C-- 0.203-
*/
/* History:

	20040706   -    small bugfix: AX2CX() was named AXCBX()
			fixed bug in STORE_A?(): it used DS instead of ES
			some cosmetical modifications
			started list of changes
*/

? ifndef _BYTES_
? define _BYTES_        20040706


? ifndef _NUMBERS_
  ? include "NUMBERS.H--"
? endif

? ifndef _JSTUFF_
  ? include "JSTUFF.H--"
? endif


? warning		FALSE



inline byte LOAD_AL ()
/* Loads byte from DS:SI into AL
   Is meant to be used as macro in header files
   Input:  nothing
   Output: AL = loaded byte
	   SI increased by 1
   Uses:   0 - 2 bytes of stack
   Size:   min. 1 byte
*/
{
? ifdef codesize
  $LODSB
? else
  ? ifdef cpu <= 3
    $LODSB
  ? else
    AL = DSBYTE[SI];
    SI++;
  ? endif
? endif
}



inline word LOAD_AX ()
/* Loads word from DS:SI into AX
   Is meant to be used as macro in header files
   Input:  nothing
   Output: AX = loaded word
	   SI increased by 2
   Uses:   0 - 2 bytes of stack
   Size:   min. 1 byte
*/
{
? ifdef codesize
  $LODSW
? else
  ? ifdef cpu <= 3
    $LODSW
  ? else
    AX = DSWORD[SI];
    SI += TWO;
  ? endif
? endif
}



inline dword LOAD_EAX ()
/* Loads double word from DS:SI into EAX
   Is meant to be used as macro in header files
   Uses 386+ code
   Input:  nothing
   Output: EAX = loaded dword
	   SI increased by 4
   Uses:   0 - 2 bytes of stack
   Size:   min. 2 byte
*/
{
? ifdef codesize
  $LODSD
? else
  ? ifdef cpu >= 4
    EAX = DSDWORD[SI];
    SI += FOUR;
  ? else
    $LODSD
  ? endif
? endif
}



inline void STORE_AL ()
/* Stores byte in AL to ES:DI
   Is meant to be used as macro in header files
   Input:  nothing
   Output: nothing
	   byte stored
	   DI increased by 1
   Uses:   0 - 2 bytes of stack
   Size:   min. 1 byte
*/
{
? ifdef codesize
  $STOSB
? else
  ? ifdef cpu <= 3
    $STOSB
  ? else
    ESBYTE[DI] = AL;
    DI++;
  ? endif
? endif
}



inline void STORE_AX ()
/* Stores word in AX to ES:DI
   Is meant to be used as macro in header files
   Input:  nothing
   Output: nothing
	   word stored
	   DI increased by 2
   Uses:   0 - 2 bytes of stack
   Size:   min. 1 byte
*/
{
? ifdef codesize
  $STOSW
? else
  ? ifdef cpu <= 3
    $STOSW
  ? else
    ESWORD[DI] = AX;
    DI += TWO;
  ? endif
? endif
}



inline void STORE_EAX ()
/* Stores double word in EAX to ES:DI
   Uses 386+ code
   Is meant to be used as macro in header files
   Input:  nothing
   Output: nothing
	   dword stored
	   DI increased by 4
   Uses:   0 - 2 bytes of stack
   Size:   min. 2 byte
*/
{
? ifdef codesize
  $STOSD
? else
  ? ifdef cpu >= 4
    ESDWORD[DI] = EAX;
    DI += FOUR;
  ? else
    $STOSD
  ? endif
? endif
}



inline void REVERSE_EAX ()
/* Reverses the byte order of EAX (ie from big to little endian)
   Notes:  uses 386+ code
	   is meant to be used on data that's been LODSD into EAX (in case
	     the *real* (ie un-reversed) order is needed)
   Input:  nothing
   Output: EAX = contents reversed
   Uses:   0 - 2 bytes of stack
   Size:   2 - 9 bytes
*/
{
? ifdef cpu >= 4
  $BSWAP EAX
? else
  AH >< AL;
  $ROL EAX,SIXTEEN
  AH >< AL;
? endif
}



inline void REVERSE_EBX ()
/* Reverses the byte order of EBX (ie from big to little endian)
   Notes:  uses 386+ code
	   is meant to be used on data that's been LODSD into EBX (in case the
	     *real* (ie un-reversed) order is needed)
   Input:  nothing
   Output: EBX = contents reversed
   Uses:   0 - 2 bytes of stack
   Size:   2 - 9 bytes
*/
{
? ifdef cpu >= 4
  $BSWAP EBX
? else
  BH >< BL;
  $ROL EBX,SIXTEEN
  BH >< BL;
? endif
}



inline void REVERSE_ECX ()
/* Reverses the byte order of ECX (ie from big to little endian)
   Notes:  uses 386+ code
	   is meant to be used on data that's been LODSD into ECX (in case the
	     *real* (ie un-reversed) order is needed)
   Input:  nothing
   Output: ECX = contents reversed
   Uses:   0 - 2 bytes of stack
   Size:   2 - 9 bytes
*/
{
? ifdef cpu >= 4
  $BSWAP ECX
? else
  CH >< CL;
  $ROL ECX,SIXTEEN
  CH >< CL;
? endif
}



inline void REVERSE_EDX ()
/* Reverses the byte order of EDX (ie from big to little endian)
   Notes:  uses 386+ code
	   is meant to be used on data that's been LODSD into EDX (in case the
	     *real* (ie un-reversed) order is needed)
   Input:  nothing
   Output: EDX = contents reversed
   Uses:   0 - 2 bytes of stack
   Size:   2 - 9 bytes
*/
{
? ifdef cpu >= 4
  $BSWAP EDX
? else
  DH >< DL;
  $ROL EDX,SIXTEEN
  DH >< DL;
? endif
}



inline byte COMP ((E)SI, (E)DI, (E)CX)
/* Compares CX bytes at DS:SI with bytes at ES:DI.
   Basically COMPNEAR(), but doesn't set ES
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  ES:DI = second array
	     CX = length of array in bytes
   Uses: 2 bytes of stack
   Size: 10 bytes
*/
{
$PUSHF
AL = NULL;
$CLD
$REP $CMPSB
IF (NOTZEROFLAG)
   AX++;
$POPF
}
/* Returns: AL = CX = 0 if success
	    AL = 1, CX undetermined by failure
	    SI, DI, destroyed
*/



inline byte COMPW ((E)SI, (E)DI, (E)CX)
/* Compares CX words at DS:SI with words at ES:DI.
   Basically COMPNEARW(), but doesn't set ES
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  ES:DI = second array
	     CX = length of array in words
   Uses: 2 bytes of stack
   Size: 10 bytes
*/
{
$PUSHF
AL = NULL;
$CLD
$REP $CMPSW
IF (NOTZEROFLAG)
   AX++;
$POPF
}
/* Returns: AL = CX = 0 if success
	    AL = 1, CX undetermined by failure
	    SI, DI, destroyed
*/



inline byte COMPD ((E)SI, (E)DI, (E)CX)
/* Compares CX dwords at DS:SI with dwords at ES:DI.
   Basically STRCMP() but doesn't need 0 as end-of-string indicator
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
	 Needs 386+ to work
   Input: DS:SI = first array
	  ES:DI = second array
	     CX = length of array in dwords
   Uses: 2 bytes of stack
   Size: 10 bytes
*/
{
$PUSHF
AL = NULL;
$CLD
$REP $CMPSD
IF (NOTZEROFLAG)
   AX++;
$POPF
}
/* Returns: AL = CX = 0 if success
	    AL = 1, CX undetermined by failure
	    SI, DI, destroyed
*/




inline byte COMPBACKWARD ((E)SI, (E)DI, (E)CX)
/* Compares CX bytes at DS:SI with bytes at ES:DI.
   Basically COMP(), but copares from the end
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  ES:DI = second array
	     CX = length of array in bytes
   Uses: 2 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSHF
AL = NULL;
(E)SI += (E)CX;
(E)DI += (E)CX;
(E)SI--;
(E)DI--;
$STD
$REP $CMPSB
IF (NOTZEROFLAG)
   AX++;
$POPF
}
/* Returns: AL = CX = 0 if success
	    AL = 1, CX undetermined by failure
	    SI, DI, destroyed
*/



inline byte COMPBACKWARDW ((E)SI, (E)DI, (E)CX)
/* Compares CX words at DS:SI with words at ES:DI.
   Basically COMPW(), but copares from the end
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  ES:DI = second array
	     CX = length of array in words
   Uses: 2 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSHF
AL = NULL;
(E)SI += (E)CX;
(E)DI += (E)CX;
(E)SI--;
(E)DI--;
$STD
$REP $CMPSW
IF (NOTZEROFLAG)
   AX++;
$POPF
}
/* Returns: AL = CX = 0 if success
	    AL = 1, CX undetermined by failure
	    SI, DI, destroyed
*/



inline byte COMPBACKWARDD ((E)SI, (E)DI, (E)CX)
/* Compares CX dwords at DS:SI with dwords at ES:DI.
   Basically COMPD(), but copares from the end
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  ES:DI = second array
	     CX = length of array in words
   Uses: 2 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSHF
AL = NULL;
(E)SI += (E)CX;
(E)DI += (E)CX;
(E)SI--;
(E)DI--;
$STD
$REP $CMPSD
IF (NOTZEROFLAG)
   AX++;
$POPF
}
/* Returns: AL = CX = 0 if success
	    AL = 1, CX undetermined by failure
	    SI, DI, destroyed
*/



inline byte COMPTOFARW (AX, (E)DI, (E)SI, (E)CX)   // ver. 1.05, uses COMPW()
/* Compares specified number of words at active segment (DS) and
     given segment
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string identifier
   NOTES: If you need different DS then you have to set it before calling
	    this procedure.
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of words to compare
          'Insert1' defined to insert COMPW() instead of calling
   Uses: COMPW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COMPW();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, ES destroyed
*/



inline byte COMPTOFAR (AX, (E)DI, (E)SI, (E)CX)
/* Compares specified number of bytes at active segment (DS) and
     given segment
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string identifier
   NOTES: If you need different DS then you have to set it before calling
	    this procedure.
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of bytes to compare
          'Insert1' defined to insert COMP() instead of calling
   Uses: COMP() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COMP();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, ES destroyed
*/



inline byte COMPTOFARD (AX, (E)DI, (E)SI, (E)CX)
/* Compares specified number of dwrods at active segment (DS) and
     given segment
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string indicator
   NOTES: If you need different DS then you have to set it before calling
	    this procedure.
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of dwords to compare
          'Insert1' defined to insert COMPD() instead of calling
   Uses: COMPD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COMPD();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, ES destroyed
*/



inline byte COMPBACKWARDTOFARW (AX, (E)DI, (E)SI, (E)CX)
/* Compares specified number of words at active segment (DS) and
     given segment
   Basically COMPTOFARW(), but compares from the end
   NOTES: If you need different DS then you have to set it before calling
	    this procedure.
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of words to compare
          'Insert1' defined to insert COMPBACKWARDW() instead of calling
   Uses: COMPBACKWARDW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 18 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COMPBACKWARDW();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, ES destroyed
*/



inline byte COMPBACKWARDTOFAR (AX, (E)DI, (E)SI, (E)CX)
/* Compares specified number of bytes at active segment (DS) and
     given segment
   Basically COMPTOFAR(), but compares from the end
   NOTES: If you need different DS then you have to set it before calling
	    this procedure.
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of bytes to compare
          'Insert1' defined to insert COMPBACKWARD() instead of calling
   Uses: COMPBACKWARD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COMPBACKWARD();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, ES destroyed
*/



inline byte COMPBACKWARDTOFARD (AX, (E)DI, (E)SI, (E)CX)
/* Compares specified number of dwords at active segment (DS) and
     given segment
   Basically COMPTOFARD(), but compares from the end
   NOTES: If you need different DS then you have to set it before calling
	    this procedure.
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of dwords to compare
          'Insert1' defined to insert COMPBACKWARDD() instead of calling
   Uses: COMPBACKWARDD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COMPBACKWARDD();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, ES destroyed
*/



inline byte COMPFAR (AX, (E)DI, BX, (E)SI, (E)CX)
/* Compares specified number of bytes
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string indicator
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  BX = segment of 1st buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of bytes to compare
          'Insert1' defined to insert COMP() instead of calling
   Uses: COMP() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSH DS
ES = AX;
DS = BX;
? ifdef Insert1
   @
? endif
COMP();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    BX, SI, DI, ES destroyed
*/



inline byte COMPFARW (AX, (E)DI, BX, (E)SI, (E)CX)
/* Compares specified number of words
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string indicator
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  BX = segment of 1st buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of words to compare
          'Insert1' defined to insert COMPW() instead of calling
   Uses: COMPW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSH DS
ES = AX;
DS = BX;
? ifdef Insert1
   @
? endif
COMPW();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    BX, SI, DI, ES destroyed
*/



inline byte COMPFARD (AX, (E)DI, BX, (E)SI, (E)CX)
/* Compares specified number of words
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string indicator
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  BX = segment of 1st buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of dwords to compare
          'Insert1' defined to insert COMPD() instead of calling
   Uses: COMPD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSH DS
ES = AX;
DS = BX;
? ifdef Insert1
   @
? endif
COMPD();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    BX, SI, DI, ES destroyed
*/



inline byte COMPBACKWARDFAR (AX, (E)DI, BX, (E)SI, (E)CX)
/* Compares specified number of bytes
   Basically COMPFAR(), but compares from the end
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  BX = segment of 1st buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of bytes to compare
          'Insert1' defined to insert COMPBACKWARD() instead of calling
   Uses: COMPBACKWARD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSH DS
ES = AX;
DS = BX;
? ifdef Insert1
   @
? endif
COMPBACKWARD();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    BX, SI, DI, ES destroyed
*/



inline byte COMPBACKWARDFARW (AX, (E)DI, BX, (E)SI, (E)CX)
/* Compares specified number of words
   Basically COMPFARW(), but compares from the end
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  BX = segment of 1st buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of words to compare
          'Insert1' defined to insert COMPBACKWARDW() instead of calling
   Uses: COMPBACKWARDW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSH DS
ES = AX;
DS = BX;
? ifdef Insert1
   @
? endif
COMPBACKWARDW();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    BX, SI, DI, ES destroyed
*/



inline byte COMPBACKWARDFARD (AX, (E)DI, BX, (E)SI, (E)CX)
/* Compares specified number of words
   Basically COMPFARD(), but compares from the end
   Input: AX = segment of 2nd buffer/string
	  DI = offset of 2nd buffer/string
	  BX = segment of 1st buffer/string
	  SI = offset of 1st buffer/string
	  CX = amount of dwords to compare
          'Insert1' defined to insert COMPBACKWARDD() instead of calling
   Uses: COMPBACKWARDD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 16 bytes
*/
{
$PUSH DS
ES = AX;
DS = BX;
? ifdef Insert1
   @
? endif
COMPBACKWARDD();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    BX, SI, DI, ES destroyed
*/



inline byte COMPNEAR ((E)SI, (E)DI, (E)CX)   // ver. 1.02, uses COMP()
/* Compares CX bytes at DS:SI with words at DS:DI.
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string identifier
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  DS:DI = second array
	     CX = length of array in bytes
          'Insert1' defined to insert COMP() instead of calling
   Uses: COMP() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
COMP();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, destroyed
	    ES = DS
*/



inline byte COMPNEARW ((E)SI, (E)DI, (E)CX)
/* Compares CX words at DS:SI with words at DS:DI.
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string identifier
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  DS:DI = second array
	     CX = length of array in words
          'Insert1' defined to insert COMPW() instead of calling
   Uses: COMPW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
COMPW();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, destroyed
	    ES = DS
*/



inline byte COMPNEARD ((E)SI, (E)DI, (E)CX)
/* Compares CX dwords at DS:SI with words at DS:DI.
   Basically STRCMP(), just doesn't need the 0 byte as end-of-string identifier
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  DS:DI = second array
	     CX = length of array in dwords
          'Insert1' defined to insert COMPD() instead of calling
   Uses: COMPD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
COMPD();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, destroyed
	    ES = DS
*/



inline byte COMPBACKWARDNEAR ((E)SI, (E)DI, (E)CX)
/* Compares CX bytes at DS:SI with words at DS:DI.
   Basically COMPNEAR(), but compares from the end
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  DS:DI = second array
	     CX = length of array in bytes
          'Insert1' defined to insert COMPBACKWARD() instead of calling
   Uses: COMPBACKWARD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
COMPBACKWARD();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, destroyed
	    ES = DS
*/



inline byte COMPBACKWARDNEARW ((E)SI, (E)DI, (E)CX)
/* Compares CX words at DS:SI with words at DS:DI.
   Basically COMPNEARW(), but compares from the end
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  DS:DI = second array
	     CX = length of array in words
          'Insert1' defined to insert COMPBACKWARDW() instead of calling
   Uses: COMPBACKWARDW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
COMPBACKWARDW();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, destroyed
	    ES = DS
*/



inline byte COMPBACKWARDNEARD ((E)SI, (E)DI, (E)CX)
/* Compares CX dwords at DS:SI with words at DS:DI.
   Basically COMPNEARD(), but compares from the end
   NOTE: If you need different DS then you have to set it before calling
	   this procedure.
   Input: DS:SI = first array
	  DS:DI = second array
	     CX = length of array in dwords
          'Insert1' defined to insert COMPBACKWARDD() instead of calling
   Uses: COMPBACKWARDD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 12 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
COMPBACKWARDD();
@UNDEFINEINSERT1();
}
/* Returns: AX = CX = 0 if success
	    AX = 1, CX undetermined by failure
	    SI, DI, destroyed
	    ES = DS
*/



inline void COPY ((E)DI, (E)SI, (E)CX)
/* Copies given number of bytes
   Basically COPYNEAR() but doesn't need source segment
   Note: bytes are copied forward, ie from lower to higher address
   Input: ES:DI = destiny
	  DS:SI = source
	     CX = bytes
   Uses: 2 bytes of stack
   Size: 5 bytes
*/
{
$PUSHF
$CLD
$REP $MOVSB
$POPF
}
/* Returns: nothing
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYW ((E)DI, (E)SI, (E)CX)
/* Copies given number of words
   Basically COPYNEARW() but doesn't need source segment
   Note: words are copied forward, ie from lower to higher address
   Input: ES:DI = destiny
	  DS:SI = source
	     CX = words
   Uses: 2 bytes of stack
   Size: 5 bytes
*/
{
$PUSHF
$CLD
$REP $MOVSW
$POPF
}
/* Returns: nothing
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYD ((E)DI, (E)SI, (E)CX)
/* Copies given number of dwords
   Basically COPYNEARD() but doesn't need source segment
   Note: dwords are copied forward, ie from lower to higher address
   Input: ES:DI = destiny
	  DS:SI = source
	     CX = dwords
   Uses: 2 bytes of stack
   Size: 5 bytes
*/
{
$PUSHF
$CLD
$REP $MOVSD
$POPF
}
/* Returns: nothing
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYTOFAR (AX, (E)DI, (E)SI, (E)CX)   // ver. 1.01, uses COPY()
/* Copies bytes from DS to given segment
   Basically COPYFAR() but doesn't need source segment
   Note: bytes are copied forward, ie from lower to higher address
   Input: AX = destiny segment
	  DI = destiny offset
	  SI = source offset
	  CX = bytes
          'Insert1' defined to insert COPY() instead of calling
   Uses: COPY() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COPY();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX, ES destiny segment
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYTOFARW (AX, (E)DI, (E)SI, (E)CX)   // ver. 1.01, uses COPYW()
/* Copies words from DS to given segment
   Basically COPYFARW() but doesn't need source segment
   Note: words are copied forward, ie from lower to higher address
   Input: AX = destiny segment
	  DI = destiny offset
	  SI = source offset
	  CX = words
          'Insert1' defined to insert COPYW() instead of calling
   Uses: COPYW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COPYW();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX, ES destiny segment
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYTOFARD (AX, (E)DI, (E)SI, (E)CX)   // ver. 1.01, uses COPYW()
/* Copies dwords from DS to given segment
   Basically COPYFARD() but doesn't need source segment
   Note: words are copied forward, ie from lower to higher address
   Input: AX = destiny segment
	  DI = destiny offset
	  SI = source offset
	  CX = dwords
          'Insert1' defined to insert COPYD() instead of calling
   Uses: COPYD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COPYD();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX, ES destiny segment
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYFROMFAR ((E)DI, AX, (E)SI, (E)CX)   // ver. 1.01, uses COPY()
/* Copies bytes from given to DS segment
   Basically COPYFAR() but doesn't need destiny segment
   Note: bytes are copied forward, ie from lower to higher address
   Input: DI = destiny offset
	  AX = source segment
	  SI = source offset
	  CX = bytes
          'Insert1' defined to insert COPY() instead of calling
   Uses: COPY() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
$PUSH DS,DS
$POP ES
DS = AX;
? ifdef Insert1
   @
? endif
COPY();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void COPYFROMFARW ((E)DI, AX, (E)SI, (E)CX)   //ver. 1.01, uses COPYW()
/* Copies words from given to DS segment
   Basically COPYFARW() but doesn't need destiny segment
   Note: words are copied forward, ie from lower to higher address
   Input: DI = destiny offset
	  AX = source segment
	  SI = source offset
	  CX = words
          'Insert1' defined to insert COPYW() instead of calling
   Uses: COPYW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
$PUSH DS,DS
$POP ES
DS = AX;
? ifdef Insert1
   @
? endif
COPYW();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void COPYFROMFARD ((E)DI, AX, (E)SI, (E)CX)   //ver. 1.01, uses COPYW()
/* Copies dwords from given to DS segment
   Basically COPYFARD() but doesn't need destiny segment
   Note: words are copied forward, ie from lower to higher address
   Input: DI = destiny offset
	  AX = source segment
	  SI = source offset
	  CX = dwords
          'Insert1' defined to insert COPYD() instead of calling
   Uses: COPYD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
$PUSH DS,DS
$POP ES
DS = AX;
? ifdef Insert1
   @
? endif
COPYD();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void COPYBACKWARD ((E)DI, (E)SI, (E)CX)
/* Copies given number of bytes
   Note: bytes are copied backwards, ie from higher to lower address
   Input: ES:DI = destiny
	  DS:SI = source
	     CX = bytes
   Uses: 2 bytes of stack
   Size: ca. 9 bytes
*/
{
$PUSHF
(E)SI += (E)CX;
(E)DI += (E)CX;
$STD
$REP $MOVSB
$POPF
}
/* Returns: nothing
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYBACKWARDW ((E)DI, (E)SI, (E)CX)
/* Copies given number of words
   Basically COPYNEARW() but doesn't need source segment
   Note: words are copied backwards, ie from higher to lower address
   Input: ES:DI = destiny
	  DS:SI = source
	     CX = words
   Uses: 2 bytes of stack
   Size: ca. 9 bytes
*/
{
$PUSHF
(E)SI += (E)CX;
(E)DI += (E)CX;
$STD
$REP $MOVSW
$POPF
}
/* Returns: nothing
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYBACKWARDD ((E)DI, (E)SI, (E)CX)
/* Copies given number of dwords
   Basically COPYNEARD() but doesn't need source segment
   Note: dwords are copied backwards, ie from higher to lower address
   Input: ES:DI = destiny
	  DS:SI = source
	     CX = dwords
   Uses: 2 bytes of stack
   Size: ca. 9 bytes
*/
{
$PUSHF
(E)SI += (E)CX;
(E)DI += (E)CX;
$STD
$REP $MOVSD
$POPF
}
/* Returns: nothing
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYBACKWARDTOFAR (AX, (E)DI, (E)SI, (E)CX)
/* Copies bytes from DS to given segment
   Basically COPYFAR() but doesn't need source segment
   Note: bytes are copied backwards, ie from higher to lower address
   Input: AX = destiny segment
	  DI = destiny offset
	  SI = source offset
	  CX = bytes
          'Insert1' defined to insert COPYBACKWARD() instead of calling
   Uses: COPYBACKWARD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COPYBACKWARD();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX, ES destiny segment
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYBACKWARDTOFARW (AX, (E)DI, (E)SI, (E)CX)
/* Copies words from DS to given segment
   Basically COPYFARW() but doesn't need source segment
   Note: words are copied backwards, ie from higher to lower address
   Input: AX = destiny segment
	  DI = destiny offset
	  SI = source offset
	  CX = words
          'Insert1' defined to insert COPYBACKWARDW() instead of calling
   Uses: COPYBACKWARDW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COPYBACKWARDW();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX, ES destiny segment
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYBACKWARDTOFARD (AX, (E)DI, (E)SI, (E)CX)
/* Copies dwords from DS to given segment
   Basically COPYFARD() but doesn't need source segment
   Note: words are copied backwards, ie from higher to lower address
   Input: AX = destiny segment
	  DI = destiny offset
	  SI = source offset
	  CX = dwords
          'Insert1' defined to insert COPYBACKWARDD() instead of calling
   Uses: COPYBACKWARDD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
ES = AX;
? ifdef Insert1
   @
? endif
COPYBACKWARDD();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX, ES destiny segment
	    SI, DI undetermined
	    CX = 0
*/



inline void COPYBACKWARDFROMFAR ((E)DI, AX, (E)SI, (E)CX)
/* Copies bytes from given to DS segment
   Basically COPYFAR() but doesn't need destiny segment
   Note: bytes are copied backwards, ie from higher to lower address
   Input: DI = destiny offset
	  AX = source segment
	  SI = source offset
	  CX = bytes
          'Insert1' defined to insert COPYBACKWARD() instead of calling
   Uses: COPYBACKWARD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
$PUSH DS,DS
$POP ES
DS = AX;
? ifdef Insert1
   @
? endif
COPYBACKWARD();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void COPYBACKWARDFROMFARW ((E)DI, AX, (E)SI, (E)CX)
/* Copies words from given to DS segment
   Basically COPYFARW() but doesn't need destiny segment
   Note: words are copied backwards, ie from higher to lower address
   Input: DI = destiny offset
	  AX = source segment
	  SI = source offset
	  CX = words
          'Insert1' defined to insert COPYBACKWARDW() instead of calling
   Uses: COPYBACKWARDW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
$PUSH DS,DS
$POP ES
DS = AX;
? ifdef Insert1
   @
? endif
COPYBACKWARDW();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void COPYBACKWARDFROMFARD ((E)DI, AX, (E)SI, (E)CX)
/* Copies dwords from given to DS segment
   Basically COPYFARD() but doesn't need destiny segment
   Note: words are copied backwards, ie from higher to lower address
   Input: DI = destiny offset
	  AX = source segment
	  SI = source offset
	  CX = dwords
          'Insert1' defined to insert COPYBACKWARDD() instead of calling
   Uses: COPYBACKWARDD() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 11 bytes
*/
{
$PUSH DS,DS
$POP ES
DS = AX;
? ifdef Insert1
   @
? endif
COPYBACKWARDD();
$POP DS
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STORE ((E)DI, AL, (E)CX)
/* Fills area with the given byte
   Note: bytes are stored forward, ie from lower to higher address
   Input: ES:DI = destiny
	     AL = byte for filling
	     CX = bytes
   Uses: 2 bytes of stack
   Size: 5 bytes
*/
{
$PUSHF
$CLD
$REP $STOSB
$POPF
}
/* Returns: nothing
	    AL = given byte
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STOREW ((E)DI, AX, (E)CX)
/* Fills area with the given word
   Note: words are stored forward, ie from lower to higher address
   Input: ES:DI = destiny
	     AX = word for filling
	     CX = words
   Uses: 2 bytes of stack
   Size: 5 bytes
*/
{
$PUSHF
$CLD
$REP $STOSW
$POPF
}
/* Returns: nothing
	    AX = given word
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STORED ((E)DI, EAX, (E)CX)
/* Fills area with the given dword
   Note: dwords are stored forward, ie from lower to higher address
   Input: ES:DI = destiny
	    EAX = dword for filling
	     CX = words
   Uses: 2 bytes of stack
   Size: 5 bytes
*/
{
$PUSHF
$CLD
$REP $STOSD
$POPF
}
/* Returns: nothing
	    EAX = given dword
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STORENEAR ((E)DI, AL, (E)CX)   // ver. 1.01, uses STORE()
/* Fills area with the given byte
   Note: bytes are stored forward, ie from lower to higher address
   Input: DS:DI = destiny
	     AL = byte for filling
	     CX = bytes
          'Insert1' defined to insert STORE() instead of calling
   Uses: STORE() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
STORE();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX = given byte
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STORENEARW ((E)DI, AX, (E)CX)   // ver. 1.01, uses STOREW()
/* Fills area with the given word
   Note: words are stored forward, ie from lower to higher address
   Input: DS:DI = destiny
	     AX = word for filling
	     CX = words
          'Insert1' defined to insert STOREW() instead of calling
   Uses: STOREW() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
STOREW();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX = given word
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STORENEARD ((E)DI, EAX, (E)CX)
/* Fills area with the given dword
   Note: dwords are stored forward, ie from lower to higher address
   Input: DS:DI = destiny
	    EAX = dword for filling
	     CX = words
          'Insert1' defined to insert STORED() instead of calling
   Uses: STORED() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
$PUSH DS
$POP ES
? ifdef Insert1
   @
? endif
STORED();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    EAX = given word
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STOREFAR (BX, (E)DI, AL, (E)CX)   // ver. 1.01, uses STORE()
/* Fills given segment with the given byte
   Basically STORENEAR() but changes ES
   Note: bytes are stored forward, ie from lower to higher address
   Input: BX = destiny segment
	  DI = destiny offset
	  AL = byte for filling
	  CX = bytes
          'Insert1' defined to insert STORE() instead of calling
   Uses: STORE() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
ES = BX;
? ifdef Insert1
   @
? endif
STORE();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AL = given byte
	    BX = ES = destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STOREFARW (BX, (E)DI, AX, (E)CX)   // ver. 1.01, uses STOREW()
/* Fills given segment with the given word
   Basically STORENEARW() but changes ES
   Note: words are stored forward, ie from lower to higher address
   Input: BX = destiny segment
	  DI = destiny offset
	  AX = word for filling
	  CX = words
          'Insert1' defined to insert STOREW() instead of calling
   Uses: STOREW() from BYTES.H--
         2 -4 bytes of stack
   Size: ca. 7 bytes
*/
{
ES = BX;
? ifdef Insert1
   @
? endif
STOREW();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    AX = given word
	    BX = ES = destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline void STOREFARD (BX, (E)DI, EAX, (E)CX)
/* Fills given segment with the given dword
   Basically STORENEARD() but changes ES
   Note: words are stored forward, ie from lower to higher address
   Input:  BX = destiny segment
	   DI = destiny offset
	  EAX = dword for filling
	   CX = words
           'Insert1' defined to insert STORED() instead of calling
   Uses: STORED() from BYTES.H--
         2 - 4 bytes of stack
   Size: ca. 7 bytes
*/
{
ES = BX;
? ifdef Insert1
   @
? endif
STORED();
@UNDEFINEINSERT1();
}
/* Returns: nothing
	    EAX = given word
	    BX = ES = destiny segment
	    SI, DI undetermined
	    CX = 0
	    ES = DS
*/



inline word AX2BX ()
/* Sets AX to BX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: AX = BX
	   BX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  // This code actually compiles to XCHG BX,AX (in other words: when
  // optimizing for codesize then we'll get *exactly* the same code as by
  // BX2AX() ) but it'll look "nicer" when writing this way   :)
  AX >< BX;
? else
  AX = BX;
? endif
}



inline word AX2CX ()
/* Sets AX to CX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: AX = CX
	   CX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  AX >< CX;
? else
  AX = CX;
? endif
}



inline word AX2DX ()
/* Sets AX to DX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: AX = DX
	   DX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  AX >< DX;
? else
  AX = DX;
? endif
}



inline word AX2DI ()
/* Sets AX to DI
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: AX = DI
	   DI undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  AX >< DI;
? else
  AX = DI;
? endif
}



inline word AX2SI ()
/* Sets AX to SI
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: AX = SI
	   SI undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  AX >< SI;
? else
  AX = SI;
? endif
}



inline word AX2BP ()
/* Sets AX to BP
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: AX = BP
	   BP undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  AX >< BP;
? else
  AX = BP;
? endif
}



inline word AX2SP ()
/* Sets AX to SP
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: AX = SP
	   SP undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  AX >< SP;
? else
  AX = SP;
? endif
}



inline void BX2AX ()
/* Sets BX to AX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: nothing
	   BX = AX
	   AX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  BX >< AX;
? else
  BX = AX;
? endif
}



inline void CX2AX ()
/* Sets CX to AX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: nothing
	   CX = AX
	   AX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  CX >< AX;
? else
  CX = AX;
? endif
}



inline void DX2AX ()
/* Sets DX to AX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: nothing
	   DX = AX
	   AX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  DX >< AX;
? else
  DX = AX;
? endif
}



inline void DI2AX ()
/* Sets DI to AX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: nothing
	   DI = AX
	   AX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  DI >< AX;
? else
  DI = AX;
? endif
}



inline void SI2AX ()
/* Sets SI to AX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: nothing
	   SI = AX
	   AX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  SI >< AX;
? else
  SI = AX;
? endif
}



inline void BP2AX ()
/* Sets BP to AX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: nothing
	   BP = AX
	   AX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  BP >< AX;
? else
  BP = AX;
? endif
}



inline void SP2AX ()
/* Sets SP to AX
   Is meant to be used in header files to avoid re-writing optimized versions
   Input:  nothing
   Output: nothing
	   SP = AX
	   AX undetermined
   Uses: 0 - 2 bytes of stack
   Size: min. 1 byte
*/
{
? ifdef codesize
  SP >< AX;
? else
  SP = AX;
? endif
}


? endif


/* end of BYTES.H-- */
