Question

In: Computer Science

Assembly language please Test Score Evaluation Create a procedure named CalcGrade that receives an integer value...

Assembly language please

Test Score Evaluation
Create a procedure named CalcGrade that receives an integer value between 0 and 50, and returns a single capital letter in the AL register. Preserve all other register values between calls to the procedure. The letter returned by the procedure should be displayed and should be according to the following
ranges:

Score 45 to 50 Grade A
Score 40 to 44 Grade B
Score 35 to 39 Grade C
Score 0 to 34 Grade F

Write a test program that

1. asks the user to enter integer between 0 and 50, inclusive. If the user enters invalid number, please display error message.

2. Pass it to the CalcGrade procedure.

3. Repeat steps 1 and 2 three times so that you collect three scores from the user and display the respective grade for each score.

Solutions

Expert Solution

AS NO Assembly language version is mentioned

Code for ARM64 Assembly

CalcGrade(int):

sub sp, sp, #16

str w0, [sp, 12]

ldr w0, [sp, 12]

cmp w0, 44

ble .L2

mov w0, 65

b .L3

.L2:

ldr w0, [sp, 12]

cmp w0, 39

ble .L4

mov w0, 66

b .L3

.L4:

ldr w0, [sp, 12]

cmp w0, 34

ble .L5

mov w0, 67

b .L3

.L5:

mov w0, 70

.L3:

add sp, sp, 16

ret

.LC0:

.string "\nEnter integer 0 to 50: "

.LC1:

.string "Please Enter Valid integer between 0 and 50 \n"

.LC2:

.string "Enter integer 0 to 50: "

.LC3:

.string "Your Grade is "

main:

stp x29, x30, [sp, -32]!

mov x29, sp

str wzr, [sp, 28]

.L11:

ldr w0, [sp, 28]

cmp w0, 2

bgt .L7

adrp x0, .LC0

add x1, x0, :lo12:.LC0

adrp x0, _ZSt4cout

add x0, x0, :lo12:_ZSt4cout

bl std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

add x0, sp, 20

mov x1, x0

adrp x0, _ZSt3cin

add x0, x0, :lo12:_ZSt3cin

bl std::basic_istream<char, std::char_traits<char> >::operator>>(int&)

.L10:

ldr w0, [sp, 20]

cmp w0, 0

blt .L8

ldr w0, [sp, 20]

cmp w0, 50

ble .L9

.L8:

adrp x0, .LC1

add x1, x0, :lo12:.LC1

adrp x0, _ZSt4cout

add x0, x0, :lo12:_ZSt4cout

bl std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

adrp x0, .LC2

add x1, x0, :lo12:.LC2

adrp x0, _ZSt4cout

add x0, x0, :lo12:_ZSt4cout

bl std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

add x0, sp, 20

mov x1, x0

adrp x0, _ZSt3cin

add x0, x0, :lo12:_ZSt3cin

bl std::basic_istream<char, std::char_traits<char> >::operator>>(int&)

b .L10

.L9:

ldr w0, [sp, 20]

bl CalcGrade(int)

strb w0, [sp, 27]

adrp x0, .LC3

add x1, x0, :lo12:.LC3

adrp x0, _ZSt4cout

add x0, x0, :lo12:_ZSt4cout

bl std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

ldrb w1, [sp, 27]

bl std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char)

mov x2, x0

adrp x0, _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_

add x1, x0, :lo12:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_

mov x0, x2

bl std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

ldr w0, [sp, 28]

add w0, w0, 1

str w0, [sp, 28]

b .L11

.L7:

mov w0, 0

ldp x29, x30, [sp], 32

ret

__static_initialization_and_destruction_0(int, int):

stp x29, x30, [sp, -32]!

mov x29, sp

str w0, [sp, 28]

str w1, [sp, 24]

ldr w0, [sp, 28]

cmp w0, 1

bne .L15

ldr w1, [sp, 24]

mov w0, 65535

cmp w1, w0

bne .L15

adrp x0, _ZStL8__ioinit

add x0, x0, :lo12:_ZStL8__ioinit

bl std::ios_base::Init::Init() [complete object constructor]

adrp x0, __dso_handle

add x2, x0, :lo12:__dso_handle

adrp x0, _ZStL8__ioinit

add x1, x0, :lo12:_ZStL8__ioinit

adrp x0, _ZNSt8ios_base4InitD1Ev

add x0, x0, :lo12:_ZNSt8ios_base4InitD1Ev

bl __cxa_atexit

.L15:

nop

ldp x29, x30, [sp], 32

ret

_GLOBAL__sub_I_CalcGrade(int):

stp x29, x30, [sp, -16]!

mov x29, sp

mov w1, 65535

mov w0, 1

bl __static_initialization_and_destruction_0(int, int)

ldp x29, x30, [sp], 16

ret

IF YOU HAVE ANY QUERY PLEASE COMMENT DOWN BELOW.
PLEASE GIVE A THUMBS UP


Related Solutions

In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length...
In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will hold the random string. Write a test program that calls your procedure 20 times and displays the strings in the console window. In your program, the random string size shall be preset as a constant. Please include...
Q1) Create a function called max that receives two integer values and returns the value of...
Q1) Create a function called max that receives two integer values and returns the value of the bigger integer. Q2) Complete the missing code in the following program. Assume that a cosine function has already been created for you. Consider the following function header for the cos function. double cos (double x) #include void output_separator() { std::cout << "================"; } void greet_name(string name) { std::cout << "Hey " << name << "! How are you?"; } int sum(int x, int...
In a package named "oop" create a Scala class named "Score" with the following: • A...
In a package named "oop" create a Scala class named "Score" with the following: • A constructor that takes an Int and stores it in a member variable named score • A method named scoreGoal that takes no parameters and has return type Unit that increments the score by 1 • A method named isWinner that takes a Score object as a parameter and returns a Boolean. The method returns true if this instances score is strictly greater than the...
Write a RECURSIVE method that receives as a parameter an integer named n. The method will...
Write a RECURSIVE method that receives as a parameter an integer named n. The method will output n # of lines of stars. For example, the first line will have one star, the second line will have two stars, and so on. The line number n will have "n" number of ****** (stars) so if n is 3 it would print * ** *** The method must not have any loops!
Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
Hi this is Assembly Language MASM x86 program. Please write it in the language and please...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please explain it with comments thank you Please answer it I really need help this question was refunded before so please answer. Thank you so much also these are two separate programs thank you. 1) Write a procedure to read in decimal or hex number (byte-sized) Then write a procedure using shifts and ANDS to convert the string to a binary number (if is backward,...
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer"...
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer" to calculate the square root for an-8 bit integer using The Radix-2 SRT-Redundant and Non-Redundant Algorithm to approximate square root
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose...
ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose value can fit within 8 bits, and outputs the value of the expression n2 – n + 6.
Write a script that creates and calls a stored procedure named test. This procedure should identify...
Write a script that creates and calls a stored procedure named test. This procedure should identify all of the prime numbers less than 100. (A prime number is an integer that can't be divided by another integer other than 1 and itself.) Then, it should display a string variable that includes the prime numbers like this: 2 1 3 1 5 1 7 1 1 1 1 1 3 1 1 7 1 1 9 1 2 3 1 2...
SQL Code: Write a script that creates and calls a stored procedure named test. This procedure...
SQL Code: Write a script that creates and calls a stored procedure named test. This procedure should identify all of the prime numbers less than 100. (A prime number is an integer that can't be divided by another integer other than 1 and itself.) Then, it should display a string variable that includes the prime numbers like this: 2 1 3 1 5 1 7 1 1 1 1 1 3 1 1 7 1 1 9 1 2 3...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT