PDA

View Full Version : Regarding Packing of 2 Bytes


NAVNEET ACHARYA
05-15-04, 02:49 PM
Sir,

I am trying to concatenate two Eight bits number ,But Having

some problem. My code is as follows:



: LEFT_SHIFT_8 DATA4 C@ 2* 2* 2* 2* 2* 2* 2* 2* DATA4 ! ;
HEX
: PACK
DATA4 C@ 0F AND DATA4 C!
LEFT_SHIFT_8
DATA5 C@ FF AND DATA5 !
DATA4 C@ DATA5 @ OR DATA4 !

;


When I am calling this Macro in my program,My Program doesn't work,Without calling it It's working fine.

Please Give me suggestion Regarding This Program As soon as

possible.

Regards,

RMDumse
05-15-04, 08:15 PM
You know, one of the most wonderful things about an interactive environment is you can try things for yourself. Have you tried to run this word by hand? to see if it works? or if it hangs up?

Off the top of my head I see no reason this word should not work. I do suspect it will not give the results you are looking for. But that is easily tested, by you, to see if it gives the results you are looking for.

For me, i would have handled the packing of two bytes differently, but then, I do not know the details of what you are trying to do.

If I had two consecutive bytes I wanted to merge into a single hex number, I'd probably use the byte swap word >< .

So if I had a character data in DATA4 and another in DATA5, I might do this:

DATA4 @ 0F AND >< DATA5 @ 0F AND OR