/* Calculate the factorial of the number held in variable A. * The number in variable A must be greater than 0 and less than or equal * to 6! = 720 (note: 5! = 120) * Store factorial of A into 16 bit variable C. Byte ordering is little endian. * C = A! */ .INCLUDE .DSEG A: .BYTE 1 C: .BYTE 2 .CSEG Fact1_6: lds r16, A clr r0 inc r0 ; r0 = 1 fact1_6a: mul r0, r16 dec r16 brne fact1_6a sts C, r0 ; least significant byte (little end) sts C+1, r1 ; most significant byte (big end) rjmp Fact1_6