#include "asm.h" // unsigned int64 mulu64_m(unsigned a, unsigned b); .text .global mulu64_m mulu64_m: movel d2, -(sp) movel #0x20, macsr // Put MAC in fraction mode movel #0, d2 movel d2, acc // Zero acc movel 12(sp), d1 movel 8(sp), d0 macl d0, d1 // Form upper half of product bplb 1f // First operand negative? movel d1, d2 // Yep, save unsigned correction 1: tstl d1 // Second operand negative? bplb 2f // Nope addl d0, d2 // Yep, save unsigned correction 2: mulul d0, d1 // Form lower half movel macsr, ccr // Overflow? bvsb 2f // Yes movel acc, d0 asrl #1, d0 // Correct for binary point position addl d2, d0 // Correct for unsigned 1: movel (sp)+, d2 rts 2: movel #0x40000000, d0 // Correct for overflow brab 1b