Free Pascal is a 32 bit compiler, so $ff shl 4= $ff0. Then $ff0 shr 4=$ff.

However, byte($ff shl 4)=$f0 , so adding a typecast gives the result you need.