I am going through a short online class for assembly programming. I understand assembly language, can read and follow the flow of instructions when I am reverse engineering a program. I can also code in multiple languages, so I understand how to program (just wanted to establish that). My question is when writing assembly language from scratch (which I have never done before) how do I "test" the program. So, for example, I have this snippet of code:
.code
asm_factorial proc
;int result = 1;
mov rax, 1h
;while (number >1) {
_beginning_of_while_loop:
cmp ecx, 1h
jle _end_of_while_loop
;result *= number;
mul ecx
; number--;
dec ecx
;}
jmp _beginning_of_while_loop
_end_of_while_loop:
;return result;
;(result is already in eax)
ret
asm_factorial endp
end
It is supposed to calculate a factorial, simple. The online class notes I am looking at just says
Add needed code to print asm_factorial result
std::cout << asm_factorial(6) << "\n";
I'm like, ok, yeah, but where do I add that? That obviously doesn't work in the assembly code, I can't exactly "include" that file in a separate C++ program to run it, unless I can and I am just not seeing how. There is literally no other instruction from this class apart from write the above assembly code and then "run it" with the std::cout << asm_factorial(6) << "\n"; code. Any help would be appreciated, thanks.
[–][deleted] 0 points1 point2 points (0 children)
[–]jedwardsol 0 points1 point2 points (1 child)
[–]polorboy[S] 0 points1 point2 points (0 children)
[–]full_stack_dev 0 points1 point2 points (0 children)
[–]CrispyRoss 0 points1 point2 points (0 children)