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

Assembly x84 Objective: Learn conditional processing: Comparison and jump instru

ID: 3812026 • Letter: A

Question

Assembly x84

Objective: Learn conditional processing: Comparison and jump instructions, if and while statements, and learn data transfer concepts and instructions, and memory allocation. Requirements: Write an assembly program to find the largest element by searching an array int ary [] = {1, 5, -3, -4, 0, 6, 11, -9, 18} int index = 0; int max = ary[0]; int arraySize = sizeof array/sizeof max while (index max) max = ary|index|;} Use cmp instruction and the appropriate jump instruction (signed or unsigned) to translate the if and while statements Use S operator (see chapter 3) to calculate the size of the array, and inc instruction to increment the index of the array Run your program using the debugger to verify your answers (do this too for questions 2 and 3) Submit the following: Lastname1.asm Write an assembly program to implement the following. while X > 0 if X != 3 AND (X B) X = X - 2 else X = X - 1 end while Use short-circuit evaluation Assume that A, B, and X are 32-bit signed integers variables Assume that A=5, B=6, and X=11Io Submit the following: Lastname2.asm Write an assembly program to compute the following: y = 3x + 9x - 10 where x and y are 32-bit integer variables x is in the range of (1 =

Explanation / Answer

please find the code for ques 1

main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-48], 1
mov DWORD PTR [rbp-44], 5
mov DWORD PTR [rbp-40], -3
mov DWORD PTR [rbp-36], -4
mov DWORD PTR [rbp-32], 0
mov DWORD PTR [rbp-28], 6
mov DWORD PTR [rbp-24], 11
mov DWORD PTR [rbp-20], -9
mov DWORD PTR [rbp-16], 18
mov DWORD PTR [rbp-8], 0
mov eax, DWORD PTR [rbp-48]
mov DWORD PTR [rbp-4], eax
mov DWORD PTR [rbp-12], 9
.L4:
mov eax, DWORD PTR [rbp-8]
cmp eax, DWORD PTR [rbp-12]
jge .L2
mov eax, DWORD PTR [rbp-8]
cdqe
mov eax, DWORD PTR [rbp-48+rax*4]
cmp eax, DWORD PTR [rbp-4]
jle .L4
mov eax, DWORD PTR [rbp-8]
cdqe
mov eax, DWORD PTR [rbp-48+rax*4]
mov DWORD PTR [rbp-4], eax
jmp .L4
.L2:
mov eax, 0
pop rbp
ret

code for Ques 2

main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 11
mov DWORD PTR [rbp-8], 5
mov DWORD PTR [rbp-12], 6
.L6:
cmp DWORD PTR [rbp-4], 0
jle .L2
cmp DWORD PTR [rbp-4], 3
je .L3
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-8]
jl .L4
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-12]
jle .L3
.L4:
sub DWORD PTR [rbp-4], 2
jmp .L5
.L3:
sub DWORD PTR [rbp-4], 1
.L5:
jmp .L6
.L2:
mov eax, 0
pop rbp
ret

code for Ques 3

main:
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], 0
mov DWORD PTR [rbp-8], 1
.L5:
cmp DWORD PTR [rbp-8], 8
jg .L2
cmp DWORD PTR [rbp-8], 1
je .L3
cmp DWORD PTR [rbp-8], 3
je .L3
cmp DWORD PTR [rbp-8], 5
je .L3
cmp DWORD PTR [rbp-8], 7
jne .L4
.L3:
mov edx, DWORD PTR [rbp-8]
mov eax, edx
add eax, eax
add eax, edx
sal eax, 2
lea edx, [rax-10]
mov eax, DWORD PTR [rbp-4]
cdqe
mov DWORD PTR [rbp-32+rax*4], edx
add DWORD PTR [rbp-4], 1
.L4:
add DWORD PTR [rbp-8], 1
jmp .L5
.L2:
mov eax, 0
pop rbp
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