Question: Given the following ARM64 assembly am.s, copy it into Raspberry Pi, then use gcc -g -o am am.s to compile it. You should be able

Given the following ARM64 assembly am.s, copy it into Raspberry Pi, then use "gcc -g -o am am.s" to compile it. You should be able to see a generated executable file "am".

.text

.global main

.type main, %function

main:

sub sp, sp,#64

mov x0,0x8899

movk x0,0xeeff, lsl16

movk x0,0xccdd, lsl32

movk x0,0x7abb, lsl48

str x0, [sp,24]

mov x0,0x7768

movk x0,0x5566, lsl16

movk x0,0x3344, lsl32

movk x0,0x1122, lsl48

str x0, [sp,48]

mov x0, sp //or add x0, sp, xzr

add x0, x0,#24

str x0, [sp,40]

mov w0,65

strb w0, [sp,39]

mov w0,66

strb w0, [sp,38]

mov x0, sp

mov x1,#3

ldr x2, [x0, x1, lsl#3]

ldr x3, [x0,#48]

cmp x3, x2

bge L1

ldr x0, [sp,24]

sub x0, x0,#0x56

str x0, [sp,24]

L1: ldr x0, [sp,40]

ldr x0, [x0]

strb w0, [sp,39]

ldr x0, [sp,48]

strb w0, [sp,38]

ldrb w0, [sp,39]

ldrb w1, [sp,38]

mov w0,0

add sp, sp,64

ret

Open a terminal window, single step run the program in the debugger GDB by "gdb am" to figure out what it does. Answer these questions: 1. Add commends to each line of code to tell what they do. 2. What are the values in x2, x3, and w0, w1 right before the last 3 lines? 3. Fill the following stack frame table:

SP
+8
+16
+24
+32
+40
+48
+56

Submission: Put your answers and results in a single file calledLastnameFirstInitial_l3.pdf (e.g., if your name is John Smith, it will be SmithJ_l3.pdf) and upload to your blackboard account by the due day.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!