Look at the SHIFTOUT command in the PBP manual. It does the hard work for you.