; Factorial program ; Calculates the factorial of a number stored in register A ; Result is stored in register B start: cst A, 10 ; Load the number 10 into register A (change this value to calculate a different factorial) cst B, 01 ; Initialize result in register B to 1 cst C, loop ; Load the address of the loop label into register C loop: mul B, B, A ; B = B * A cst D, 01 sub A, A, D ; A = A - 1 cmp D, A, D ; If A = 1, loop will end jz D, C ; If A is not equal to 1, jump to loop end: ; Result is now in register B ; End of program