%include "CONSTANTS.h" section .data prompt: db `Enter a value for n \n`,0 inputFmt: db `%d`,0 endl: db `\n`,0 fmtString: db `%d! = %20d\n`,0 debugString: db `%d is the number\n`,0 section .bss section .text global main main: ;mov rdi, format1 ;mov rsi, -1 ;call CallPrintf ; cout << "Enter a number" mov rdi, prompt call CallPrintf ; cin >> n mov rdi, inputFmt call CallScanf mov r14, rsi; mov rdi, debugString call CallPrintf ; r12 will be i ; r13 will be fact ; r14 will be n ; save the input value from rsi to r14 ; if n == 0 or n == 1 cmp r14, 0; je factIs1 cmp r14, 1 je factIs1 ; else ; fact 1; mov r13, 1 ; i = 2; mov r12, 2 topOfLoop: ; while i <= n cmp r12, r14 jg outOfLoop; ; fact *= i imul r13, r12 ; print i! = fact mov rdi, fmtString mov rsi, r12 mov rdx, r13 ; I had forgotten to put the call to printf in during class. call CallPrintf ; i++ inc r12 jmp topOfLoop factIs1: ; cout n! = 1 mov rdi, fmtString mov rsi, r14 mov rdx, 1 call CallPrintf outOfLoop: jmp Exit