[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ROL Instruction



Bryan Parkoff wrote:

>    Why Motorola and Intel's ROL Instruction are not the same?
>
>    For example, Motorola rolates from $80 to $00.  The carry is turned on.
>It has to rolate from $00 to $01 second time.  Intel can rolates from $80 to
>$01 once.  I wonder why Motorla has to rolate twice.  Is it the way how
>Motorola is designed?

It is not unusual for instruction sets to have subtle differences
in semantics.

I'm not an Intel (8080, 8088, x86) assembly language programmer,
but I think that Intel generally offers _both_ kinds of rotates.
The 6502 designers' philosophy was simplicity, and they
only provided the "carry inclusive" rotates.

Taking the approach of including the carry bit in the circular
shift allows very easy extension to shifts of quantities larger
than one byte.  I find this much more useful than a rotate
instruction that does not include carry.

If you want to simulate a ROL that does not include carry,
it is only necessary to preset the carry bit to the high bit
of the shifted byte.  For example, if the A register is being
shifted, then preceding the ROL with a CMP #$80 will cause
the ROL to shift the high bit to the low bit position.

-michael

Check out amazing quality sound for 8-bit Apples on my
Home page:  http://members.aol.com/MJMahon/