Mirsad Todorovac wrote:
I was wondering for a period of time however why no language implemented ROR and ROL operators (rotate right and left) - it may seem unnecessary, but sometimes you have to go to assembler just because C and Pascal miss this operator - it could be very useful, for example in filters, convolutions, CRC checksum calculation and graphics.
Yes, I've thought about this when I translated the MD5 unit for GPC. Currently it does (left) rotation as (w shl s) or (w shr (32 - s)) (which is translated from similar C code).
The backend seems to have support for rotation, so it might be easy to add it in GPC (I haven't checked yet, but it appears so).
If we do it, I think it should not be operators (because that would change the syntax more than necessary), but rather simple predefines functions (`RotateLeft', `RotateRight'?).
Of course, if a range of bytes is rotated, it's very useful to preserve carry flag somewhere - but I guess one has to do asm for that, doesn't he?
I'm not even sure how easy it is in asm. At least on IA32, if my information is correct, "The Carry Flag will contain the value of the last bit rotated out", but the old value of CF is not rotated in, so this would take some extra work, anyway.
So I guess for the (few, I assume) situations where someone wants to rotate more than one work (not byte), they'll have to do some manual coding, anyway, whether in Pascal or asm. Am I missing something?
Frank