Questions tagged [little-man-computer]
Little Man Computer (LMC) models an instructional Von Neumann computer architecture and uses assembly language.
87
questions
0
votes
0
answers
23
views
Indirect addressing LMC [duplicate]
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 ...
0
votes
0
answers
38
views
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 ...
1
vote
1
answer
98
views
How can you reverse a list in LMC language?
I have a list in LMC and I would like to try to reverse it like so :
tab dat 111
dat 222
dat 333
dat 444
dat 555
tab dat 555
dat 444
dat 333
...
-1
votes
1
answer
46
views
How to add cx^2 to a+bx in LMC, with overflow output as 999?
I need to write an LMC program to calculate the value of a+bx+cx² for given values of a, b, c and x. If the result exceeds 999, then it needs to output 999; if less than 999, then output the result.
...
1
vote
1
answer
242
views
LMC program to recognize if a number doesn't evenly divide into another
I am trying to create a program in LMC which checks if a number evenly divides into another one (such as 10/2), with the program below I am able to do divison and halt the program as required
INP
...
0
votes
2
answers
55
views
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
...
-1
votes
1
answer
94
views
Divison in LMC with and without remainder
I need a bit of help to code how to divide a sum of numbers, divided by n numbers put in. For instance, the sum is 10, with 2 numbers, the answer should be 5. But if the sum is 14 and the total input (...
0
votes
1
answer
104
views
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 ...
0
votes
1
answer
129
views
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 ...
0
votes
0
answers
35
views
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.
1
vote
1
answer
154
views
LMC program that will produce the sum of the median and twice the smallest of 3 inputs
so I've been tasked to create a little-man-machine program that will take 3 distinct inputs and produce the result of the median + 2 * the smallest number.
So far I've managed to produce an output ...
1
vote
2
answers
346
views
How to produce dividend and remainder in a little man computer program?
I am trying to write a LMC program that takes two integer inputs, divides them, and produces the quotient and remainder. To start, I broke down the problem into 4 stages:
1.Divide num1 by num2 to get ...
-3
votes
1
answer
504
views
Get maximum and count of input numbers [closed]
I need to create a simple LMC program for the following task:
Input a series of numbers and output:
the largest among them, and
how many numbers were entered.
The number 000 will be used to mark ...
1
vote
1
answer
300
views
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 ...
1
vote
1
answer
272
views
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 ...
2
votes
2
answers
2k
views
Input three numbers into the LMC and output them largest to smallest?
So, I've managed to get the bulk of the problem done however I can only output from largest to smallest if the input values are ascending? first = 10, second = 20, third = 30. How would I output this ...
1
vote
1
answer
531
views
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 ...
1
vote
1
answer
634
views
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 ...
1
vote
1
answer
768
views
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 ...
0
votes
1
answer
112
views
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 ...
0
votes
1
answer
340
views
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 ...
1
vote
1
answer
212
views
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 ...
2
votes
1
answer
376
views
Fetch - execute cycle for LMC instructions
I have to define the steps for each Little Man Computer instruction (ADD, SUB, BR, BRP etc.), and I'm having trouble with the branching instructions and COB (or the Halt instruction). I understand the ...
-2
votes
1
answer
926
views
Sort three input numbers [closed]
I am looking at this assignment:
Write a program that takes three inputs and outputs them in ascending order.
I had used the following LMC simulator: https://www.101computing.net/LMC/#
And this is ...
0
votes
1
answer
217
views
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 ...
0
votes
1
answer
192
views
How to print a list of values + max/min
I am looking at this Little man computer problem:
The user will enter first the size of the data, and then the individual numbers.
I have to print (OUT) excatcly what was input, followed by the max ...
1
vote
1
answer
231
views
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 ...
1
vote
1
answer
445
views
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 ...
1
vote
1
answer
268
views
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 ...
1
vote
1
answer
168
views
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, ...
0
votes
2
answers
412
views
Output a sequence [closed]
For a Little Man Computer (LMC) simulator I have the following assignment:
Your code must accept a number between 1 and 15.
It must then add the number 2 (to the submitted number),
before displaying ...
0
votes
2
answers
499
views
Bubble sort with variable number of inputs
I am working on a bubble sort program for the Little Man Computer and I want it to have a variable number of inputs (like 500), after which the program will stop taking inputs and will sort the values ...
0
votes
1
answer
280
views
e-LMC extended Little Man Computer bubble embedded program continuous input
I am looking for a e-LMC extended little man computer program that will accept an indefinite inputs and bubble-sort them. I need to have more inputs continuous and then do the bubble sort.
INP //read ...
1
vote
1
answer
207
views
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 ...
0
votes
1
answer
608
views
Branching when negative accumulator
I'm trying to create a loop that will print if a number given is odd or even (Par). How do I branch the loop when the accumulator value is -1?
START INP // int(input(""))
STA n // ...
0
votes
1
answer
290
views
Program to sum input numbers is not working
I am trying to make a program that first takes n inputs from the user, and then calculates the sum of those numbers. Then I want the program to print if the sum is an even or an odd number.
For ...
0
votes
1
answer
766
views
How to find the greatest of more than two input numbers
I was able to write an LMC program which finds the greater value of two input values. But how do I modify it to find the greatest value of any number of input values, not only two?
Below is my code:
...
0
votes
1
answer
284
views
Bubble sort 4 numbers
I'm trying to code a bubble sort using the LMC, and well, it's not going too great.
First of all it just loops for all eternity, and I cannot figure out the cause, maybe a pair of fresh eyes would ...
0
votes
2
answers
57
views
How to take number up to 64 and output in a 000 000 binary format
The goal is to accept a number up to 64 and output it in binary in a 000 000 format, so encoded in two decimal values. I know that LMC wont allow an output number like 010, so a format like 11 100 is ...
0
votes
1
answer
152
views
How to loop and encode as binary?
I am trying to get a program running in the LMC that converts any numerical to binary.
Normally I would just use the divide method, but I cannot do that since the Little Man Computer does not allow ...
0
votes
2
answers
325
views
Summing up values if number of values is given as first input
How do I write a Little Man program that adds up a series of input numbers and outputs the sum. The first input value will contain the number of values that follow as input, and which are to be added ...
2
votes
2
answers
768
views
Is Little Man Computer still relevant?
I´m trying to learn how computers actually works, I found some simulator software but the seem to be very complex (I´m still a beginner). I saw Little Man Computer (LMC) which is very old. I´m ...
-1
votes
1
answer
217
views
Negative division in little man computer
I always get stuck in a loop when I try to make a division with a negative number in LMC. For exemple 10/2 will give me 5 and -10/-2 will also work and give 5. The problem is when there is a single ...
-5
votes
1
answer
1k
views
Little Man Computer - I'm trying to find the right answer [closed]
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
...
1
vote
1
answer
819
views
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 ...
0
votes
1
answer
1k
views
How to find the sum of odd numbers in LMC
I am learning LMC, but I am not able to find the sum of odd numbers till 100 in LMC
such as 1+3+5+7... and so on
I did write the code to add the two numbers
INP //here I wil input 1
STA 99
INP ...
0
votes
1
answer
3k
views
Little Man Computer Integer Division with Remainder
I've managed to code an LMC program which works on this simulator for performing integer division. However if there is a remainder it goes into an infinite loop.
I'm trying to think of a way to just ...
0
votes
0
answers
89
views
How to do a base conversion with Little Man Computer?
I need to convert a decimal number to a base between 2 and 9 using Little Man Computer. How do I proceed?
I believe successive divisions are the best method. In my opinion, I must write a code which ...
0
votes
0
answers
337
views
how to convert a number from base 10 to any other base using Little Man Computer
I need to create a program that takes as the first input : A decimal number and as a second input the number of the base it will be converted to . then outputs the result of the conversion .
I ...
2
votes
1
answer
562
views
LMC: base conversion from decimal to base 9 included
I am trying to create an LMC assemble code that will allow a user to put two inputs: a decimal number and a base that the number should be converted to. The code should be able to convert any decimal ...