First of all you need to convert the codes into a decimal value.
I have little experience with Omron CP processors, and do not know all the instructions, however assume this processor is limited the best way is as following.
assume you have words containing 3031, 3233, this is the ASCII equivalent of "0123" in decimal so first take the 3031 word AND it with Decimal 15 this will give you "1" and store it in a register, shift the word right 8 places, AND it with 15 this will give you "0", do the same with the second word and you will have four words with the digits 1,0,3,2 but obviously these are in wrong order, assume these are W1,W2,W3,W4 then multiply
W1 by 100, hundreds
W2 by 1000, thousands
W3 by 10, tens
W4 by nothing as this is units
Add words 1,2,3,4 gives you 0123 decimal, do this for all the values then compare for lowest.
I know Omron have these simple instructions in some form
So to re-iterate:
AND Word 1 with 15 & store in Word x
Shift Right 8 bits Word 1 to remove lower byte & put upper byte in lower byte (or swap bytes if instruction is available).
AND It with 15 & Store in word x+1
do same for word 2
You then have 4 words with decimal equivalents of the data,Multiply all words by their respective multiplier
Add them up & store decimal value You will need to find the instructions Omron have in this CPU I believe they have NASR (Bit Shift) & SWAP (swap bytes).
If I had to do this in Siemens It would look something like this
L DW 100 'first word W1 Hex 3031
L KF 15 ' Mask Decimal 15, Hex F
AW 'AND it
L KF 100 '100's Multiplier
XF ' multiply
T DW 200 'Store value 1 Hundreds
L DW 100
SRW 8 ' Shift right to get upper byte into lower byte = H0030
LKF 15 'Mask
AW
L KF 1000 ' Thousand's multiplier
XF
T DW 201 'Store value Thousands (0)
L DW 101 ' Second word W2 Hex 3233
L KF 15 ' Mask
AW ' No need for multiplier as this is units
T DW 202 ' Store Value 3
L DW 101
SR W 8
L KF 15
AW
L KF 10 ' Tens multiplier
XF
T DW 203 ' Store Value 20 (2)
L DW 200 ' Hundreds
+F ' ADD
L DW 201 ' Thousands
+F
L DW 202 ' Units
+F
T DW204 ' Decimal value 0123
In actual fact, this is just to show the steps to convert from hex (ASCII) to a decimal value, I could have done this using things like TAK instructions to reduce the use of data words or other instructions before anyone criticises it.
Edit: Garry: Good point, however, he needs a decimal value for a counter value according to the post.