Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly code that declare three arrays A,B,C where the value of array

ID: 3700871 • Letter: W

Question

Write an assembly code that declare three arrays A,B,C where the value of array A from the user and array B you can load it “array of 5” you need to calculate and store values in array c based on this condition If A[i] >= B[i] Then C [i] = A[i] -B[i] Else C[i] =A[i]*B[i] ? and then print array C Write an assembly code that declare three arrays A,B,C where the value of array A from the user and array B you can load it “array of 5” you need to calculate and store values in array c based on this condition If A[i] >= B[i] Then C [i] = A[i] -B[i] Else C[i] =A[i]*B[i] ? and then print array C Write an assembly code that declare three arrays A,B,C where the value of array A from the user and array B you can load it “array of 5” you need to calculate and store values in array c based on this condition If A[i] >= B[i] Then C [i] = A[i] -B[i] Else C[i] =A[i]*B[i] ? and then print array C

Explanation / Answer

.LC0:

.string "Enter A-array Elements "

.LC1:

.string "%d"

.LC2:

.string "Loading B-Array"

.LC3:

.string "%d "

.LC4:

.string "Loading of B-Array is done!"

.LC5:

.string " Calculating C-Array Elements!"

.LC6:

.string "Calculation of C-Array is done!"

.LC7:

.string "C-Array Elements Are"

.LC8:

.string "%d "

main:

pushq %rbp

movq %rsp, %rbp

subq $96, %rsp

movl $0, -4(%rbp)

movl $.LC0, %edi

call puts

movl $0, -4(%rbp)

jmp .L2

.L3:

leaq -32(%rbp), %rax

movl -4(%rbp), %edx

movslq %edx, %rdx

salq $2, %rdx

addq %rdx, %rax

movq %rax, %rsi

movl $.LC1, %edi

movl $0, %eax

call __isoc99_scanf

addl $1, -4(%rbp)

.L2:

cmpl $4, -4(%rbp)

jle .L3

movl $.LC2, %edi

call puts

movl $0, -4(%rbp)

jmp .L4

.L5:

movl -4(%rbp), %eax

addl $1, %eax

leal (%rax,%rax), %edx

movl -4(%rbp), %eax

cltq

movl %edx, -64(%rbp,%rax,4)

movl -4(%rbp), %eax

cltq

movl -64(%rbp,%rax,4), %eax

movl %eax, %esi

movl $.LC3, %edi

movl $0, %eax

call printf

addl $1, -4(%rbp)

.L4:

cmpl $4, -4(%rbp)

jle .L5

movl $.LC4, %edi

call puts

movl $.LC5, %edi

call puts

movl $0, -4(%rbp)

jmp .L6

.L9:

movl -4(%rbp), %eax

cltq

movl -32(%rbp,%rax,4), %edx

movl -4(%rbp), %eax

cltq

movl -64(%rbp,%rax,4), %eax

cmpl %eax, %edx

jle .L7

movl -4(%rbp), %eax

cltq

movl -32(%rbp,%rax,4), %edx

movl -4(%rbp), %eax

cltq

movl -64(%rbp,%rax,4), %eax

subl %eax, %edx

movl -4(%rbp), %eax

cltq

movl %edx, -96(%rbp,%rax,4)

jmp .L8

.L7:

movl -4(%rbp), %eax

cltq

movl -32(%rbp,%rax,4), %edx

movl -4(%rbp), %eax

cltq

movl -64(%rbp,%rax,4), %eax

imull %eax, %edx

movl -4(%rbp), %eax

cltq

movl %edx, -96(%rbp,%rax,4)

.L8:

addl $1, -4(%rbp)

.L6:

cmpl $4, -4(%rbp)

jle .L9

movl $.LC6, %edi

call puts

movl $.LC7, %edi

call puts

movl $0, -4(%rbp)

jmp .L10

.L11:

movl -4(%rbp), %eax

cltq

movl -96(%rbp,%rax,4), %eax

movl %eax, %esi

movl $.LC8, %edi

movl $0, %eax

call printf

addl $1, -4(%rbp)

.L10:

cmpl $4, -4(%rbp)

jle .L11

movl $0, %eax

leave

ret

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote