Number to Hex to String
It's too bad that you have to do this. If I understand you correctly, you have a number (1234) and you want to wind up with a string which is the Hex equivalent of this number ("04D2")
Here's a brute-force approach
Step 1. Separate the integer into 4 elements.
If your PLC is an AB (you don't say), you would use 4 MVM instructions (Move with Mask) using masks of 000Fh, 00F0h, 0F00h, and F000h to 4 different registers. Divide the resulting registers by 1, 16, 255, and 4096 respectively. Now each resulting register consists of a number 0 through 15.
1234 (= 0000 0100 1101 0010) =>=> 0, 4, 13, 2
Step 2. Convert the integer to it's ASCII equivalent.
To each register, add 48 to each of the numbers. If the resulting number is > 57, add an additional 7. (e.g., 10 (="A" hex) + 48 = 58 + 7 = 65 (= "A" in ASCII).
0 + 48 = 48
4 + 48 = 52
13+ 48 = 61 + 7 = 68
2 + 48 = 50
Step 3. Combine the ASCII 8-bit bytes into 16-bit words.
For each letter pair, multiply one of the numbers by 256 and add it to the remaining number. The final registers should be consecutive.
48 * 256 + 52 = 12340 (="04" ASCII)
68 * 256 + 50 = 17458 (="D2" ASCII)
If you are only working with ASCII registers, you can stop here.
Step 4. Put these in a string file.
If this is an AB processor, there are several ways to convert ASCII to string.
a. The instruction MOV N7:1 ST10:0.DATA[1]
b. If you know the lenght of the string, put it in the preceeding word, then use the COP instruction. (Assume the data is in N7:1 and N7:2) MOV 4 N7:0. COP #N7:0 ST10:0 1