Number of data words from bytes

Is there a simple method to determine the number dwords if given a number of bytes? For example, if 3 bytes, then one dword. If 7 dwords, then 2 dwords. If anyone has a short method, please let me know.

In reply to Robert.Lanier:

What’s the definition of a “dword” ?

In reply to KillSteal:

In reply to Robert.Lanier:
What’s the definition of a “dword” ?

A double-word, 32-bits.

In reply to Robert.Lanier:

Try this:

localparm NUM_WORDS = ( NUM_BYTES + 3 ) / 4;

What makes this work is that the division is integer division.

In reply to Mark Curry:

In reply to Robert.Lanier:
Try this:

localparm NUM_WORDS = ( NUM_BYTES + 3 ) / 4;

What makes this work is that the division is integer division.

Seems like you would need a ceiling function for this to work.

In reply to Robert.Lanier:

The integer division effectively gives you a “floor” function. The +3 basically give you an offset on your argument. Try my solution, I think it fits your requirements perfectly.

In reply to Mark Curry:

In reply to Robert.Lanier:
The integer division effectively gives you a “floor” function. The +3 basically give you an offset on your argument. Try my solution, I think it fits your requirements perfectly.

Yes, this will work. Thanks for the help!