# Little Man Computer

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Hi, i need a LMC program written that outputs the smallest of three numbers?

Thanks.

#### Ent

Josiah
I'm sorry, but we don't generally do people's homework for them. If you can show that you're working on some code but have a specific problem, you might get some help but still have to do the work yourself. Otherwise how would you learn?

#### sepala

Ent is correct. What you are asking is a simple thing, a simple math. That's all. Apart from that, some Programming languages has methods to do this for you too..

This is what ive done so far:

My flowchart is summat like this:

Input A, B, C ---> is A<B ----> If yes, ----> is A<C -------> if Yes, output A, if no output C
Input A, B, C ----> is A<B ----> If No -----> is B<C -------> If yes, output B, if no output C

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
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
24 902 Output
25 000 HALT
97 000 DATA
98 000 DATA
99 000 DATA

I think its ok but not sure

#### Ent

Josiah
So what goes wrong when you try to run this?

I havent tried running this. I just wanted to know whether it was correct, as i am new to this and this is only a sample question. Its not the actual exam question.

#### Ent

Josiah
In that case I suggest you just run it and see what it makes of a few combinations of values. LMC is designed to give you a run through of what your computer is doing, it can explain things much better than we can.

Remember when testing to give it values that it should find easy and values that might confuse it (e.g. how does it handle the two numbers being equal?)

Karen
Malware Specialist Coordinator
I'll close this now since we don't assist with homework.

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

As Seen On