[net.puzzle] Short sequences of assembly language instructions

chuck@dartvax.UUCP (Chuck Simmons) (06/16/85)

The following 5 instruction routine is written in 68000 code.
What does it do?  

; D0 and D1 are 32 bit registers.

    move.l d0,d1          ;     d1 := d0
    bra.s L2              ;     goto L2
L1: sub.l d1,d0           ; L1: d0 := d0 - d1 
L2: lsr.l #1,d1           ; L2: d1 := d1 div 2
    bne.s L1              ;     if d1 <> 0 then goto L1

Cheers, Chuck