## Invitation to Computer Science 8th Edition

Published by Cengage Learning

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

#### Answer

$\begin{array}{lll} {\text {$\quad$}} & {\text {LOAD$\quad$} }& {\text {Y} } & {\text {--Load the value of Y into register R} } \\ {\text {$\quad$}} & {\text {ADD$\quad$} }& {\text {Z} } & {\text {--R now holds the sum (Y + Z)} } \\ {\text {$\quad$}} & {\text {SUBTRACT$\quad$} }& {\text {TWO} } & {\text {--R now holds (Y + Z - 2)} } \\ {\text {$\quad$}} & {\text {STORE$\quad$} }& {\text {X} } & {\text {--Store the result in X} } \\ {\text {$\quad$}} & {\text {,$\quad$} }& {\text { } } & {\text {X} } \\ {\text {$\quad$}} & {\text {,$\quad$} }& {\text { } } & {\text {X} } \\ {\text {$\quad$}} & {\text {,$\quad$} }& {\text { } } & {\text {X} } \\ {\text {X:$\quad$}} & {\text {.DATA$\quad$} }& {\text {0} } \\ {\text {Y:$\quad$}} & {\text {.DATA$\quad$} }& {\text {0} } \\ {\text {Z:$\quad$}} & {\text {.DATA$\quad$} }& {\text {0} } \\ {\text {TWO:$\quad$}} & {\text {.DATA$\quad$} }& {\text {2} } \\ \end{array}$

#### Work Step by Step

$\begin{array}{lll} {\text {$\quad$}} & {\text {LOAD$\quad$} }& {\text {Y} } & {\text {--Load the value of Y into register R} } \\ {\text {$\quad$}} & {\text {ADD$\quad$} }& {\text {Z} } & {\text {--R now holds the sum (Y + Z)} } \\ {\text {$\quad$}} & {\text {SUBTRACT$\quad$} }& {\text {TWO} } & {\text {--R now holds (Y + Z - 2)} } \\ {\text {$\quad$}} & {\text {STORE$\quad$} }& {\text {X} } & {\text {--Store the result in X} } \\ {\text {$\quad$}} & {\text {,$\quad$} }& {\text { } } & {\text {X} } \\ {\text {$\quad$}} & {\text {,$\quad$} }& {\text { } } & {\text {X} } \\ {\text {$\quad$}} & {\text {,$\quad$} }& {\text { } } & {\text {X} } \\ {\text {X:$\quad$}} & {\text {.DATA$\quad$} }& {\text {0} } \\ {\text {Y:$\quad$}} & {\text {.DATA$\quad$} }& {\text {0} } \\ {\text {Z:$\quad$}} & {\text {.DATA$\quad$} }& {\text {0} } \\ {\text {TWO:$\quad$}} & {\text {.DATA$\quad$} }& {\text {2} } \\ \end{array}$

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.