To convert the high-level language instructions to assembly language instructions, we need to follow the semantic operations indicated in each statement. Here's the continuation for each of the points you've provided:
- For the instruction
Input
, you want to load the value into memory location associated withz
, which isM[7]
. Assuming there is a command to read input, it would typically look like this:
Input M[7] ; Store the input value from the user into memory location M[7]
- The operation
x = y + z
should add the values stored inM[6]
(for y) andM[7]
(for z) and store the result inM[5]
(for x). The assembly operation for this would look like this:
Add M[6] ; Add the value of M[6] (y) to the accumulator
Add M[7] ; Add the value of M[7] (z) to the accumulator
Store M[5] ; Store the result in M[5] (x)
- For the operation
x = 2 * y
, you want to addy
to itself and store the result inx
. Sincey
is inM[6]
, it would look like this:
Add M[6] ; Add the value of M[6] (y) to the accumulator
Add M[6] ; Add the value of M[6] (y) again to the accumulator
Store M[5] ; Store the result in M[5] (x)
- For the instruction
x = y + y + y
, since you mentioned the commandAdd M[5] M[6] M[6]
has already been entered (which addsy
to itself once and stores it inx
), we should complete the remaining addition ofy
:
Add M[6] ; Add M[6] (y) to the result (which is currently in M[5])
Store M[5] ; Store the final result back in M[5] (x)
This series of instructions should adequately represent the intended operations in assembly language.