Question
MASM IRVINE32 You are to write a program which will have the following Procedures (Functions): getAreaRectangle getAreaTriangle getAreaCircle getPerimeterRectangle getPerimeterTriangle getPerimeterCircle You will first need
MASM IRVINE32
You are to write a program which will have the following Procedures (Functions):
getAreaRectangle
getAreaTriangle
getAreaCircle
getPerimeterRectangle
getPerimeterTriangle
getPerimeterCircle
You will first need to ask the user if they want to find the Area or the Perimeter.
Then you will ask of which shape (Rectangle, Triangle, Circle).
Finally, based on the input of the user, you will call the Procedure and display the correct answer on the screen.
This is going to be a long program!! It will mainly test your ability to use Condition statements and Procedures.
EDIT: Please use the number 3 instead of 3.14 for Pi
INCLUDE Irvine32.inc
; Define constants for calculating circle area and perimeter PI = 3.14159
; Define procedures for calculating area and perimeter
getAreaRectangle PROC ; Retrieve parameters from the stack mov eax, [esp+4] ; length mov ebx, [esp+8] ; width ; Calculate the area and return it imul eax, ebx ret getAreaRectangle ENDP
getPerimeterRectangle PROC ; Retrieve parameters from the stack mov eax, [esp+4] ; length mov ebx, [esp+8] ; width ; Calculate the perimeter and return it add eax, ebx add eax, eax ret getPerimeterRectangle ENDP
getAreaTriangle PROC ; Retrieve parameters from the stack mov eax, [esp+4] ; base mov ebx, [esp+8] ; height ; Calculate the area and return it imul eax, ebx sar eax, 1 ret getAreaTriangle ENDP
getPerimeterTriangle PROC ; Retrieve parameters from the stack mov eax, [esp+4] ; side1 mov ebx, [esp+8] ; side2 add eax, ebx add eax, [esp+12] ; side3 ; Return the perimeter ret getPerimeterTriangle ENDP
getAreaCircle PROC ; Retrieve parameter from the stack mov eax, [esp+4] ; radius ; Calculate the area and return it fld PI fmul DWORD PTR [esp+4] fmul DWORD PTR [esp+4] fstp DWORD PTR [esp+4] ret getAreaCircle ENDP
getPerimeterCircle PROC ; Retrieve parameter from the stack mov eax, [esp+4] ; radius ; Calculate the perimeter and return it fld PI fmul DWORD PTR [esp+4] fmul DWORD PTR 2 fstp DWORD PTR [esp+4] ret getPerimeterCircle ENDP
; Define the main program main PROC ; Display menu options mov edx, OFFSET menu call WriteString ; Prompt user for their choice call ReadChar cmp al, '1' je calculateArea cmp al, '2' je calculatePerimeter ; Invalid input, display error message and exit mov edx, OFFSET invalidInput call WriteString jmp exitProgram
calculateArea: ; Display shape options mov edx, OFFSET shapeMenu call WriteString ; Prompt user for their choice call ReadChar cmp al, '1' je calculateRectangleArea cmp al, '2' je calculateTriangleArea cmp al, '3' je calculateCircleArea ; Invalid input, display error message and exit mov edx, OFFSET invalidInput call WriteString jmp exitProgram
calculatePerimeter: ; Display shape options mov edx, OFFSET shapeMenu call WriteString ; Prompt user for their choice call ReadChar cmp al, '1' je calculateRectanglePerimeter cmp al, '2' je calculateTrianglePerimeter cmp al, '3' je calculateCirclePerimeter ; Invalid input, display error
i am getting a error for the whole getAreaRectangle if you can help fix problem it would be nice thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started