Point_d_entree: tst.l d0 beq.s Resultat0 movem.l d2-d5,-(a7) cmp.l #65536,d0 bhi.s Else1ST moveq #1,d1 moveq #1,d4 bra.s Repeat1ST Else1ST: moveq #1,d1 swap d1 move.l #256,d4 Repeat1ST: add.l d4,d4 lsl.l #2,d1 cmp.l d0,d1 bls.s Repeat1ST move.l d4,d3 lsr.l #1,d3 moveq #0,d1 Repeat2ST: move.l d1,d2 move.l d3,d1 add.l d4,d1 lsr.l #1,d1 move.l d1,d5 mulu d5,d5 cmp.l d0,d5 bls.s Else2ST move.l d1,d4 cmp.l d1,d2 bne.s Repeat2ST movem.l (a7)+,d2-d5 rts Else2ST: move.l d1,d3 cmp.l d1,d2 bne.s Repeat2ST movem.l (a7)+,d2-d5 rts Resultat0: moveq #0,d1 rts
Voilà, tu passe le nombre dans d0 et récupère le résultat dans d1.
A ton service

PS : Ce doit être optimisable, enjoy.