I am trying to write two different programs in LMC using an old assembly language. The first as is follows:
Writea LMC program that takes two inputs, a number to count down from, and the stepvalue (example: count down from 35 by 5), until it reaches zero. It should print each step, and the lastnumber before zero if the sequence doesn’t end on zero, but if the number goesto negative, that number should not be printed. Example output using 13 and 3 as inputs would be: 13, 10, 7, 4, 1. Example output using 12 and 3 as inputs wouldbe: 12, 9, 6, 3, 0.
I have tried something along the lines of this:
Which does not work
The second LMC program I am trying to write is as follows:
Writethe code to calculate the area and perimeter of a triangle. The program should take 3 inputs, which are,in order, the base, height, and the third side of the triangle. The code shouldproduce 2 values in the output box, the first number will be the area and thesecond, the perimeter. (Hint: you’ll probably want to use DAT statements tostore some values to start).
Im in this same class, although Im not gonna give you the answer I'll give some hints.
First a few errors in your coding:
The Store command is STA not STO
You have to number all your code lines starting with 00
EX. 00 IN
You only have 2 inputs for the first part, so you cant read in 3 times.
Now some hints:
Try subtracting the second number that was stored from the first number then restoring in the same slot. Then use the SKN coupled with the JMP command to reiterate your code...like a loop. That way it will keep subtracting until it hits negative, and dont forget to output each number.
For the Triangle one the area is 1/2(base * Height) just think about what multiplication is in Addition. (Use a counter). The first part is to get you ready for the second part, remember that. For division the dividing factor is by two so use a counter like in multiplication but subtract the numbers instead of add and deduct from the counter by 2 instead of 1.