Question

In: Electrical Engineering

Assignment Description: Develop and test an Intel 8086 assembly program that reads two decimal numbers x...

Assignment Description:
Develop and test an Intel 8086 assembly program that reads two decimal numbers x and y. Your program
should display the result of their:
1) Addition: x+y
2) Subtraction: x-y
3) Multiplication: x*y
4) Division: x / y
Notes:
 x and y are two-digit decimal numbers (i.e. 0-99).
 The program should display an error message if the value of y is zero, in the case of division.
 You can assume only positive numbers but you will get a bonus if your program can read and handle
negative numbers.
 You will get higher mark if your program accepts only two decimal digits (0-9) for each number and
print error message when the user tries to enter non-decimal digits (e.g. A-Z, or a-z, or any special
character).
Your program output should be similar to the following examples:
Example1: (x>y)
Please enter two 2-digit decimal
number:
X= 48
Y= 26
X + Y = 74
X – Y = 22
X * Y = 1248
X /Y = 1 with Remainder 22
Example2: (x<y)
Please enter two 2-digit decimal
number:
X= 12
Y= 37
X + Y = 49
X – Y = -25
X * Y = 444
X /Y = 0 with Remainder 12
Example3: (y=0)
Please enter two 2-digit decimal
number:
X= 56
Y= 00
X + Y = 56
X – Y = 56
X * Y = 00
X /Y = error overflow

Solutions

Expert Solution

Hey! Hope you're having a great day! If this helps, please don't forget to leave a thumbs up!

The following code uses the Irvine32 library, so make sure it's installed in your system.

TITLE MASM Template (main.asm)

INCLUDE Irvine32.inc

.data

;Please choose either of the following operations:', 13,10,0

szMenu db "Now what do you want to do with those 2 numbers?", 13, 10

db 'Add (A)',13,10

db 'Subtract (S)',13,10

db 'Divide (D)',13,10

db 'Multiply (M)',13,10

db 'Exit (E)',13,10

db 'Selection: ',0 ;13,10,0

myMenu db 'Welcome!', 13, 10

db 'Enter Integer 1: ',0

myInteger2 db 'Enter Integer 2: ',0;13,10,0

szInvalidMenu db 13, 10, "Invalid Menu Choice!", 13, 10, 0

myTotal db 'Total: ',13,10,0

.data?

Input1 dd ?

Input2 dd ?

Total dd ?

.code

Start:

call Clrscr

mov edx, offset myMenu

call WriteString

  

FirstNum:

call ReadInt

test eax, eax

jz Start

mov Input1, eax

SecondNum:

mov edx, offset myInteger2

call WriteString

call ReadInt

test eax, eax

jz SecondNum

mov Input2, eax

Menu:

mov edx, offset szMenu

call WriteString

call ReadChar

.if al == "A" || al == "a"

Call Crlf

mov edx, offset myTotal

call WriteString

mov eax, Total

mov eax, Input1

add eax, Input2

Call WriteInt

Call Crlf

;jmp start

  

.elseif al == "S" || al == "s"

  

Call Crlf

mov edx, offset myTotal

call WriteString

mov eax, Total

mov eax, Input1

sub eax, Input2

Call WriteInt

Call Crlf

;jmp start

  

.elseif al == "D" || al == "d"

Call Crlf

mov edx, offset myTotal

call WriteString

mov eax, Total

mov eax, Input1

div eax, Input2

Call WriteInt

Call Crlf

;jmp start

  

.elseif al == "M" || al == "m"

  

Call Crlf

mov edx, offset myTotal

call WriteString

mov eax, Total

mov eax, Input1

mul eax, Input2

Call WriteInt

Call Crlf

;jmp start

  

.elseif al == "E" || al == "e"

exit

  

.else

mov edx, offset szInvalidMenu

call WriteString

jmp Menu

.endif

  

call WaitMsg

exit

end Start

exit

main ENDP

END main


Related Solutions

Develop and test an Intel 8086 assembly program by emu8086 amd dont use any extirnall lib...
Develop and test an Intel 8086 assembly program by emu8086 amd dont use any extirnall lib , that reads two decimal numbers x and y. Your program should display the result of their: 1) Addition: x+y 2) Subtraction: x-y 3) Multiplication: x*y 4) Division: x / y Notes:  x and y are two-digit decimal numbers (i.e. 0-99).  The program should display an error message if the value of y is zero, in the case of division.  You...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays the sum and the difference. In the .data section, define two variables num1 and num2 both words. Initialize num1 to 92413 10 and num2 to D4B 16 (use 0xD4B to initialize, Note that D4B is a hexadecimal number). Your main procedure/function should load the values of num1 and num2 into two temporary registers, and display them on the console window. Then add the values...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. A * 5 (A + B) - (A / B) (A - B) + (A * B)
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers,...
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. 1) A * 5 2) (A + B) - (A / B) 3) (A - B) + (A * B)
Develop an x86 assembly language program that properly executes an "x to the y power" function:...
Develop an x86 assembly language program that properly executes an "x to the y power" function: int power(int x, int y) Compute the integer value that is x to the y power Do not concern yourself with the possibility of overflow You may only use only a loop structure to compute the value Remember that the return value must be placed in the EAX register Make sure that any registers (not EAX) used by this function are placed back to...
Assignment #2 will be the construction of a program that reads in an unspecified number of...
Assignment #2 will be the construction of a program that reads in an unspecified number of integers from standard input, performs some calculations on the inputted numbers, and outputs the results of those calculations to standard output. The numbers could be delimited by any kind of whitespace, i.e. tabs, spaces, and lines (Note that if you use the Scanner class, you do not have to worry about these delimiters. They will be taken care of). Your program will continue to...
Develop a recursive algorithm that multiply two integer numbers x and y, where x is an...
Develop a recursive algorithm that multiply two integer numbers x and y, where x is an m-bit number and y is an n-bit number (10 points), and analyze the time complexity of this algorithm (10 points).
Write a program that reads a file (provided as attachment to this assignment) and write the...
Write a program that reads a file (provided as attachment to this assignment) and write the file to a different file with line numbers inserted at the beginning of each line. Such as Example File Input: This is a test Example File Output 1. This is a test. (Please comment and document your code and take your time no rush).
in java Write a program that reads in ten numbers and displays the number of distinct...
in java Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly one space (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read a number and store it to an array if it is new. If the number is already in the array, ignore it.) After the input, the array contains the distinct numbers. Here is the sample run of the program: Enter...
Write a program that reads two strings from an input file (The first line is X,...
Write a program that reads two strings from an input file (The first line is X, the second line is Y), compute the longest common subsequence length AND the resulting string. You will need to write 2 methods 1) return LCS length in iterative function // return the length of LCS. L is the 2D matrix, X, Y are the input strings, m=|X|, n=|Y| int lcs_it(int **C, string X, string Y, int m, int n ) 2) return LCS resulting...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT