Question

In: Computer Science

: Please write a MARIE program to calculate 1+2+3+...+100.

: Please write a MARIE program to calculate 1+2+3+...+100.

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

LDA 301BH

MOV B, A

INR A

MOV C, A

MVI A, 00H

LOOP1 ADD B

DCR C

JNZ LOOP1

MVI C, 02H

MVI B, 00H

LOOP2 INR B

SUB C

JNZ LOOP2

MOV A, B

STA 301CH

HLT

Explanation:

Algorithm:

Taking N as the input, increment it to obtain N+1.
Multiply N with N+1.
Divide the obtained product obtained by 2.
Steps:

Load the data from the memory location (301BH, random choice) into the accumulator
Move the data into B
Increment the value in the accumulator by one and move it to the register C
Initialize the accumulator with 0
Multiplication step: Keep adding B to accumulator. The B has to be added equal number of times as the value of C
Initialize B with 00H. B will store the quotient of the division
Initialize C with 02H. This is the divisor for the division
Division step: Keep subtracting C from A till A becomes 0. For each subtraction, increment B by one
The final answer is in B. Move it to A. Then store the value of A in 301CH (again random choice)

Kindly revert for any queries

Thanks.


Related Solutions

Question 2. Write a MARIE program that accepts an integer from the user, and if it...
Question 2. Write a MARIE program that accepts an integer from the user, and if it is a prime number the program will output 1, otherwise, the program will output 0. Examples: If the user input is 17, the output would be 1 If the user input is 2, the output would be 1 If the user input is 15, the output would be 0 If the user input is -2, the output would be 0 You should write and...
write a java code to calculate 1+2-3+4-5 …-99+100
write a java code to calculate 1+2-3+4-5 …-99+100
USE Python 3, please type thanks! Write a Python 3 program to calculate the Body Mass...
USE Python 3, please type thanks! Write a Python 3 program to calculate the Body Mass Index (BMI) of a person if they enter their weight and their height to your program. Check out the formula here: http://www.freebmicalculator.net/calculate-bmi.php Your program should first print "Body Mass Index Calculator" The program will then ask the user if they want to enter Metric Units or English Units. Using the appropriate formula (see link above) calculate their BMI. Depending on their BMI show their...
-Write a program in C++: • to find the sum of the series 1! /1+2! /2+3!...
-Write a program in C++: • to find the sum of the series 1! /1+2! /2+3! /3+4! /4+5! /5 using the function1, • to convert decimal number to binary number using the function2, • to check whether a number is a prime number or not using the function3, • to check whether two given strings are an anagram using the function4. important must do in (Multi-Filing) of c++
Write a MARIE program that implements the following logic. If X < Y Then X =...
Write a MARIE program that implements the following logic. If X < Y Then X = X + Y Else Y = 2X Assume the two numbers are X and Y and are entered by the user. Provide prompts to the user to enter the numbers and provide a meaningful output to the screen.
1. Please program the following in Python 3 code. 2. Please share your code. 3. Please...
1. Please program the following in Python 3 code. 2. Please share your code. 3. Please show all outputs. Instructions: Run Python code  List as Stack  and verify the following calculations; submit screen shots in a single file. Postfix Expression                Result 4 5 7 2 + - * = -16 3 4 + 2  * 7 / = 2 5 7 + 6 2 -  * = 48 4 2 3 5 1 - + * + = 18   List as Stack Code: """...
3. Write a program that will accept only 5 numbers from 50 to 100. The program...
3. Write a program that will accept only 5 numbers from 50 to 100. The program should remind the user if an inputted number is not on the range. Compute the sum and average of the 1st and the 5th inputted numbers.
Multiples of 2 and 3: write a c++ program Using a while loop, write a program...
Multiples of 2 and 3: write a c++ program Using a while loop, write a program that reads 10 integer numbers. The program shall count how many of them are multiples of 2, how many are multiples of 3, and how many are NOT multiples of either 2 or 3. The output should be similar to the one shown below.
Using C Language Write a program segment that computes 1 + 2 + 3 + ......
Using C Language Write a program segment that computes 1 + 2 + 3 + ... + ( n - 1) + n , where n is a data value. Follow the loop body with an if statement that compares this value to (n * (n + 1)) / 2 and displays a message that indicates whether the values are the same or different. Please give me code to just copy and paste
Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The...
Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The parity checker should repeatedly execute a loop that performs the following tasks: 1. Ask the user for an input X, which can be any printable ASCII character from Table 1; 2. Output the decimal code of X; 3. Output the total number of 1’s that appears in the binary code of X; 4. Output the parity bit which, when added to the binary code...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT