News for hackers. Stuff that matters.
Re:Mill Computing in 2017 by kinghajj on Thursday January 12, 2017 @11:08AM (#13383328)
I think this would implement factorial. I can't remember some of the specific mnemonics, but this is the gist:

        # entering factorial: argument n is b0
        # drop initial accumulator to belt; bail early if n==0
        con(1), cmpeq(b1, 0), brtrue(end);
        # now, b0 == 1, b1 == n
    loop:
        # multiply accumulator by n, then decrement n, then check if n stil not 0
        mul(b0, b1), sub(b1, 1), cmpeq(b1, 0), brfalse(loop);
    end:
        # no matter what, the most recent accumulator is b0
        ret(b0);
Re:Mill Computing in 2017 by igodard on Thursday January 12, 2017 @03:28PM (#13385796)
ConAsm (model-dependent assembler) for "Silver" model:

F("fact") %0; sub(b0 %0, 1) %1;

        gtrsb(b0 %1, 1) %2,
          retnfl(b2 %0),
          inner("fact$1_1", b1 %1, b2 %0);
L("fact$1_1") %3 %4;

        mul(b1 %3, b0 %4) %5;

        sub(b0 %4, 1) %6;

        gtrsb(b0 %6, 1) %7,
          retnfl(b1 %5),
          br("fact$1_1", b2 %6, b1 %5);
Note that integer multiply is specified as 3 cycles in this model, so the recurrence in the loop takes three cycles. Other ops are one cycle. Each semicolon is an instruction (and cycle) boundary, ops separated by commas issue and execute together.
Re:Mill Computing in 2017 by kinghajj on Thursday January 12, 2017 @04:05PM (#13386096)
Ah, of course. I've watched your videos so much, how could I have forgotten that multiply is 3 cycles? Thanks for chiming in!