• Support PF! Buy your school textbooks, materials and every day products Here!

LMC Little man Computer Programing help?

  • Thread starter Freshman
  • Start date
  • #1
3
0
ok, i know this sounds simple but ive 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 im 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!!
 

Answers and Replies

  • #2
phinds
Science Advisor
Insights Author
Gold Member
2019 Award
15,754
5,387
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
3
0
oh ok, yea im 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
33,085
4,792
oh ok, yea im 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
3
0
ok, well im 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 im 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
33,085
4,792
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.
 

Related Threads for: LMC Little man Computer Programing help?

  • Last Post
Replies
10
Views
7K
Replies
2
Views
2K
Replies
8
Views
8K
  • Last Post
Replies
2
Views
1K
  • Last Post
Replies
4
Views
7K
Replies
4
Views
979
Replies
1
Views
6K
Replies
2
Views
987
Top