lmc controlled

24
Little Man Computer Teacher Guidance Task 1, 2, 3

Upload: raybeards

Post on 03-Oct-2015

232 views

Category:

Documents


2 download

DESCRIPTION

Help for the OCR Controlled assessment

TRANSCRIPT

Unit 4 AO1 - website

Little Man ComputerTeacher GuidanceTask 1, 2, 318/03/20152The first programINPSTA DECINPLOOP SUB DECOUTBRZ QUITBRA LOOPQUIT HLTDEC DAT000102030405060708LMC will store these instructions in the first eight memory locations.18/03/20153The first programINPSTA DECINPLOOP SUB DECOUTBRZ QUITBRA LOOPQUIT HLTDEC DAT000102030405060708These are all LMC instructions and appear on the list of instructions on page 3 on your controlled assessment instructions.18/03/20154The first programINPSTA DECINPLOOP SUB DECOUTBRZ QUITBRA LOOPQUIT HLTDEC DAT000102030405060708These are labels.When you compile the program, LMC assigns each label to a memory location.LOOP = 03QUIT = 07DEC = 0818/03/20155Compile the programLittle Man Computer Memory:InpOutAccLOOPQUITDEC0123456789901308901208902707603000The compiler sets up these values18/03/20156Compile the programLittle Man Computer Memory:InpOutAccLOOPQUITDEC0123456789901308901208902707603000INPINPOUTHLTThese mnemonics are straightforward, look at page 318/03/20157Compile the programLittle Man Computer Memory:InpOutAccLOOPQUITDEC0123456789901308901208902707603000INPSTADECINPOUTHLTThe mnemonic LDA has two parts:3 means Store08 is the operand, in this case it means memory location 0818/03/20158Compile the programLittle Man Computer Memory:InpOutAccLOOPQUITDEC0123456789901308901208902707603000INPSTADECINPSUB DECOUTHLTThe mnemonic SUB has two parts:2 means Subtract08 is the operand, in this case it means memory location 0818/03/20159Compile the programLittle Man Computer Memory:InpOutAccLOOPQUITDEC0123456789901308901208902707603000INPSTADECINPSUB DECOUTBRZQUITHLTThe mnemonic BRZ has two parts:7 means Branch if zero07 is the operand, in this case it means memory location 0718/03/201510Compile the programLittle Man Computer Memory:InpOutAccLOOPQUITDEC0123456789901308901208902707603000INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThe mnemonic BRA has two parts:6 means Branch always03 is the operand, in this case it means memory location 0318/03/201511Running the programLittle Man Computer Memory:InpOutAccLOOPQUITDEC0123456789901308901208902707603000INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTRun the program and use the values in example (i)Use Step to run the program one step at a time.18/03/201512Running the programLittle Man Computer Memory:Inp2OutAcc2LOOPQUITDEC0123456789901308901208902707603000INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will ask for the first number.The number is stored in the accumulator.Pressing Step will move to the next instruction.18/03/201513Running the programLittle Man Computer Memory:Inp2OutAcc2LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will store the number from the accumulator into memory 08.18/03/201514Running the programLittle Man Computer Memory:Inp2OutAcc2LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will ask for another number.Enter 1018/03/201515Running the programLittle Man Computer Memory:Inp10OutAcc10LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will ask for another number.Enter 1010 will be stored in the accumulator.18/03/201516Running the programLittle Man Computer Memory:Inp10OutAcc8LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will subtract the value in memory location 8 from the accumulator (10-2).The answer will be stored in the accumulator.18/03/201517Running the programLittle Man Computer Memory:Inp10Out8Acc8LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will display the value that is in the accumulator.It will be displayed in the outbox18/03/201518Running the programLittle Man Computer Memory:Inp10Out8Acc8LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will branch to location 7, but only if the accumulator is equal to zero.It isn't, so the program continues without branching.18/03/201519Running the programLittle Man Computer Memory:Inp10Out8Acc8LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will branch to location 318/03/201520Running the programLittle Man Computer Memory:Inp10Out8Acc6LOOPQUITDEC0123456789901308901208902707603020INPSTADECINPSUB DECOUTBRZQUITBRALOOPHLTThis will subtract the value in memory location 8 from the accumulator (8-2).The answer will be stored in the accumulator.The program will continue until the accumulator equals exactly zero.Step through the program, watching how the accumulator and outbox change.After looping five times, the accumulator will equal zero and the program will stop.18/03/201521Watch and learn18/03/201522FlowchartStartInputSubtract value in 08 from accumulatorInputStore in 08Display