LMC Little man Computer Programing help?

  • Thread starter Freshman
  • Start date
  • Tags
    Computer
In summary, the conversation was about a person being stuck on a programming problem in the Little Man Computer program. They needed help with obtaining three numbers, determining the smallest of the three, and outputting it. They had attempted to solve the problem but were not successful and were looking for guidance. The expert suggested an algorithm that involved comparing the three numbers and storing the smallest one in a memory location.
  • #1
Freshman
3
0
ok, i know this sounds simple but I've been stuck for the past 3 days trying to figure this out can someone please help me with this i need to do the following,

1) Obtain 3 numbers
2) Determine which number is the smallest of the 3 numbers
3)Out put the smalles number and then halt.

this is what I am trying to figure out in the Little man computer program anyone know the code to complete this and if you can kindly explain to me how you came up with that code that would be a life saver! thanks so much!
 
Physics news on Phys.org
  • #2
you need to show some attempt yourself so we'll have some idea of your level of knowledge and where you are stuck.

Asking people here to just spoon-feed you a total answer is not how this forum works.
 
  • #3
oh ok, yea I am new to this fourm but this is what i have so far and its not really working

MB Op-Code Description
00 901 Input A
01 397 Store A in MB 97
02 901 Input B
03 398 Store B in MB 98
04 297 Subtract A from B
05 808 If positive, go to MB 08
06 598 Load MB 98 (B)
07 616 Send to MB 16
08 597 Load MB 97 (A)
09 901 Input C
10 399 Store C in MB 99
11 297 Subtract A from C
12 821 If positive, go to MB 21
13 599 Load MB 99
14 902 Output MB 99 (C)
15 000 HALT
16 901 Input the data received from MB 07 (B)
17 398 Store B in MB 98
18 299 Subtract B from C
19 821 If positive, go to MB 21
20 599 Load MB 99 (C)
21 902 Output
22 000 HALT
23 598 Load MB 98
24 902 Output
25 000 HALT
97 000 DATA
98 000 DATA
99 000 DATA
 
  • #4
Freshman said:
oh ok, yea I am new to this fourm but this is what i have so far and its not really working

MB Op-Code Description
00 901 Input A
01 397 Store A in MB 97
02 901 Input B
03 398 Store B in MB 98
04 297 Subtract A from B
05 808 If positive, go to MB 08
06 598 Load MB 98 (B)
07 616 Send to MB 16
08 597 Load MB 97 (A)
09 901 Input C
10 399 Store C in MB 99
11 297 Subtract A from C
12 821 If positive, go to MB 21
13 599 Load MB 99
14 902 Output MB 99 (C)
15 000 HALT
16 901 Input the data received from MB 07 (B)
17 398 Store B in MB 98
18 299 Subtract B from C
19 821 If positive, go to MB 21
20 599 Load MB 99 (C)
21 902 Output
22 000 HALT
23 598 Load MB 98
24 902 Output
25 000 HALT
97 000 DATA
98 000 DATA
99 000 DATA

What does "not really working" mean? Please provide more detailed information - what works, what doesn't work, and so on.
 
  • #5
ok, well I am able to get the three numbers, and i subtract the first two and get an output, i was having my professor try and explain it to me, but it seems like he didn't even know what he was doing, so I am stuck at figuring out a code or method that will determine the smallest of the three numbers any suggestion on determining that would be a great benefit to myself.
 
  • #6
Here is one possible algorithm.
Code:
Input A and store it.
Input B and store it.
Input C and store it.

Compare A and B (by subtraction)
If A <= B 
{  
   compare A and C
   If A <= C
   {
      Store A (A is the smallest)
   }
   Else 
   {
      Store C (C is the smallest)
   }
Else 
{
   compare B and C
   If B <= C 
   {
      Store B (B is the smallest}
   }
   Else Store C (C is the smallest)
}
By "store X" I mean copy the value to some memory location that will hold the smallest value, similar to what you're doing for A, B, and C.

Hope that helps.
 

1. What is LMC Little man Computer programming?

LMC Little man Computer programming is a simple educational programming language used to teach the basics of computer programming. It is based on the concept of a "little man" that follows instructions to solve problems and perform mathematical calculations.

2. How does LMC Little man Computer programming work?

LMC Little man Computer programming works by using a set of instructions, called a "program", to tell the little man what to do. The program is written using a simple instruction set that includes basic arithmetic and memory operations.

3. Is LMC Little man Computer programming suitable for beginners?

Yes, LMC Little man Computer programming is designed to be simple and easy to understand, making it a great language for beginners to learn the basics of programming. It is also a great way to introduce concepts like memory management and control flow.

4. What are the benefits of learning LMC Little man Computer programming?

Learning LMC Little man Computer programming can help develop critical thinking skills and problem-solving abilities. It also introduces fundamental concepts of computer programming, which can be applied to other programming languages.

5. Where can I find resources to learn LMC Little man Computer programming?

There are many online resources available to learn LMC Little man Computer programming, including tutorials, videos, and interactive exercises. You can also find textbooks and other educational materials at your local library or bookstore.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Programming and Computer Science
Replies
11
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
9
Views
559
  • Computing and Technology
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
2K
Replies
4
Views
777
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
5K
Back
Top