Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MARIE assembly language program that calculates and displays the perimet

ID: 3873883 • Letter: W

Question

Write a MARIE assembly language program that calculates and displays the perimeter or the area of a rectangle, given the length of each side, depending on the user’s input.

The user should be prompted to enter the length of each of the sides; once these values have been read by the program, provide the user with the options to select which calculation to perform on the rectangle, and prompt them to enter one of the options.

For example: Enter Perimeter(P) or Area(A)

The application should accept a character corresponding to one of the actions: P for Perimeter or A for Area. The output statements should accurately describe the results being displayed. For example, if the input is:

4 (for one side)

5 (for the other side)

A (for calculation type)

Your program should print something like this:

The area of the rectangle is 20.

Your program should be preceded by a comment block with your name, the course and section numbers, the project name, the program purpose, along with a description of the input and a description of the output. Be sure to include appropriate comments throughout your code, choose meaningful identifiers, and use indentation as shown in your textbook and in class. Your filename should be RectangleOperations.mas.

Submit your program by uploading it in the Assignment link in Blackboard.

Explanation / Answer

CLEAR / Clears the accumulator

INPUT / taking input from the keyboard into the accumulator

STORE LEN / Storing the value from the accumulator into address LEN

INPUT

STORE BRE

INPUT

STORE CHOICE / loading value in address A in accumulator

SUBT P / subtracting value in address P from accumulator

SKIPCOND 000 / skip if value is negative in accumulator that is choice has been given as A then skip the next instruction and the then part will be executed which calculates the area

JUMP ELSE

THEN,

FOR_INIT, LOAD ONE

STORE I / store the value at address I into accumulator

FOR_COND,LOAD I / I contains value 1 which

SUBT BRE

SKIPCOND 800 / if I> BRE LOOP STOPS

JUMP FOR_BODY

JUMP END_FOR  

FOR_BODY,

LOAD AREA

ADD LEN

STORE AREA

JUMP FOR_COND

END_FOR,

LOAD AREA

OUTPUT

JUMP END_IF

ELSE,

CLEAR

ADD LEN

ADD LEN

ADD BRE

ADD BRE

STORE PERI

LOAD PERI

OUTPUT

END_IF, HALT

PERI, DEC 0

AREA, DEC 0

CHOICE, DEC 0

P, DEC 80

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote