Kev77
Member
Thanks Bernie, I will give it a try when I get to work in the morning.
Declare three variables, Final_Number, Temp_Hex and Character_Pos.
CLR Final_Number and Character_Pos
Do this while Character_Pos < String_Length
MOV String_Data[Character_Pos] to Temp_Hex (*)You should end up with Final_Number being equal to the string representation.
Subtract 48 from Temp_Hex (*)
If Temp_Hex > 15 then subtract 6 from Temp_Hex (*)
Multiply Final_Number by 16
Add Temp_Hex to Final_Number
Add 1 to Character_Pos
We are starting from the leftmost character of the string, getting its ASCII value, converting that to 0-15, left shifting Final_Number by 4 bits and adding in the converted character. We continue until we have processed the last character.
By the way - if you only want the value from one position then the starred (*) instructions are all you need.
Binary Hex ASCII
0000 0 48
0001 1 49
0010 2 50
0011 3 51
0100 4 52
0101 5 53
0110 6 54
0111 7 55
1000 8 56
1001 9 57
1010 A 65
1011 B 66
1100 C 67
1101 D 68
1110 E 69
1111 F 70
I will post a screen shot on how I have it set up now in the morning. It seems to work good but it looks ugly. I am sure there is a cleaner way to write it and I would like anyones thoughts. Currently I have a rung with (8) SUB instructions, one for each position.
Example:
Rung 1
string[0] - 48 = temp[0]
string[1] - 48 = temp[1]
string[2] - 48 = temp[2]
and so on...
Rung 2
string[0] GRT 15, SUB 7 to Binary 0 (SINT I think)
string[1] GRT 15, SUB 7 to Binary 1
string[1] GRT 15, SUB 7 to Binary 2
I can't figure out what this section is doingand so on...
Rung 3
string[0] LES 15, MOV string [0]to Binary 0
string[1] LES 15, MOV string [1]to Binary 1
string[2] LES 15, MOV string [2]to Binary 2
and so on...
I shortened your steps eliminating a variableI am going to try Bernie's total number solution in the morning. Thanks for all the suggestions.
I first contacted Rockwell last week and they we no help. They could not find a way to get it done. At first they thought I was crazy until they tried to convert ASCII 5 and got 53. I guess I should have gone here first! Thanks all...
Kevin
FEDC
^
FEDC
^
FEDC
^
FEDC
^