# Little Man Computer : Output Largest and Lowest of Three Numbers Entered



## bootwala (Mar 19, 2012)

Little Man Computer : Output Largest and Lowest of Three Numbers Entered

1) Write LMC program (similar to the two examples in the LMC Stuff folder) to perform the following:
a) Input three integers (from the input basket)
b) Compare the three integers and find the minimum and maximum values of the three.
c) Output two values (to the output basket), the minimum followed by the maximum of the three inputs

I've spent over 10+ Hours trying to learn how to get this to work.
I have things like this, but It's too much code and waste.. I need a simple solution to this, if anyone can calloborate or help with hints and what not, I am not asking you to do my home-work, but help me, because never seen a LMC example with proper difficult level of coding.

I have

```
0	IN
1	STO	10
2	IN
3	STO 	11
4	IN	
5	STO 	12
6	SUB	11 # Subtract 11 from 12. 12-11 = +1= C-B = +1, C is is Big
7	BRP	12 # GO FOR C IS BIG OVER B.
8	LDA	11	# else B IS BIG over C. load C. = 11 IS BIG OVER 12.
9	SUB 	10 # Subtract 10 from 11. B-A = +1, than C is big
10	BRP	bigB	# GO FOR B is bigger over A.
11	LDA	10	# else A IS BIG OVER B.
12	STO 	99
13	LDA 	99
14	OUT 	
15	LDA	11
16	SUB	12	#SUB 12 FROM 11. 11-12 = B-C= +1== B IS BIG....
17	LDA	12
18	STO	97	# C IS SMALLEST AND A IS BIGGEST
19	OUT
20	HLT
21
22	LDA	12	# C IS BIG,
23	SUB 	10 # Subtract 10 from 12. 12-10 = +2. Still 12 Big and A SMALL
24	BRP	big1210
25	LDA	12	# BIGGEST C
26	STO	99
27	OUT
28	LDA	10
29	STO	97
30	OUT		# SMALLEST A
31	HLT
32big1210		# Still 12 Big Over 10 and 11.
33	LDA	11
34	SUB	10	# 11-10 = +1 BRP. OR ABIG.
35	BRP	p1110	# GO FOR BIG B AND SMALL A
36	LDA	12	
37	STO	99
38	OUT
39	HLT
40p1110	# BIG B AND SMALL A
41	LDA	12
42	STO	99
43	OUT
44	LDA	10
45	STO	97
46	OUT
47	HLT
48bigC
49	LDA	12
50
51	STO	99
52	OUT		# BIGGEST C
53	LDA	11
54	STO	97
55	OUT		# SMALLEST B
56	HLT
57bigB
58 	LDA	11
59	STO	99
60	OUT		# BIGGEST B.. WHILE SMALLER C
61	LDA	10
62	SUB	12	# SUBTRACT 12 FROM 10. 10-12 = -1 A-C = +A
63	LDA	12
67	OUT		# SMALLEST C.
68	HLT
```
I;ve attached LMC program too


----------

