5.8 · exercise
The absolute truth
The starter reads one signed number into the value register. Print its magnitude: -42 prints as 42.
Compare the register against zero, skip the sign flip when it is not negative, and flip it otherwise. neg flips the sign of a register in one instruction.
What is checked
- the magnitude is printed on its own line
- the program exits cleanly
cmpmakes the decision, andnegflips the sign- the same holds for other inputs you do not see: positive values and zero have to come out unchanged
specification
stdin-42
stdoutprints the right output
exitexits with the right code
sourceuses
negsourceuses
cmphiddenright output and exit code on 4 more inputs you do not see
We run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.