Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 6 - 6.3 - Assemblers and Assembly Language - Practice Problem - Page 299: 1d

Answer

$\begin{array}{lll} {\text { $\quad$ }} & {\text {LOAD$\quad$} }& {\text {FIFTY} } & {\text {--R holds the constant 50} } \\ {\text { $\quad$ }} & {\text {COMPARE$\quad$} }& {\text {X} } & {\text { } } \\ {\text { $\quad$ }} & {\text {JUMPGT$\quad$} }& {\text {THEN} } & {\text {--if X > 50 go to label THEN} } \\ {\text { $\quad$ }} & {\text {IN$\quad$} }& {\text {X} } & {\text {--input a new value} } \\ {\text { $\quad$ }} & {\text {JUMP$\quad$} }& {\text { DONE} } & {\text {--and jump to done because we are} } \\ {\text { $\quad$ }} & {\text { $\quad$} }& {\text { } } & {\text {--all finished} } \\ {\text {THEN: $\quad$ }} & {\text {OUT$\quad$} }& {\text {X } } & {\text {} } \\ {\text {DONE: $\quad$ }} & {\text {$\quad$} }& {\text {} } &\text{--the next statement goes here} \\ {\text { $\quad$ }} & {\text {.} }& {\text {} } \\ {\text { $\quad$ }} & {\text {.} }& {\text {} } \\ {\text { $\quad$ }} & {\text {.} }& {\text {} } \\ {\text {FIFTY: $\quad$ }} & {\text {.DATA} }& {\text {0} } \\ {\text {X: $\quad$ }} & {\text {.DATA} }& {\text {50} } \\ \end{array}$

Work Step by Step

$\begin{array}{lll} {\text { $\quad$ }} & {\text {LOAD$\quad$} }& {\text {FIFTY} } & {\text {--R holds the constant 50} } \\ {\text { $\quad$ }} & {\text {COMPARE$\quad$} }& {\text {X} } & {\text { } } \\ {\text { $\quad$ }} & {\text {JUMPGT$\quad$} }& {\text {THEN} } & {\text {--if X > 50 go to label THEN} } \\ {\text { $\quad$ }} & {\text {IN$\quad$} }& {\text {X} } & {\text {--input a new value} } \\ {\text { $\quad$ }} & {\text {JUMP$\quad$} }& {\text { DONE} } & {\text {--and jump to done because we are} } \\ {\text { $\quad$ }} & {\text { $\quad$} }& {\text { } } & {\text {--all finished} } \\ {\text {THEN: $\quad$ }} & {\text {OUT$\quad$} }& {\text {X } } & {\text {} } \\ {\text {DONE: $\quad$ }} & {\text {$\quad$} }& {\text {} } &\text{--the next statement goes here} \\ {\text { $\quad$ }} & {\text {.} }& {\text {} } \\ {\text { $\quad$ }} & {\text {.} }& {\text {} } \\ {\text { $\quad$ }} & {\text {.} }& {\text {} } \\ {\text {FIFTY: $\quad$ }} & {\text {.DATA} }& {\text {0} } \\ {\text {X: $\quad$ }} & {\text {.DATA} }& {\text {50} } \\ \end{array}$
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.