I want to move 4 bytes, $B1,B2,B3,B4, one at a time, into data register D1.
The value I want in D1 is $B1B2B3B4.
Which instruction(s) will help me do this?
I want to move 4 bytes, $B1,B2,B3,B4, one at a time, into data register D1.
The value I want in D1 is $B1B2B3B4.
Which instruction(s) will help me do this?
I found a solution using LSL (Thank you, Chris Stratton), and SWAP:
MOVE.B #$B1,D0
LSL #8,D0
MOVE.B #$B2,D0
SWAP D0
MOVE.B #$B3,D0
LSL #8,D0
MOVE.B #$B4,D0
There's no point in using SWAP to do this, just combine moves, ors and shifts:
MOVE.B #$B1, D0 ; D0 now $xxxxxxB1
LSL.L #8, D0 ; $xxxxB100
ORI.B #$B2, D0 ; $xxxxB1B2
LSL.L #8, D0 ; $xxB1B200
ORI.B #$B3, D0 ; $xxB1B2B3
LSL.L #8, D0 ; $B1B2B300
ORI.B #$B4, D0 ; $B1B2B3B4
Maybe it's not shorter or faster, but at least I think it's clearer.
Sometimes you can just be direct about it:
MOVE.L #$B1B2B3B4,D0
(shrug)
There are clever ways to do what you want if you need to save memory or run very fast.