Question

In: Computer Science

Write an assembly language program to calculate score = (num1 + num2) /2 i.e input two...

Write an assembly language program to calculate score = (num1 + num2) /2 i.e input two numbers num 1 and num 2 and divide it by 2 to display score.Test your program for the Pep/9 computer.

Solutions

Expert Solution

STACK SEGMENT
STACK ENDS
DATA SEGMENT   ; initialization of data segment
 n1 DB 10   ;Declaration of first value
 n2 DB 3   ;Declaration of second value
 avg DB ?          ;Empty slot to store average
 remainder DB " remainder ",'$'
 rem DB ?           ;Empty slot to store remainder
DATA ENDS    ;End of data segment
CODE SEGMENT   ; code segment
ASSUME CS: CODE, DS: DATA
Start:     ;Starting address
 MOV AX, DATA
 MOV DS, AX   ;Initialize the DS register
 
 MOV AL, n1
 ADD AL, n2
 MOV AH, 00   
 MOV BL, 02   
 DIV BL    
 
 ADD AL, 48
 MOV average, AL  ;stores average
 ADD AH, 48
 MOV rem, AH   ;stores remainder
 
 CALL disp           
 
 MOV AX, 4C00H  ;Returns control to MS-DOS
 INT 21H
 
disp proc           ;Procedure "disp"
 MOV AH, 02H
 MOV DL, average
 INT 21H    ;Displays average
 
 MOV AH, 09H
 LEA DX, remainder
 INT 21H    ;Displays message "remainder"
 
 MOV AH, 02H
 MOV DL, rem
 INT 21H    ;Displays remainder
 ret     ;returns control back to the point this procedure was called
disp endp           ;End of procedure
 

 
CODE ENDS    ;End of code segment
END Start    ;End of program

Related Solutions

Assembly using x86 irvine (masm) Write a complete program that will input values for num1 ,num2,...
Assembly using x86 irvine (masm) Write a complete program that will input values for num1 ,num2, and num3 and display the value of the expression ( (num1 ^ 3) * num2 + 5 * ( num2 ^ 2) ) / num3. assume that the user enters only numbers that are greater than zero and the calculation never exceed 4 bytes size. Sample run: num1 = 1 num2 = 2 num3 = 3 ((num1 ^ 3) * num2 + 5 *...
Write an interactive program that inputs a decimal num1 and an integer num2. If num1 is...
Write an interactive program that inputs a decimal num1 and an integer num2. If num1 is less than num2, then it displays "num 1 is less than num 2"; if they are identical, it starts over again; if . If num2 is less than num1, then it displays "num 2 is less than num 1
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Q4. Please write a function Calculate_integer_division(). Your function should accept two parameters num1 and num2 and...
Q4. Please write a function Calculate_integer_division(). Your function should accept two parameters num1 and num2 and return the result of integer division of num1 by num2. So if num1 is 9 and num2 is 2, the function should return 4. Call your function and print out the result. Q5. Please print out the following with the help of a range() function: 200, 400, 600, 800 Q6. Please print 'Go.' if the traffic light is green, 'Wait.' if it's yellow and...
Write an assembly language program to input a string from the user. Your program should do...
Write an assembly language program to input a string from the user. Your program should do these two things: ***** I AM POSTING THIS QUESTION FOR THE THIRD TIME NOW,I WANT IT DONE USING INCLUDE IRVINE32.INC***** 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   "Hello thEre. How aRe yOu?" Your output should be:...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A palindrome is a word, number, phrase or any other sequence which reads the same backward as forward e.g. madam, racecar. Sample Execution: Please enter a String: redivider The string is a palindrome Another Sample Execution: Please enter a String: abracadabra The string is not a palindrome
in assembly language x86 Masm, Write a program that calculate the first seven values of the...
in assembly language x86 Masm, Write a program that calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(0) = 0, Fib(1) = 1, Fib(2) = Fib(0)+ Fib(1), Fib(n) = Fib(n-1) + Fib(n-2). You NEED to calculate each value in the series "using registers and the ADD operation" You can also use variables, Have your program print out "The first seven numbers is" Use WriteInt for the printing, Place each value in the EAX...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
**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)
Write a mips assembly language program to ask the user to enter two integers A and...
Write a mips assembly language program to ask the user to enter two integers A and B and then display the result of computing the expression: A + 2B - 5.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT