Shift Left One Bit

Purpose:

To shift the contents of the 16-bit variable value at location 6000 to the left one bit. The result is to be stored back into the the variable value.

Sample Test Data:

input: value: (6000) = 57B616 = 0101 0111 1011 01102
output result: (6000) = AF6C16 = 1010 1111 0110 11002
Note that (6000) means "the contents of location with address 6000". Clearly what we mean here is that the contents of
6000 and 6001 taken together is 57B6, where (6000) = 57 and (6001) = B6

Source Code:

data equ $6000  
program equ $4000  
       
  org data  
value ds.w 1 ;value to be shifted left
       
  org program  
  move.w value, d0 ;get value to be shifted
  lsl.w #1, d0 ;shift left one bit
  move.w d0, value ;store shifted result

Shifting a number left one digit always causes the number to be multiplied by the base of the number system, in this case 2. It may be less time consuming to multiply a number by 2 this way than to use the MUL instruction.

Back to 68000 program contents page