Thread: stuck on Little man computer help please!

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    2

    stuck on Little man computer help please!

    trying to write a program for school. the program is supposed to do the following:


    Write a program that takes an input value (for example, a number 5). The output should be sum of all numbers from 1 to the value input by the user (in this example, the output would be 1+2+3+4+5 i.e. 15)


    what I dont get is how if say I enter 20 how to get it to know that I entered 20 and just add all the numbers from 1 to 20 like count. would I use the SUB (subtract) command to aid in this? help-I'm stuck!!


    INP
    STA NUM1
    LDA NUM1
    INP
    STA NUM2
    LDA NUM2
    ADD NUM2
    OUT
    HLT

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    This is a question on assembly language, not 'C'.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    2
    sorry, I did think of that but then I saw another thread about lmc so I thought I'd try. do you know any good forums that help with this, or any good irc channels? thanks

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    What microprocessor is it for?
    Fact - Beethoven wrote his first symphony in C

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by Click_here View Post
    What microprocessor is it for?
    Don't think it's a real microprocessor (though a hardware implementation may exist somewhere), probably just a hypothetical one: Little man computer - Wikipedia, the free encyclopedia.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by cduval04 View Post
    what I dont get is how if say I enter 20 how to get it to know that I entered 20 and just add all the numbers from 1 to 20 like count. would I use the SUB (subtract) command to aid in this? help-I'm stuck!!
    Yes, subtraction is a good way to approach this. Could you write such a program using subtraction in a higher level language, like C, C++, Java, etc? If so, then you understand the concept. Try writing this in one of those languages, then translate the higher level code into little man assembly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stuck and need help.
    By tvred in forum C++ Programming
    Replies: 4
    Last Post: 03-23-2010, 11:34 AM
  2. Computer Science vs Computer Engineering degree
    By PCG33K in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-03-2007, 07:13 AM
  3. HELP! New To C++ and stuck
    By flatline911 in forum C++ Programming
    Replies: 5
    Last Post: 07-01-2003, 09:45 AM
  4. Replies: 23
    Last Post: 01-31-2003, 03:13 AM
  5. computer science or computer engineering??
    By pkananen in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 02-26-2002, 12:10 PM

Tags for this Thread