## Invitation to Computer Science 8th Edition

$\begin{array}{llll} {\text { }} & {\text {.BEGIN} } & {\text { } } & {\text { } }\\ {\text { }} & {\text {CLEAR} } & {\text {NEGCOUNT} } & {\text {--Step 1. Not really necessary} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--because} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--negcount is already set to 0} }\\ {\text { }} & {\text {LOAD} } & {\text {ONE} } & {\text {--Step 2. Set i to 1. Also not} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--really} }\\ {\text { }} & {\text {STORE} } & {\text {T} } & {\text {--necessary because i is} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--initialized to 1} }\\ {\text {LOOP:}} & {\text {LOAD} } & {\text {FIFTY} } & {\text {--Step 3. Check whether i . 50} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--and if so} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--terminate the loop} }\\ {\text { }} & {\text {COMPARE} } & {\text {I} } & {\text { } }\\ {\text { }} & {\text {JUMPGT} } & {\text {ENDLOOP} } & {\text { } }\\ {\text { }} & {\text {IN} } & {\text {N} } & {\text {--Step 4. Read a value} }\\ {\text { }} & {\text {LOAD} } & {\text {ZERO} } & {\text {--Step 5. Increment} }\\ {\text { }} & {\text { } } & {\text {FIFTY} } & {\text {--negcount if} }\\ {\text { }} & {\text {COMPARE} } & {\text {N} } & {\text {--N is less than zero} }\\ {\text { }} & {\text {JUMPGE} } & {\text {SKIP} } & {\text { } }\\ {\text { }} & {\text {INCREMENT} } & {\text {NEGCOUNT} } & {\text { } }\\ {\text {SKIP:}} & {\text {INCREMENT} } & {\text {I} } & {\text {--Step 6. Count one more} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--loop iteration} }\\ {\text { }} & {\text {JUMP} } & {\text {LOOP} } & {\text {--Step 7. and start the loop} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--over} }\\ {\text {ENDLOOP:}} & {\text {OUT} } & {\text {NEGCOUNT} } & {\text {--Step 8. Produce the final} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--answer} }\\ {\text { }} & {\text {HALT} } & {\text { } } & {\text {--Step 9. and halt} }\\ {\text {NEGCOUNT:}} & {\text {.DATA} } & {\text {0} } & {\text { } }\\ {\text {I:}} & {\text {.DATA} } & {\text {1} } & {\text { } }\\ {\text {N:}} & {\text {.DATA} } & {\text {0} } & {\text { } }\\ {\text {ONE:}} & {\text {.DATA} } & {\text {1} } & {\text { } }\\ {\text {FIFTY:}} & {\text {.DATA} } & {\text {50} } & {\text { } }\\ {\text {ZERO:}} & {\text {.DATA} } & {\text {0} } & {\text { } }\\ {\text {}} & {\text {.END} } & {\text { } } & {\text { } }\\ \end{array}$
$\begin{array}{llll} {\text { }} & {\text {.BEGIN} } & {\text { } } & {\text { } }\\ {\text { }} & {\text {CLEAR} } & {\text {NEGCOUNT} } & {\text {--Step 1. Not really necessary} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--because} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--negcount is already set to 0} }\\ {\text { }} & {\text {LOAD} } & {\text {ONE} } & {\text {--Step 2. Set i to 1. Also not} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--really} }\\ {\text { }} & {\text {STORE} } & {\text {T} } & {\text {--necessary because i is} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--initialized to 1} }\\ {\text {LOOP:}} & {\text {LOAD} } & {\text {FIFTY} } & {\text {--Step 3. Check whether i . 50} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--and if so} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--terminate the loop} }\\ {\text { }} & {\text {COMPARE} } & {\text {I} } & {\text { } }\\ {\text { }} & {\text {JUMPGT} } & {\text {ENDLOOP} } & {\text { } }\\ {\text { }} & {\text {IN} } & {\text {N} } & {\text {--Step 4. Read a value} }\\ {\text { }} & {\text {LOAD} } & {\text {ZERO} } & {\text {--Step 5. Increment} }\\ {\text { }} & {\text { } } & {\text {FIFTY} } & {\text {--negcount if} }\\ {\text { }} & {\text {COMPARE} } & {\text {N} } & {\text {--N is less than zero} }\\ {\text { }} & {\text {JUMPGE} } & {\text {SKIP} } & {\text { } }\\ {\text { }} & {\text {INCREMENT} } & {\text {NEGCOUNT} } & {\text { } }\\ {\text {SKIP:}} & {\text {INCREMENT} } & {\text {I} } & {\text {--Step 6. Count one more} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--loop iteration} }\\ {\text { }} & {\text {JUMP} } & {\text {LOOP} } & {\text {--Step 7. and start the loop} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--over} }\\ {\text {ENDLOOP:}} & {\text {OUT} } & {\text {NEGCOUNT} } & {\text {--Step 8. Produce the final} }\\ {\text { }} & {\text { } } & {\text { } } & {\text {--answer} }\\ {\text { }} & {\text {HALT} } & {\text { } } & {\text {--Step 9. and halt} }\\ {\text {NEGCOUNT:}} & {\text {.DATA} } & {\text {0} } & {\text { } }\\ {\text {I:}} & {\text {.DATA} } & {\text {1} } & {\text { } }\\ {\text {N:}} & {\text {.DATA} } & {\text {0} } & {\text { } }\\ {\text {ONE:}} & {\text {.DATA} } & {\text {1} } & {\text { } }\\ {\text {FIFTY:}} & {\text {.DATA} } & {\text {50} } & {\text { } }\\ {\text {ZERO:}} & {\text {.DATA} } & {\text {0} } & {\text { } }\\ {\text {}} & {\text {.END} } & {\text { } } & {\text { } }\\ \end{array}$