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:
[ Parent
| on HN ]
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.