======================================================
Assignment #06 - Little Man Computer Basics
======================================================
- Ian! D. Allen - idallen@idallen.ca - www.idallen.com
Available online: Friday October 29, 2010
Upload due date in the Blackboard Assignment Area:
Upload "assignment06.txt" before 19:00 (7pm) on Wednesday November 3, 2010
Answers will be posted shortly after the due date/time and discussed
in class, if there are any questions about the answers.
Submission method: Upload via the "Assignments" assignment06 upload.
Use the file name given above. Upload only one single file of plain text,
not HTML, not MSWord. No fonts, no word-processing. Plain text only.
Did I mention that the format is plain text (e.g. using Notepad)?
Answers will be posted after the due date/time so that you can check
your answers before coming to class and ask questions about the answers
in class. Please check your answers (and my answers!). I go over
each assignment in class if there are questions about the answers.
No questions means no review - I'll presume you know the material.
Questions similar to ones on these assignments will appear on your tests
and exams.
Not all assignments will be marked. See the Week 1 Notes for details.
==============================================================================
Edit this file and answer the following questions, showing the method
or formula you used to get the answer, if appropriate.
Upload the file containing the methods, formulas, questions and answers
before the due date. Some of the answers below will require reading
the links published in the weekly course notes.
==============================================================================
0. What is the date of your second Midterm Test?
1. List the Instruction Cycle activities for the Little Man Computer (LMC).
2. With reference to the full extended LMC opcode table (LMC_opcodes.html),
which LMC instruction(s) would not work "properly" if the LM incremented
the counter *after* performing the instruction instead of before?
3. What is the purpose of the LMC mnemonic pseudo-instruction DAT?
4. Which LMC instructions set the values of the three LMC light flags?
5. What is the only way that the N (negative) flag can come on?
Give an example.
6. Can the N flag and P (positive) flag ever both be on at the same time?
Give an example.
7. Can the N flag and Z (zero) flag ever both be on at the same time?
Give an example.
8. a) What value appears in the Calculator if you start with 999 and
then add one?
9. b) What are the on/off states of the three lights N,Z,P afterward?
10. a) What value appears in the Calculator if you start with zero and
then subtract one?
11. b) What are the on/off states of the three lights N,Z,P afterward?
For each of the following nine actions, give the final value in the
Calculator and indicate the on/off state of the three indicator
lights N, Z, and P. Assume that no lights are on to begin with.
12. a) Input 400 into Calculator. ANSWER:
13. b) 600 is subtracted. ANSWER:
14. c) 600 is subtracted again. ANSWER:
15. d) 600 is subtracted again. ANSWER:
16. e) 600 is subtracted again. ANSWER:
17. f) 600 is subtracted again. ANSWER:
18. g) 600 is added. ANSWER:
19. h) 600 is added again. ANSWER:
20. i) 600 is added again. ANSWER:
21. a) List all the outputs that would be generated if the following numeric
code were entered into the LMC mailboxes starting at mailbox 00, and
then the LM was awakened. (You should translate this numeric program
into more readable LMC mnemonics and labels before tracing it!)
Mailbox values - read across each line left to right in memory dump format:
117 216 118 416 800 911 116 418 216 600
902 116 418 418 600 700 600 010 002 000
22. b) What is the final value left in memory location 16 at program end?
c) Optional: After tracing the above program by hand, enter it into
the LMC simulator and verify your answer.
23. a) Translate the following LMC mnemonic code ("assembly language") into
LMC numeric code ("machine language") starting in mailbox 00.
Use the five-column listing format described in the notes:
LDA ZERO
STO SUM
LDA ONE
STO COUNT
WHILE LDA FIFTY
SUB COUNT
SKP
JMP ENDWH
LDA SUM
ADD COUNT
STO SUM
LDA COUNT
ADD TWO
STO COUNT
JMP WHILE
ENDWH LDA SUM
OUT
HLT
SUM DAT 600
COUNT DAT 700
ZERO DAT 000
ONE DAT 001
TWO DAT 002
FIFTY DAT 050
24. b) Show the "Label Table" for the above program, linking labels with
mailbox addresses.
25. c) Re-code the above program into a Java or C++ program or pseudocode
that performs, as closely as possible, the same operations in the
same order. Do not optimize your program or re-order the
statements. Do a direct translation.
26. d) In simple English, what does the above program do?
--
| Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada
| Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/