LMC Little man Computer Programing help?

  • Thread starter Freshman
  • Start date
  • #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!
 

Answers and Replies

  • #2
phinds
Science Advisor
Insights Author
Gold Member
2022 Award
18,148
10,978
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
Freshman
3
0
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
36,708
8,704
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
Freshman
3
0
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
36,708
8,704
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.
 

Suggested for: LMC Little man Computer Programing help?

Replies
18
Views
2K
  • Last Post
Replies
1
Views
588
  • Last Post
Replies
15
Views
499
  • Last Post
Replies
3
Views
457
  • Last Post
Replies
3
Views
653
  • Last Post
Replies
2
Views
638
  • Last Post
Replies
1
Views
800
  • Last Post
Replies
3
Views
863
Replies
2
Views
407
Replies
20
Views
1K
Top