Download presentation
Presentation is loading. Please wait.
Published byΦιλομήλα Αυγερινός Modified over 5 years ago
1
Learning how to use the Little man computer
The following program will demonstrate the input and output instructions of the LMC. The first instruction will copy a three-digit number from the In Box to the accumulator, and the second instruction will copy the value of the accumulator to the Out Box. Program INP OUT HLT
2
Learning how to use the Little man computer
The following program will demonstrate the load and save instructions of the LMC. Program INP STA FIRST INP STA SECOND LDA FIRST OUT LDA SECOND OUT HLT FIRST DAT SECOND DAT
3
Learning how to use the Little man computer
The following program will demonstrate the add and subtract instructions of the LMC. Note: The Accumulator (calculator) in the LMC is only designed to work with non-negative three-digit numbers. Mathematical operations which produce values greater than 999 or less than 000 can cause undefined effects to occur. Program INP STA FIRST INP ADD FIRST OUT INP SUB FIRST OUT HLT FIRST DAT
4
LMC Branch Instructions (for making decisions)
The following program will demonstrate how to use the branching instructions of the LMC to implement decision making. Note: The Branch Always instruction should only be used to connect paths indicated by your flowchart. Flowchart The following is the flowchart for a program that will output the largest of two input values. Note: if the values are equal, both numbers represent the largest value, so either can be output.
6
LMC Branch Instructions (for making decisions)
Program INP STA FIRST INP STA SECOND SUB FIRST BRP SECONDBIG LDA FIRST OUT BRA PROGRAMEND SECONDBIG LDA SECOND OUT PROGRAMEND HLT FIRST DAT SECOND DAT
7
LMC Branch Instructions (for implementing loops)
The following program will demonstrate how to use the branching instructions of the LMC to implement looping. Note: The Branch Always instruction should only be used to connect paths indicated by your flowchart. Flowchart The following is the flowchart for a program that will output the values from 1 to 10.
9
LMC Branch Instructions (for implementing loops)
Program LDA ONE STA COUNT OUT LOOPTOP LDA COUNT ADD ONE OUT STA COUNT SUB TEN BRP ENDLOOP BRA LOOPTOP ENDLOOP HLT ONE DAT 001 TEN DAT 010 COUNT DAT
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.