• 100% Satisfaction Guarantee

Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 596
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
44076068
Ingo U is online now

# 1. Write a Little Man program to accept an indefinite number

### Customer Question

1. Write a Little Man program to accept an indefinite number of input values. The output value will be the largest of the input values. You should use the value 0 as a flag to indicate the end of input.

2. Now write a Little Man program that accepts three values as input and outputs them in order of size, largest to smallest. (Use the code I already have for this and just modify it for a swapping)

3. Finally write a Little Man program that prints out the sums of the odd values from 1 to 39. The output will consist of 1, 1+3, 1+3+5, 1+3+5+7 . . . . No input is required. As an aside, do you notice anything interesting about the output results that are produced by this series? (Hint: This series is sometimes used as part of an algorithm for finding square roots of numbers.)
Submitted: 1 year ago.
Category: Homework
Expert:  Ingo U replied 1 year ago.
Hi,
could you please post or upload the code provided by the instructor that was mentioned?
Also, I have sent an underpriced report, since this is really 3 questions. Please consider raising the amount.
Regards,
Ingo U
Customer: replied 1 year ago.

the code that I already have to input 3 numbers by a user and then output the largest (no infinite number or flag) is:

INP
STA FIRST
INP
STA SECOND
INP
STA THIRD
LDA FIRST
SUB SECOND
BRP FGS
LDA SECOND
BRA NEXT
FGS LDA FIRST
NEXT STA BIGGERONE
SUB THIRD
BRP TNG
LDA THIRD
BRA RESULT
TNG LDA BIGGERONE
RESULT OUT
HLT
FIRST DAT
SECOND DAT
THIRD DAT
BIGGERONE DAT

Expert:  Ingo U replied 1 year ago.
Which simulator are you using? There are several out there... I should make sure I have the same environment.
Customer: replied 1 year ago.

http://www.atkinson.yorku.ca/~sychen/research/LMC/LittleMan.html

And yes the code that I responded with should be the main heart of it. Thank you!

Customer: replied 1 year ago.

What time do you think you can have this done by? I have to make print screens of it and type up the document for it as well. Please let me know the approximate time you expect to have this done by. Thank you!

Expert:  Ingo U replied 1 year ago.
A couple of hours I'd say...
Customer: replied 1 year ago.

2 hours will be pushing it, but I understand. Please try and get it done as soon as you can - I greatly appreciate your business and will give you excellent feedback if done by an hour and a half :) Thanks again!

Customer: replied 1 year ago.

and a bonus

Expert:  Ingo U replied 1 year ago.
Do you have a document describing the instruction set of this LMC? It looks a little different from ones I've used.
Customer: replied 1 year ago.

whatever way you can get it to work is fine - like if you need to put the 901 and the 399 and all that stuff. totally doesn't matter to me as this is due in less than 2 hours

FIGURE 6.3

Little Man Mnemonic Instruction Codes with

Their Corresponding OP Codes

LDA

STO

SUB

IN

OUT

COB or HLT

BRZ

BRP

BR

DAT

5xx

3xx

1xx

2xx

901

902

000

7xx

8xx

6xx

Store

Subtract

Input

Output

Coffee break (or Halt)

Branch if zero

Branch if positive or zero

Branch unconditional

Data storage location

(the first ‘‘m’’ is silent). Once you learn to read these mnemonics, you’ll find that programs

written with mnemonics are generally easy to read. It is more common to write programs this

way. For a while, we will continue to print both the mnemonic and the code, but eventually,

we will stop printing the code. Most programs are also written with comments, which help

to clarify the code. The mnemonic instructions that we will use are shown in Figure 6.3.

The

DAT abbreviation is used to indicate that a particular mailbox will be used to store data.

The data may be specified in advance, for example, to use as a constant, or it may be zero if

the particular location is to be used to store the data later, during execution of the program.

The program, shown in Figure 6.4, works as follows: the first four instructions simply

input and store the two numbers. The fifth instruction, in mailbox 04, subtracts the first

FIGURE 6.4

LMC Program to Find Positive Difference of Two

Numbers

00

01

02

03

04

05

06

07

08

09

10

11

IN

STO

IN

STO

SUB

BRP

LDA

SUB

OUT

COB

DAT

DAT

901

310

901

311

210

808

510

211

902

000

000

000

test

negative; reverse order

print result and

stop.

used for data

10

11

10

08

10

11

00

00

Expert:  Ingo U replied 1 year ago.
Here are the first 2:

So you can start working on your end...
Customer: replied 1 year ago.

Thank you for letting me work on that while you finish the last 1. Do you know how to make it look more like the code I sent you? It is pretty similar, but if you could make the code I sent you look the same as yours that would be good.

I just want all the codes to look the same format

Sorry that I am new on this site and don't really know how this works. Thanks!

Expert:  Ingo U replied 1 year ago.
Here's the 3rd one:

The interesting thing about the output it it's all squares from 1*1 through 20*20

In what way does my code not look like yours? Formatting? I used tabs to be able to read it better. But as far as the actual code, of course I had to write different instructions and use different labels. The main thing is that it works, isn't it? Which I believe all 3 do...
Customer: replied 1 year ago.

can you tab the code I gave you so it matches the same formatting? and also - should there be a number in the mailbox number 36 on this program:

INP
STA FIRST
INP STA SECOND
INP
STA THIRD
TOP LDA FIRST
SUB SECOND
BRP SWAPFS
LDA SECOND
SUB THIRD
BRP SWAPST
BRA RESULT
SWAPFS LDA FIRST
STA TMP LDA SECOND
STA FIRST
LDA TMP
STA SECOND
BRA TOP
SWAPST LDA SECOND
STA TMP
LDA THIRD
STA SECOND
LDA TMP
STA THIRD
BRA TOP
RESULT LDA FIRST
OUT
LDA SECOND
OUT
LDA THIRD
OUT
HLT
FIRST DAT
SECOND DAT
THIRD DAT
TMP DAT

Expert:  Ingo U replied 1 year ago.
Are you saying you'd like me to format the code you gave me to match my tab format? No problem. As you can see above, pasting tabbed code (from notepad, for example) gets messed up on this website. But in the text file, in notepad, things should line up nice and neatly.
When I load the program above, P2.txt, mailbox 36 corresponds to the number THIRD.
What the program does is sort the values FIRST, SECOND and THIRD in ascending order. In order to swap any two of them, we also need a temporary variable, TMP, in mailbox 37. In the end it'll still have whatever the last value that needed to be stored temporarily for swapping.
Expert:  Ingo U replied 1 year ago.

Customer: replied 1 year ago.

excellent, the last thing is - could you explain the 3rd program to me a little more clear. I don't see the pattern from the lmc

Expert:  Ingo U replied 1 year ago.
You can view this answer by clicking here to Register or Login and paying \$3.

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

### What Customers are Saying:

• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Previous | Next >
• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
• This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
• Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
• I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
• Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
• Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
• He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX

• ### Manal Elkhoshkhany

#### Satisfied Customers:

4530
More than 5000 online tutoring sessions.
< Last | Next >

### Manal Elkhoshkhany

#### Satisfied Customers:

4530
More than 5000 online tutoring sessions.

### LogicPro

#### Satisfied Customers:

4395
Expert in Java C++ C C# VB Javascript Design SQL HTML

### Linda_us

#### Satisfied Customers:

3132
Post Graduate Diploma in Management (MBA)

### Chris M.

#### Satisfied Customers:

2486
Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

### F. Naz

#### Satisfied Customers:

2055
Experience with chartered accountancy

### Bizhelp

#### Satisfied Customers:

1884
Bachelors Degree and CPA with Accounting work experience