==================================================================== Quiz 11: User Friendly Assembler Program for Computing the Factorial [TOC] ==================================================================== Write an assembly program `factorial.s` where a user is first asked to type in some unsigned integer $n$, then prints the value of $n$ followed by the string "`! = `" (characters: '`!`', space, '`=`', space) and then prints the value of $n!$ followed by a newline. So an example run could look as follows: ---- CODE (type=txt) ---- theon$ 1_ulm_build/func/ulm a.out n = 0 0! = 1 theon$ 1_ulm_build/func/ulm a.out n = 1 1! = 1 theon$ 1_ulm_build/func/ulm a.out n = 2 2! = 2 theon$ 1_ulm_build/func/ulm a.out n = 3 3! = 6 theon$ 1_ulm_build/func/ulm a.out n = 4 4! = 24 theon$ 1_ulm_build/func/ulm a.out n = 5 5! = 120 theon$ 1_ulm_build/func/ulm a.out n = 6 6! = 720 theon$ 1_ulm_build/func/ulm a.out n = 7 7! = 5040 theon$ 1_ulm_build/func/ulm a.out n = 15 15! = 1307674368000 ------------------------- Submit your program and the used `isa.txt` with `submit hpc quiz11 isa.txt factorial.s` How Submit Checks Results ========================= ---- SHELL (path=session12/func/, hide) ---------------------------------------- make 1_ulm_build/func/ulmas factorial.s -------------------------------------------------------------------------------- Submit will use shell command to get results computed by your program. It therefore uses the `echo` connected by a pipe with your program. Try this with your program yourself: ---- SHELL (path=session12/func/) ---------------------------------------------- echo 5 | 1_ulm_build/func/ulm a.out -------------------------------------------------------------------------------- So the output that you see does not contain the user input. It only contains what your program prints, i.e. - the string "`n = `" (without a newline), - the value of $n$, - the string "`! = `" (without a newline), - the value of $n!$, In addition it will write the output of your program into a file, like this: ---- SHELL (path=session12/func/) ---------------------------------------------- echo 5 | 1_ulm_build/func/ulm a.out > res -------------------------------------------------------------------------------- It will then compare with `diff` whether `res` contains what we expect by comparing it with some solution file `sol`. So obviously file `res` here contains :import: session12/func/res ---- SHELL (path=session12/func/, hide) ---------------------------------------- cp res sol -------------------------------------------------------------------------------- and this is identical with the content of `sol`. But let's assume `res` would have this content (where a space is missing now): ---- CODE (file=session12/func/res_ups) ---------------------------------------- n = 5! =120 -------------------------------------------------------------------------------- Then with `diff` we get ---- SHELL (path=session12/func/) ---------------------------------------------- diff res_ups sol -------------------------------------------------------------------------------- and this will also show up in the error report.