IFN551ComputerSystemsFundamentals Assignment
PREAMBLE
LMCisacartoonisedassemblylanguagethatmimicstheinstructionsetofmanyreal-worldarchitectures,includingx86,ARMandothers.ThesearemodelledonthevonNeumanncomputersystemarchitecture,asproposedbyJohnvonNeumannin1945.InlearningLMC,youwillgainanunderstandingofhowthesoftware system of a computer operates at a fundamental level. See the lectures and tutorials for moreinformation aboutthearchitectureand instructionsof LMC.
In this assignment, there are two questions; both are separated into sub-questions. Be sure to answerall questions.For each, amarkingschemeisprovided.
First,youarerequiredtodemonstrateyourabilitytointerpretandsolveanovelproblem.Youwilldesignasolutiontotheproblembyusingnaturallanguagetoexplainyourapproach,andplanhowyouwilltestthe implementation of this design. After designing your solution and test plan, you are required toimplementthe designusing the LMCintegrated developmentenvironment (IDE).
Second,withsomeprovidedcode,youwilldescribeitsfunctionandtidyit,toimprovereadability.
AcademicintegrityistakenveryseriouslyatQUT.Ensurethattheworkyousubmitisyourownandthatyou provide sufficient evidence of how you came to your final solution. If we have queries about yoursolution, you must be prepared to answer these when requested otherwise a grade of zero will beawarded.
Youmustmakeappropriatereferencetotheauthor(s)ofworksorideasthatyousubmitandarenotyourown. Do not directly copy, summarise, or claim to own any material that is not rightfully yours. Thisincludes any works or ideas generated by artificial intelligence (AI). The use of AI in this assignment isdiscouraged and may hinder your ability to complete this assignment to our specifications. Any materialsubmittedinthisassignmentwillbethesubjecttointelligentalgorithmsthatdetectplagiarismandprovidea measureofauthenticityof your work.
YoumustadheretotheQUTManualofPoliciesandProcedures,andagreetothetermsbelow.Youcanaccess theQUT MOPPbysearchingMOPPintheHiQwebsite.
QUESTION1(35MARKS)
Select the task according to the last digit of your student ID:
9, 8, 7 Task1-A
6, 5, 4 Task 1-B
3,2, 1,0 Task 1-C
For example: if your student ID is n98765435then you will do Task B.Selecting the incorrect task will result in a grade of zero for this question.See thefollowingpages for theTasks.
- UseLMCIDE5.0.0 (orgreater)
- EnteryourstudentIDinthe LMCIDEwhencompleting thisquestion
- Failingtoincludethe.lmcfileinyoursubmissionwillresultinagradeofzerofor3
- SufficientLMCfilehistorymustbeavailabletodemonstrate
Task 1-A
Write a LMC program that converts an Unreal number into a decimal number. The Unreal number system is like theRoman number system; however, it has some exceptions and limitations. You must display the result as output beforehalting theprogram.
Forexample,theUnrealnumberCXIis 111, andXXXVIis36.
Unrealdigit |
Naturalnumber |
I |
1 |
V |
5 |
X |
10 |
L |
50 |
C |
100 |
D |
500 |
YourprogramonlyneedstosupporttheUnrealdigitslistedinthetableabove.
Your program will only be able to calculate a natural number up to and including 999.Iftheuserentersan Unrealnumeralwhich exceeds this,theoutputistobe 999.
Six (6) input values are provided by the user, the order of input is important:ThefirstinputisthenumberofDs thattheUnrealnumbercontains.
The second input is the number of Cs that the Unreal number contains.Thelastinputis the numberofIs thatthe Unrealnumbercontains.
Forexample,iftheuserprovidestheinputs0,0,0,1,2,2thenthiswillbetheequivalentofXVVII
Task 1-B
Write a LMC program that can convert an n-bit binary number into a decimal number. Display the natural number asoutputbeforehaltingtheprogram.
The first input determines the value for n. It is assumed this value will be equal to four, or greater.Forexample,ifthe firstinputiseight(8)theneightsubsequentinputsare requested.
Ifthesubsequentinputsnumberwere1, 0,0, 1,0, 0, 0,0thentheoutput wouldbe9.
n input values are provided by the user, one for each bit:The firstoftheseistheleast-significant bit.
Thenthinputisthemost-significantbit.
Task1-C:
Write a LMC program that calculates the sum of numbers provided by the user. Display the summation as output beforehalting theprogram.
Iftheuserhasprovidedlessthanorequaltoteninputvalues,thenonlysumeven numbers.Oddnumbersareignored.
If the user has provided more than ten values, then only sum any odd numbers subsequent to the tenth input. The existingsummationof evennumbersshallremain.
If the user enters zero, at any point, then the summation is displayed.Forexample:
Inputvalues:3,3,4, 0 Result:4
Inputvalues:2,3,7, 0 Result:2
Inputvalues: 1,2,3, 4,5,6,7,8,9,8, 7,6, 5, 4,3, 0 Result:43
Question1.1 (10marks)
Describeyourapproachtosolvingtheproblem.
- Use natural language, structured like a conventional programming language tocommunicateyour
- Whennecessary,useloopingandconditional
- Namesymbolssensiblytomake theiruse
Cormen (2009) wrote an excellent introduction to the conventions of pseudocode (see Part I, chapter 2, section 1.2). Youcan readthisbysearchingforthetextviaQUTLibrary.
Cormen, Thomas H. Leiserson, Charles E. Rivest, Ronald L. Stein Clifford. (2009). Introduction to Algorithms (3rdEdition)- 2.1.2PseudocodeConventions.MITPress.
Question1.2 (10marks)
Drafta testplan tobe usedasa verificationmethod to ensure thatyourLMCprogramiscorrect.
- Tabularisetestinputvalue(s)andtheexpectedoutput(s)
- Consider uncommon cases. For example, when the calculator reaches itsmaximum value, when negative values are calculated, or when an input isunexpectedly large.
Draftyourtestplanusingthefollowingtemplate(twoexamplesareprovided):
Comma-separate the input and output values.Deletetheexamples.
InputValue(s) |
Expectedoutputvalue(s) |
Notes |
2,4,6 |
10 |
Allevennumbers |
1,3,5 |
9 |
All oddnumbers |
Question1.3 (15marks)
ImplementanLMCprogramaccordingtothealgorithmyoudesignedinQ1.1.
Usethetestsuiteyoudesigned inQ1.2toverifytheimplementationofyouralgorithmiscorrect.
- Onlysymbolicaddressingistobeused;numericaladdressingwillbe
- LMCprogrammustrequestthecorrectnumberofinput(s).
- LMCprogram mustproducethecorrectnumberofoutput(s).
- LMCprogram mustproducethecorrectoutputvalue(s)forallgiven test
- Code must be tidy (spacing, indentation) and comments are to be used to describethe algorithm.Donotdescribethe functionof eachLMC
- YourLMCfileshouldshowthefullhistoryofhowyoursolution was
Note: A mark of zero will be given for those test cases where the HLT command is not executed. This may be due to itbeingmissingor,syntaxor run-timeerrors. Errors willnot befixed bythemarker.
QUESTION2(15MARKS)
Below is a LMC program, however, its intended use has been forgotten. Unfortunately, the developer has not indented orcommented theircode,soreadabilityislow.
- UseLMCIDE5.0.0 (orgreater)
- EnteryourstudentIDinthe LMCIDEwhencompleting thisquestion
- Failingtoincludethe.lmcfileinyoursubmissionwillresultinagradeofzerofor2
- SufficientLMCfilehistorymustbeavailabletodemonstrate
INSTO aINSTO bLDA aADD bSTOc
loop: LDA bSUBc
BRP doneLDAcSUBbSTOcOUT
LDA tADD cSTOt
BRloop
done: LDA tOUT
HLT
c:DAT000
a:DAT000
b:DAT000
h:DAT100
t:DAT000
Question2.1 (5 marks)
Describethe functionofthecode.
Question2.2 (10marks)
Tidythecode toimproveits readability.Bemindfultonotbreakit.Implementatestsuite.