test: clr.l -(sp) clr.l -(sp) move.l #$00001fff,-(sp) bsr.s _queens add.w #12,sp rts ; int queens (int a, int b, int c); _queens: movem.l d1-d4/a0,-(sp) movem.l 24(sp),d0-d2 move.l #$80000000,-(sp) sub.w #12,sp sub.l a0,a0 bra.s enter ; inner loop runs in 46 bytes ; d0-d4 32 bits registers ; a0 teller, optellen zonder carry te veranderen loop: sub.l d4,d3 ; d3 -= d4 movem.l d0-d3,-(sp) ; d0-d3 op stack sub.l d4,d0 ; d0 -= d4 (*) bls.s found ; if carry or zero jmp found ; (bls = Branch if Less or Same) or.l d4,d1 ; d1 |= d4 or.l d4,d2 ; d2 |= d4 add.l d1,d1 ; d1 *= 2 lsr.l #1,d2 ; d2 /= 2 enter: moveq #0,d4 ; d4 = 0 move.l d1,d3 ; d3 = d1 or.l d2,d3 ; d3 |= d2 not.l d3 ; d3 = ~d3 and.l d0,d3 ; d3 &= d0 bne.s for ; if d3!=0 jmp for return: movem.l (sp)+,d0-d3 ; stack naar d0-d3 for: sub.l d3,d4 ; d4 -= d3 and.l d3,d4 ; d4 &= d3 bne.s loop ; if d4!=0 jmp loop bra.s return ; jmp return found: addq.w #1,a0 ; inc a0, no flags!! bcc.s return ; if no carry, jmp return (carry van *) subq.w #1,a0 add.w #16,sp move.l a0,d0 movem.l (sp)+,d1-d4/a0 rts