Questions tagged [little-man-computer]

Little Man Computer (LMC) models an instructional Von Neumann computer architecture and uses assembly language.

Little Man Computer (LMC) models an instructional Von Neumann computer architecture and uses language. It is mostly used for educational purposes.

Questions about programming issues involving LMC should clarify which simulator the code should run on, as there are different interpretations on how a LMC should work with negative numbers and overflow.

There are several simulators available on the web, including those published by:

These take assembly code as input and run the program visualising the process.

For more info, see:

90 questions
1
vote
1 answer

How to detect in LMC that calculation is greater than 999 and then output 999?

I need to write an LMC program to solve a+bx+x2. Further, if the result is greater than 999, then it needs to output 999; if less than 999, then output the result. I have done the a+bx+x2 part, but have no idea how to output 999 when there is…
陈俊滔
  • 21
  • 1
1
vote
1 answer

Keeping a running total of numbers entered LMC

I am making a program that allows a user to input numbers indefinitely until they input '0'. Once they enter 0 the program should halt. However, I want to add each number entered to a running total and output the total everytime the user inputs a…
csPYTHONcs
  • 187
  • 1
  • 8
1
vote
1 answer

Output and Reset Lists in LMC

I am working at this coding challenge: Write a program for the Little Man Computer that allows the user to manage a list of values. It should start with an empty list and then process input as follows: If the input is: less than 100: add this…
julio11
  • 27
  • 8
1
vote
1 answer

Programming arrays in LMC

I am working on this challenge: The program needs to accept a sequence of integers. It ends with number 999. The integers (except 999) are placed in a list. The integers must be less than or equal to 99. Any inputs greater than 99 are not placed…
julio11
  • 27
  • 8
1
vote
1 answer

How to check if a number is odd or even in little man computer

I need help with making my program produce the correct output. I am currently working with this code: INP STA NUMBER SUB DIVISOR BRP VERIFY BRA CHECK LOOP STA NUMBER LDA RESULT ADD ONE …
user15082428
1
vote
1 answer

Convert n-bit binary to base 10 number

I am looking at this Little man computer problem: Write a Little Monkey Computer program that can convert an n-bit binary number into a number using the base-10 number system. Display the natural number as output before halting the program. The…
Tony
  • 13
  • 4
1
vote
1 answer

Little Man Computer Program to output 1 with delay of 5 seconds

Suppose a Little Man Computer program requires 1 microsecond to execute one instruction. I need to write a LMC program that takes an input between 0 and 10 (inclusive), and produces an output of one 1 but after a delay of that many seconds. For…
Anyonomiss
  • 25
  • 5
1
vote
1 answer

max/min of an unknown number of inputs in LMC?

How can I print the maximum/minimum of an unknown number of inputs in LMC? I know that I can SUB INPUT 1 FROM INPUT 2 and see if it is negative or positive but I don't know how to name the inputs so that I can load them. PS: I found this useful link…
User28
  • 25
  • 2
1
vote
1 answer

Print all digits of a given number in LMC

I need to print all digits of a given number in LMC. I tried with this code who gives me the last digit but I don't know how to keep going with the other digits. INP L0 STA R0 SUB R1 BRP L0 LDA R0 OUT HLT R0 DAT 000 R1 DAT…
User28
  • 25
  • 2
1
vote
1 answer

Want to use Labels to simplify Little Man Computer Program BubbleSort

This code is a Little Man Computer program that Bubblesorts and uses input, output, and sorts itself and then repeats. This is the program but I would like to use Labels for all constants, variables, and branch target locations where the branch…
user7806600
1
vote
1 answer

Output all the factors of the input

I'm trying to output every number that evenly divides the input (so there is no remainder). For example: if 60 is input, then the output should be: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 I have programmed code that outputs 10 in this example: 50 /…
user14512733
1
vote
1 answer

Show how many positive and negative numbers were input

I'm trying to write a Little Man Computer program that outputs how many positive numbers I have and how many negative numbers I have, but it considers the negative numbers as positive too. This is what I have so far: LOOP IN STO NUM BRZ…
1
vote
1 answer

Sieve of Eratosthenes little man computer

Could someone help me understand, why this work only when input<69 ? I'm working with simple assembly code for Little Man Computer INP STA INPUT LDA C OUT ADD ONE OUT LOOP LDA A \\ first loop ADD ONE STA A …
SVLK
  • 11
  • 2
1
vote
1 answer

How can I make loops in Little Man Computer for a Fibonacci Sequence?

INP STA numOne OUT INP STA numTwo OUT LDA numOne ADD numTwo STA numThree OUT LDA numTwo ADD numThree STA numFour OUT LDA…
D. Tunus
  • 271
  • 2
  • 16
1
vote
2 answers

How to write multiplication with the Little Man Computer?

I know that I need to do repeated addition, but I'm having trouble with the loops; I just do not understand them at all. Here is a program that multiplies a number by 2, without a loop. INP STA num1 LDA num1 ADD num1 STA num1 OUT HLT num1 DAT I…
ciarascuro
  • 21
  • 2
  • 6