Pm designer operation manual – B&B Electronics WOP-2121V-N4AE - Manual User Manual
Page 428

4
14
PM Designer Operation Manual
14-19
CHAPTER 14 USING MACROS
B2W
Format
P1
= B2W(P2,P3)
Data Type
U
Function Converts
P3-byte array starting from P2 to a P3-word array and saves the result in P1. All the high
bytes of the word array are set to 0.
P1 (I)
The location (or the word array) to save the result.
P2 (I)
The byte array to be converted.
P3 (I/C)
The size of the byte array.
Example 1
$U200
=
0x45FA
$U201
=
0xEB29
$U100
= B2W(
$U200
,
3
)
/* Convert 3 bytes starting from $U200 to 3 words starting from $U100,
$U100 will be 0xFA, $U101 will be 0x45 and $U102 will be 0x29. */
W2B
Format
P1
= W2B(P2,P3)
Data Type
U
Function
Converts a word array P2 with P3 elements to a byte array and saves the result in the byte array
P1. The conversion discards the high byte of every element of the word array to form a byte array
with the same number of elements. The array size can not exceed 256.
P1 (I)
The location (or the word array) to save the result.
P2 (I)
The word array to be converted.
P3 (I/C)
The size of the word array.
Example 1
$U200
=
0x45FA
$U201
=
0xEB29
$U202
=
0xC781
$U100
= W2B(
$U200
,
3
)
/* Convert 3 words starting from $U200 to 3 bytes starting from
$U100, $U100 will be 0x29FA and the low byte of $U101 will be 0x81*/
A2X
Format
P1
= A2X(P2)
Data Type
U
Function
Converts a 4-digit hex number in ASCII character form to a binary number and saves the result in
P1. The character of the fourth digit is in the first word of the word array P2 and the characters of
the other digits are in the following words in sequence.
P1 (I)
The location to save the result.
P2 (I)
The word array that contains the characters to be converted.
Example 1
$U20
=
49
// '1'
$U21
=
50
// '2'
$U22
=
69
// 'E'
$U23
=
70
// 'F'
$U100
= A2X(
$U20
)
/* The value of $U100 will be 0x12EF. */