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...
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...
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.
IN JAVA Write a complete program that asks the user to enter two real numbers from...
IN JAVA Write a complete program that asks the user to enter two real numbers from the console. If both numbers are positive print the product, if both numbers are negative print the quotient, otherwise print INVALID INPUT. Use a nested if; output should be to a dialog and console; use printf to format the console output (for real numbers specify the width and number of digits after the decimal). The output must be labeled. Follow Java conventions, indent your...
Create a program that asks the user for the names of two car dealerships and the...
Create a program that asks the user for the names of two car dealerships and the # of cars sold in each one. Then output that data in two columns as shown below. The "Store location" column has a width of 25, while the "Cars sold" column has a width of 9. Also, notice the alignment of the second column. The program should end with the "Press Enter to end this program" prompt. OUTPUT Enter the location for the first...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT