Question

1. Write an ARMV8 program to compute the maximum of three numbers x, y, and z....

1. Write an ARMV8 program to compute the maximum of three numbers x, y, and z. (25)
2. Write an ARMV8 program to bubblesort an Array of numbers A[i] in ascending order. (50)
3. Google uunction. Write an ARMV8 program to compute this function. Include the high-level language code that you used as well.

1. Write an ARMV8 program to compute the maximum of three numbers x, y, and z. (25)
2. Write an ARMV8 program to bubblesort an Array of numbers A[i] in ascending order. (50)
3. Google McCarthy’s 91 function. Write an ARMV8 program to compute this function. Include the high-level language code that you used as well.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have answered all the questions. Do give a thumps up

1.

.LC0:

.string "Enter the numbers A, B and C: "

.LC1:

.string "%d is the largest number."

main:

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

mov x29, sp

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, 28

mov x1, x0

adrp x0, _ZSt3cin

add x0, x0, :lo12:_ZSt3cin

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

mov x2, x0

add x0, sp, 24

mov x1, x0

mov x0, x2

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

mov x2, x0

add x0, sp, 20

mov x1, x0

mov x0, x2

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

ldr w1, [sp, 28]

ldr w0, [sp, 24]

cmp w1, w0

blt .L2

ldr w1, [sp, 28]

ldr w0, [sp, 20]

cmp w1, w0

blt .L2

ldr w0, [sp, 28]

mov w1, w0

adrp x0, .LC1

add x0, x0, :lo12:.LC1

bl printf

.L2:

ldr w1, [sp, 24]

ldr w0, [sp, 28]

cmp w1, w0

blt .L3

ldr w1, [sp, 24]

ldr w0, [sp, 20]

cmp w1, w0

blt .L3

ldr w0, [sp, 24]

mov w1, w0

adrp x0, .LC1

add x0, x0, :lo12:.LC1

bl printf

.L3:

ldr w1, [sp, 20]

ldr w0, [sp, 28]

cmp w1, w0

blt .L4

ldr w1, [sp, 20]

ldr w0, [sp, 24]

cmp w1, w0

blt .L4

ldr w0, [sp, 20]

mov w1, w0

adrp x0, .LC1

add x0, x0, :lo12:.LC1

bl printf

.L4:

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 .L8

ldr w1, [sp, 24]

mov w0, 65535

cmp w1, w0

bne .L8

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

.L8:

nop

ldp x29, x30, [sp], 32

ret

_GLOBAL__sub_I_main:

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

2.

.LC0:

.string "Enter the size of array: "

.LC1:

.string "Enter the array elements: "

.LC2:

.string " "

main:

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

mov x29, sp

stp x19, x20, [sp, 16]

stp x21, x22, [sp, 32]

stp x23, x24, [sp, 48]

stp x25, x26, [sp, 64]

str x27, [sp, 80]

mov x0, sp

mov x27, x0

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, x29, 104

mov x1, x0

adrp x0, _ZSt3cin

add x0, x0, :lo12:_ZSt3cin

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

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*)

ldr w0, [x29, 104]

sxtw x0, w0

sub x0, x0, #1

str x0, [x29, 120]

mov x1, x0

add x1, x1, 1

mov x25, x1

mov x26, 0

lsr x1, x25, 59

lsl x22, x26, 5

orr x22, x1, x22

lsl x21, x25, 5

mov x1, x0

add x1, x1, 1

mov x23, x1

mov x24, 0

lsr x1, x23, 59

lsl x20, x24, 5

orr x20, x1, x20

lsl x19, x23, 5

add x0, x0, 1

lsl x0, x0, 2

add x0, x0, 15

lsr x0, x0, 4

lsl x0, x0, 4

sub sp, sp, x0

mov x0, sp

add x0, x0, 3

lsr x0, x0, 2

lsl x0, x0, 2

str x0, [x29, 112]

str wzr, [x29, 128]

.L3:

ldr w0, [x29, 104]

ldr w1, [x29, 128]

cmp w1, w0

bge .L2

ldrsw x0, [x29, 128]

lsl x0, x0, 2

ldr x1, [x29, 112]

add x0, x1, x0

mov x1, x0

adrp x0, _ZSt3cin

add x0, x0, :lo12:_ZSt3cin

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

ldr w0, [x29, 128]

add w0, w0, 1

str w0, [x29, 128]

b .L3

.L2:

mov w0, 1

str w0, [x29, 132]

.L8:

ldr w0, [x29, 104]

ldr w1, [x29, 132]

cmp w1, w0

bge .L4

str wzr, [x29, 136]

.L7:

ldr w1, [x29, 104]

ldr w0, [x29, 132]

sub w0, w1, w0

ldr w1, [x29, 136]

cmp w1, w0

bge .L5

ldr x0, [x29, 112]

ldrsw x1, [x29, 136]

ldr w1, [x0, x1, lsl 2]

ldr w0, [x29, 136]

add w2, w0, 1

ldr x0, [x29, 112]

sxtw x2, w2

ldr w0, [x0, x2, lsl 2]

cmp w1, w0

ble .L6

ldr x0, [x29, 112]

ldrsw x1, [x29, 136]

ldr w0, [x0, x1, lsl 2]

str w0, [x29, 108]

ldr w0, [x29, 136]

add w1, w0, 1

ldr x0, [x29, 112]

sxtw x1, w1

ldr w2, [x0, x1, lsl 2]

ldr x0, [x29, 112]

ldrsw x1, [x29, 136]

str w2, [x0, x1, lsl 2]

ldr w0, [x29, 136]

add w1, w0, 1

ldr x0, [x29, 112]

sxtw x1, w1

ldr w2, [x29, 108]

str w2, [x0, x1, lsl 2]

.L6:

ldr w0, [x29, 136]

add w0, w0, 1

str w0, [x29, 136]

b .L7

.L5:

ldr w0, [x29, 132]

add w0, w0, 1

str w0, [x29, 132]

b .L8

.L4:

str wzr, [x29, 140]

.L10:

ldr w0, [x29, 104]

ldr w1, [x29, 140]

cmp w1, w0

bge .L9

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*)

mov x2, x0

ldr x0, [x29, 112]

ldrsw x1, [x29, 140]

ldr w0, [x0, x1, lsl 2]

mov w1, w0

mov x0, x2

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

ldr w0, [x29, 140]

add w0, w0, 1

str w0, [x29, 140]

b .L10

.L9:

mov w0, 0

mov sp, x27

mov sp, x29

ldp x19, x20, [sp, 16]

ldp x21, x22, [sp, 32]

ldp x23, x24, [sp, 48]

ldp x25, x26, [sp, 64]

ldr x27, [sp, 80]

ldp x29, x30, [sp], 144

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 .L14

ldr w1, [sp, 24]

mov w0, 65535

cmp w1, w0

bne .L14

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

.L14:

nop

ldp x29, x30, [sp], 32

ret

_GLOBAL__sub_I_main:

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

3.

M(int):

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

mov x29, sp

str w0, [sp, 28]

ldr w0, [sp, 28]

cmp w0, 100

ble .L2

ldr w0, [sp, 28]

sub w0, w0, #10

str w0, [sp, 28]

ldr w0, [sp, 28]

b .L3

.L2:

ldr w0, [sp, 28]

add w0, w0, 11

bl M(int)

bl M(int)

nop

.L3:

ldp x29, x30, [sp], 32

ret

.LC0:

.string "enter a number "

main:

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

mov x29, sp

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*)

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> >&))

add x0, sp, 24

mov x1, x0

adrp x0, _ZSt3cin

add x0, x0, :lo12:_ZSt3cin

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

ldr w0, [sp, 24]

bl M(int)

str w0, [sp, 28]

ldr w1, [sp, 28]

adrp x0, _ZSt4cout

add x0, x0, :lo12:_ZSt4cout

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

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> >&))

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 .L8

ldr w1, [sp, 24]

mov w0, 65535

cmp w1, w0

bne .L8

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

.L8:

nop

ldp x29, x30, [sp], 32

ret

_GLOBAL__sub_I_M(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

Add a comment
Know the answer?
Add Answer to:
1. Write an ARMV8 program to compute the maximum of three numbers x, y, and z....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT