43.3.4.3 Swap

Purpose

This service performs swapping of two buffers.

How to Use the Service

Description

This service swaps two buffers, X and Y, of the same size in memory.

The service name for this operation is Swap.

Parameters Definition

This service can easily be accessed through the use of the PUKCL_Swap() macro.

Table 43-9. Swap Service Parameters
ParameterTypeDirectionLocationData LengthBefore Executing the ServiceAfter Executing the Service
nu1XBasenu1ICrypto RAMu2LengthBase of the number XBase of X filled with Y
nu1YBasenu1ICrypto RAMu2LengthBase of the number YBase of Y filled with X
u2XLengthu2ILength of X and YLength of X and Y

Code Example

_PARAM PUKCLParam;
PPUKCL_PARAM pvPUKCLParam = &PUKCLParam;

// Initialize parameters
PUKCL_Swap(nu1XBase) = <Base of the X number>; 
PUKCL_Swap(nu1YBase) = <Base of the Y number>; 
PUKCL_Swap(u2XLength) = <Length of the numbers>;

// vPUKCL_Process() is a macro command, which populates the service name
// and then calls the library... 
vPUKCL_Process(Swap,pvPUKCLParam); 
if (PUKCL(u2Status) == PUKCL_OK)
            {
            ...
            }
else // Manage the error

Constraints

The following conditions must be avoided to ensure that the service works correctly:

  • nu1XBase or nu1YBase are not aligned on 32-bit boundaries
  • u2XLength is either <4, > 0xffc, or not a 32-bit length
  • {nu1XBase, u2XLength} or {nu1YBase, u2XLength} do not entirely lie in PUKCCRAM
  • {nu1XBase, u2XLength} overlaps {nu1YBase,u2YLength}

Status Returned Values

Table 43-10. Swap Service Return Codes
Returned statusImportanceMeaning
PUKCL_OKService functioned correctly