Computer
Science 161.01
Fall
2017
Homework
7 DUE Monday October 16th at 9:30AM
YOUR NAME:
____________________________________________________
1. (10 points) What follows is a VSC-32 assembly language
program. Recall that JUMP causes a jump
to occur to the specified labeled instruction only if the accumulator has 0 in
it. If there is something other than 0
in the accumulator, the JUMP does not take effect, and the program simply
follows the next instruction below it.
Without actually typing this program in to the web site, answer the
following:
a) What value will be written by the program if the number entered for X
by the
user is 7? ________
b) What value will be written by the program if the number entered for X
by the user is 0? ________
c) Assemble (that is, translate into binary) the first 4 instructions of
the program. Remember that each
instruction is 8 bits. Remember also
that the program gets loaded into memory beginning at address 0.
READ X
LOAD X
JUMP DONE
ADD THREE
STORE X
DONE:WRITE X
STOP
THREE: DATA 3
X:DATA 0
2. (9 points) The five VSC-32 instructions
LOAD X
ADD Y
ADD Z
SUBTRACT W
STORE X
can be replaced by one JavaScript assignment statement.
Write down the assignment statement: _________________________
3. (8 points) The JavaScript assignment statement Y = Z – W + Y would require four VSC-32 instructions. Write them in the space provided below.
4. (13 points) Get ready to decipher! This VSC-32 machine language program
writes
three different values to the
screen: 878827C8498900370F
What are those three values? (Do not use the software to find out)
5. (10 points) Without using the JavaScript scratchpad site, predict the values for
each of the following expressions:
7 + 10 * 5 __________________
29 % 7 __________________
100 – 30 % 5 __________________
(100 – 30) % 5 __________________
10 * 5 % 4 __________________
10 * (5 % 4) __________________
2 + 5 == 8 - 1 __________________
10 % 2 != 0 __________________
itsOctober = true;
itsOctober && (5 < 2) __________________
itsTuesday = false;
(10 % 2 == 1) || !itsTuesday __________________