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 *...
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....
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
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.
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Write an MSP430 assembly language program that implements the following 2 algorithms: 2) a macro called...
Write an MSP430 assembly language program that implements the following 2 algorithms: 2) a macro called "vdot" that calculates the "dot product" of two vectors "a" and "b", implemented as “arrays” (following the “C” language convention), of 3 elements. the macro should receive 2 pointers to the first element of each vector and return the result in R13.
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)
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT