I am trying to write a single 68000 instruction to multiply the 32-bit unsigned value in D0 by 0.125. Yet fractional multiplication is not available. So I am wondering if there is any way to go around it? It's supposed to be unsigned and 0.125 = 1/8. Thus, the way I thought it would work is:
LSL (LSR #0,#3),D0
This didn't even run, and I have no idea how else I could do it.
This is assembly, you cannot just compose expressions combining instructions like that. Each instruction needs to be on its own line. If you want to implement
(x >> 3) << 3
you'll have to first shift right, then shift left, which are two separate instructions:By the way, note that
(x >> N) << N
is equivalent tox & -(1 << N)
, which in the case ofN=3
is:x & -8
, or in 68k assemblyAND.L #-8,D0
(or in hexAND.L #$fffffff7,D0
).However, if you want to just multiply by 0.125 (i.e. divide by 8), one right shift will suffice: