In: Computer Science
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