; Factorial JMP start N: DB 5 ; Variable to take factorial of Fact: DB 1 ; Factorial start: MOV A, [Fact] ; calculate fact in reg. A MOV B, [N] ; variable N to reg. B MOV C, 1 ; counting variable CMP B, 0 ; if variable is 0, fact is 1 JE .bot ; jump to end CMP B, 1 ; if variable is 1, fact is 1 JE .bot ; jump to end .top: INC C ; increment counter MUL C ; multiply A by C answer goes into A CMP B, C ; Check if end JNZ .top ; jump if not .bot: HLT