Professional Documents
Culture Documents
Assignment 3
Assignment 3
Assignment 3
This assignment is again separated into two parts. Part [A] is intended to give
you practice at working with the Little Man instruction set and with the LMC
VVM simulator. Each of the exercises in part [A] emphasizes a different aspect
of machine language programming, so you will want to do them all. You are
strongly encouraged to work directly with your CS240 partner on the part
[A] problems. The problems are graduated to help you ease your way into
Bloom Level 3.
In each case you should determine the algorithm first, then write the
code, then test it using the VVM simulator. (Definitely not the other
way around!)
Part [A]
599
902
199
902
398
198
902
397
197
902
396
196
902
395
195
902
394
194
902
393
193
902
392
192
902
391
191
902
390
000
*99
001
If you prefer, you can write a program that outputs the Fibonacci
series instead. The Fibonacci series starts with 0, 1. Each output
value after that is the sum of the previous two. [0, 1, 1, 2, 3, 5, 8,
13, ...]
4. Write a program that takes in a series of input numbers and
outputs the sum of all the previous numbers, including the current
one, each time there is a new entry. Your program will stop when the
user inputs a zero. (There is no limit to the number of values that
the user will input.) Example: Input is 2, 3, 5, 1, 8, 0. Output is 2, 5,
10, 11, 19.
901
399
901
199
398
901
198
397
901
6. This ones a challenge problem, but if you and your partner can
figure it out, you are well on your way to being a professional: Write
a program that accepts two input values and outputs the product
(multiplication) of the two. Hint: use one of the values as an index to
count the number of times that you add the other value to itself.
Part [B]
You are to solve this problem completely on your own, with no help
from anyone except the instructor!
INP//INPUTA
STO99//STOREAIN99
INP//INPUTB
STO98//STOREBIN98
LDA99//.LOADAINTOCALC
SUB98//SUBTRACTBFROMA
BRZ
INP//INPUTA
STO18//STOREAIN18
STO17//STORE1IN17
INP//INPUTB
STO19//STOREBIN19
LDA18
SUB19
BRZ90
BRP06
STO16
LDA18
SUB16
OUT
BR15
ADD17
STO20
OUT
HLT
*90
OUT
BR00
HLT