How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ingo U Your Own Question

Ingo U
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 476
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Type Your Homework Question Here...
Ingo U is online now
A new question is answered every 9 seconds

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: 9 months ago.
Category: Homework
Expert:  Ingo U replied 9 months 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 9 months 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 9 months ago.
Which simulator are you using? There are several out there... I should make sure I have the same environment.
Customer: replied 9 months 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 9 months 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 9 months ago.
A couple of hours I'd say...
Customer: replied 9 months 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 9 months ago.


and a bonus

Expert:  Ingo U replied 9 months 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 9 months 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


ADD


SUB


IN


OUT


COB or HLT


BRZ


BRP


BR


DAT


5xx


3xx


1xx


2xx


901


902


000


7xx


8xx


6xx


Load


Store


Add


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 9 months ago.
Here are the first 2:

http://wikisend.com/download/236638/P1.txt
http://wikisend.com/download/180820/P2.txt

So you can start working on your end...
Customer: replied 9 months 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 9 months ago.
Here's the 3rd one:

http://wikisend.com/download/727732/P3.txt

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 9 months 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 9 months 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 9 months ago.
Here's your code with tabs:

http://wikisend.com/download/116594/SuppliedCodeWithTabs.txt
Customer: replied 9 months 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


 


http://wikisend.com/download/727732/P3.txt

Expert:  Ingo U replied 9 months ago.
THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.

JustAnswer in the News:

 
 
 
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.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...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
< Last | 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
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience