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
3 answers

LMC - How to increment an address?

I am inputting several variables. I want to know how to increment the address each time, so each of the inputs are saved in a different address. I tried to ADD 1 everytime but it can only be for specific inputs, not for addresses.
1
vote
1 answer

LMC program to find the difference between double the median and the smallest of 3 inputs?

I want to write an LMC program to find the difference between twice the median and the smallest of 3 distinct inputs efficiently. I would like some help in figuring out an algorithm for this. Here is what I have so far: INPUT 901 - Input first STO …
1
vote
1 answer

LMC - Checking if a^2 + b^2 = c^2 in Little Man Computer Assembly efficiently

My program needs to accept 3 inputs and then check if they form a Pythagorean triple. I'm using the Little Man Computer to do this, and therefore I am using LMC assembly. If you want more info on the commands that can be used, or to download the…
JC2188
  • 337
  • 3
  • 17
1
vote
1 answer

Sorting least to greatest of three numbers

I am currently learning assembly language. I have been able to create a quick short function to swap two numbers from least to greatest. I am applying the same basic foundation to do this with three numbers but every time I am performing a…
user1261800
1
vote
2 answers

Operator Overloading and array handling in C++

I am writing a Little Man computer simulation and i want to overload the Indexing operator []. I have create a class called LMC and have done the following: #include using namespace std; class LMC { public: LMC(); void…
0
votes
3 answers

LMC - Not going into negative (little man computer)

Just working with Little Man Computer here and have ran into a problem that is kind of bugging me. Since there is no if's etc, I'm finding it hard to stop odd numbers going into negatives numbers when being subtracted from an even number. For…
Deany
  • 43
  • 2
  • 11
0
votes
0 answers

Indirect addressing LMC

I would like to know how do I get access to the data contained at a specific address given that the address has been stored as a data at another address in a variable (sort of indirect addressing) in little man computer (lmc)? I was thinking of…
0
votes
0 answers

In LMC,How create a table by self-modify it's size?

Actually i dont know how to put a data into a tab by different addresses in a tab ,like TAB[1]=1,TAB[2]=2,TAB[3]=3. there is my code in LMC, i have tried many times and check many LMC exemples in Stackoverflow ,but i'm still so confused hwo to…
Dereck
  • 1
  • 3
0
votes
2 answers

Change a program to output two numbers in Ascending order instead of descending

This is descending. How would I swap to ascending so that when LMC outputs the numbers it shows in ascending order. INP STA A INP STA B LDA A SUB B BRP BTOS BRA BTOS2 BTOS LDA A …
0
votes
1 answer

Confusion with Little Man Computer; simple division program

INP STA A INP STA B LDA 99 STA C loop LDA A SUB B STA A LDA C ADD Y STA C LDA A BRP loop LDA C OUT HLT A DAT B …
Edrawrxd
  • 1
  • 2
0
votes
1 answer

How to count the total of numbers from input in LMC

I'm struggling a bit on this question. Essentially, I have to loop through a code with inputs, until the input is 0. Doing that by BRZ. And then, I have to output how many numbers that have been typed in to input. If I have typed in 1, 4, 6, 2, then…
ali03
  • 11
  • 2
0
votes
0 answers

LMC assemble code n- bit binary to decimal

I am trying to create an LMC assemble code that can convert an n-bit binary number into a number using the base-10 number system. Display the natural number as an output before halting the program.
0
votes
1 answer

LMC program do not output the correct sum

loop inp sta numa sub validate endthis brp loop bra label1 label1 lda numa sub validate1 brp label2 brz label2 endthis bra loop label2 lda num loop sta num add total sta total …
Gigi
  • 3
  • 3
0
votes
1 answer

Sorting least to greatest of five numbers

I need to sort five numbers from least to greatest. I have been struggling with this assignment for a Little Man computer simulator. I tried adding more loops for the addition of 2 input numbers, but it never worked. Working sorter for 3 numbers: …
samsi
  • 1
  • 1
0
votes
1 answer

Little Main Computer program to display quotient followed by remainder

This is what I have so far but I can't get it to work. I need to have it input a dividend and a divisor and output the result along with the remainder. Example: if the input is 33 followed by 6 the output will be 5 followed by 3 since 33/6 is 5…
user7806600