High and Low Order Words

For questions and postings not covered by the other forums
Biff
Posts: 3
Joined: Wed Nov 28, 2012 11:19 pm

High and Low Order Words

Postby Biff » Wed Nov 28, 2012 11:30 pm

Hello

I need to pass an lParam value to the SendMessage API function that takes a high-word and low-word value. However, as Jade doesn't have a bitwise shift operator or an quivalent to the HIWORD/LOWORD macros (to my knowledge), I was hoping someone might be able to point me in the right the direction as to the best way to achieve this in Jade.

I could write an external function but I'd rather handle this from within Jade (6.3.10).

Thanks

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: High and Low Order Words

Postby ghosttie » Thu Nov 29, 2012 12:04 am

You should be able to achieve a lot with bitOr and bitAnd.

I found some old shift methods on Integer, but I don't know if they're appropriate or even correct:

Code: Select all

shiftLeft(pI_Bits : Integer) : Integer; vars begin return self * (2 ^ pI_Bits); end;

Code: Select all

shiftRight(pI_Bits : Integer) : Integer; vars begin return self div (2 ^ pI_Bits); end;
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: High and Low Order Words

Postby murray » Thu Nov 29, 2012 7:41 am

Bit shifting is unnecessary, as in this case you only need to select on word/byte boundaries.
You can typecast an Integer or Integer64 to a Binary and then pick the bytes that you require.
Remember to allow for the correct byte ordering (Intel architecture being little-endian).

quick example:

Code: Select all

vars i , hi, lo : Integer; begin i := 12345678; // 0x00BC614E hi := i.Binary[3:2].Integer; lo := i.Binary[1:2].Integer; write i.Binary.display; // 4E61 BC00 write lo.Binary.display; // 4E61 0000 write hi.Binary.display; // BC00 0000 end;
Murray (N.Z.)


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 14 guests

cron