Question

In: Computer Science

Creat a linux assembly program that asks two scores from the user, specifically, the raw score...

Creat a linux assembly program that asks two scores from the user, specifically, the raw score as the first score and the total score as the second score. Store the digits in the EAX and EBX register, respectively. Given the formula raw score divided by total score times 50 and plus 50. Store the result in a memory location 'res' and finally display the result.

Solutions

Expert Solution

Here is the working code :

bits 32
global start   
extern exit,printf, scanf ; it tells that exit exists even if we won't be defining it
import exit msvcrt.dll ; exit function is defined in msvcrt.dll
import printf msvcrt.dll ; contains important C-runtime specific functions (exit, printf)
import scanf msvcrt.dll ; Data Declaration


segment data use32 class=data public

format_scanf db "%d", 0
format_printf1 db "Enter scores for both Raw and Total Score", 0x0d, 0x0a, 0   
format_printf2 db "The result is = %d", 0x0d, 0x0a, 0

score1 dd 0
score2 dd 0
res dd 0
  
segment code use32 class=code public
start:

push dword format_printf1
call [printf]
add esp, 4*1

push score1
push dword format_scanf
call [scanf]
add esp, 4*2

push score2
push dword format_scanf
call [scanf]
add esp, 4*2

MOV EAX, [score1] ; we have the raw score
MOV EBX, [score2] ; we have the total score

MOV EDX, 0 ; Arithmetic operations start from here
MOV ECX, 50
MUL EBX ; start multiplication by 50, result store in EDX:EAX

DIV ECX ; EDX:EAX is divided by ECX (whose value is 50) and quotient will be in EAX, and the remainder in EDX

ADD EAX, 50

MOV [res], EAX

push dword [res]
push dword format_printf2
call [printf]
add esp, 4*2

; exit(0)
push dword 0
call [exit]   


Related Solutions

Create a Linux program that asks two scores from the user, specifically the raw score as...
Create a Linux program that asks two scores from the user, specifically the raw score as the first score and the total score as the second score. Store the digits in the EAX and EBX register, respectively. Given the formula raw score divided by total score times 50 and plus 50. Store the result in memory location ‘res’ and finally display the result.
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user toinput an...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user to input an integer and then prints out a string that shows how that integer should be encoded using 16 bits. Your program should handle both positive and negative valued inputs. Your program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.As an example, if the input is 12, your program should output “0000000000001100”. If the input...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or enter -1 to stop. When finished entering all the scores, the program should display the number of scores entered, the sum of the scores, the mean, the lowest and the highest score. (IN PYTHON)
write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
Write a program that asks the user to enter five test scores. The program should display...
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100...
PYTHON: Write a program to continuously asks the user an score given as integer percentages in...
PYTHON: Write a program to continuously asks the user an score given as integer percentages in the range 0 to 100. Calculate the total number of grades in each letter-grade category as follows: 90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, and 0 to 59 is an F. Use a negative score as a sentinel value to indicate the end of the input. (The...
Write a mips assembly language program that asks the user to enter an unsigned number and...
Write a mips assembly language program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Write a mips assembly language program that asks the user to enter an alphabetic character (either...
Write a mips assembly language program that asks the user to enter an alphabetic character (either lower or upper case)and change the case of the character from lower to upper and from upper to lower and display it.
Write a javascript program that asks the user to enter up to 10 golf scores, which...
Write a javascript program that asks the user to enter up to 10 golf scores, which are to be stored in an array. You should provide a means for the user to terminate input prior to entering 10 scores. The program should display all the scores on one line and report the average score. Handle input, display, and the average calculation with three separate array processing functions.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT