Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ iswap(3) — HP-UX Instrument Control Library G.03.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ipoke(3)

ipeek(3)

iscanf(3)

iprintf(3)

ISWAP(3)

HP-UX

NAME

iswap − provides byte-swapping between devices

SYNOPSIS

#include <sicl.h>
 

int iswap (addr, length, datasize);
int ibeswap (addr, length, datasize);
int ileswap (addr, length, datasize);
 char *addr;
unsigned long length;
int datasize;

 

DESCRIPTION

These functions provide an architecture-independent way of byte swapping data received from a remote device or data that is to be sent to a remote device.  This data may be received/sent using the iwrite/iread calls, or the ifwrite/ifread calls. 
 
The iswap function will always swap the data. 
 
The ibeswap function assumes the data is in big-endian byte ordering (big-endian byte ordering is where the most significant byte of data is stored at the least significant address) and converts the data to whatever byte ordering is native on this controller’s architecture.  Or it takes the data that is byte ordered for this controller’s architecture and converts the data to big-endian byte ordering. (Notice that these two conversions are identical.) 
 
The ileswap function assumes the data is in little-endian byte ordering (little-endian byte ordering is where the most significant byte of data is stored at the most significant address) and converts the data to whatever byte ordering is native on this controller’s architecture.  Or it takes the data that is byte ordered for this controller’s architecture and converts the data to little-endian byte ordering. (Notice that these two conversions are identical.) 
 
Depending on the native byte ordering of the controller in use (either little-endian, or big-endian), that either the “ibeswap” or “ileswap” functions will always be a no-op, and the other will always swap bytes, as appropriate.
 
In all three functions, the addr parameter specifies a pointer to the data.  The length parameter provides the length of the data in bytes.  The datasize must be one of the values 1, 2, 4, or 8.  It specifies the size of the data in bytes and the size of the byte swapping to perform:

 1byte data and no swapping is performed.
216-bit word data and bytes are swapped
on word boundaries.
432-bit longword data and bytes are swapped
on longword boundaries.
864-bit data and bytes are swapped on
8-byte boundaries.

 
The length parameter must be an integer multiple of datasize.  If not, unexpected results will occur. 
 
IEEE 488.2 specifies the default data transfer format to transfer data in big-endian format.  Non-488.2 devices may send data in either big-endian or little-endian format.
 
These functions do not depend on a SICL session id.  Therefore, they may be used to perform non-SICL related task (namely, file I/O). 
 
The following constants are available for use by your application to determine which byte ordering is native to this controller’s architecture.
 

­I_ORDER_LE This constant is defined if the native controller is little-endian. 

­I_ORDER_BE This constant is defined if the native controller is big-endian. 

 
These constants may be used in #if or #ifdef statements to determine the byte ordering requirements of this controller’s architecture.  This information can then be used with the known byte ordering of the devices being used to determine the swapping that needs to be performed.
 

RETURN VALUE

Iswap returns zero (0) if successful, or a non-zero error number if an error occurs. 
 

SEE ALSO

ipoke(3), ipeek(3), iscanf(3), iprintf(3)
 

AUTHOR

iswap was developed by HP. 

Hewlett-Packard Comapny  —  September 29, 1999

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026