In: Computer Science
Write a sequence of assembly language instructions to subtract each entry of an array A of five two’s complement 16-bit binary integers from the corresponding entry of an array B of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i].
Use the following data for the arrays A and B.
A: 10, -15, 20, 4, -5
B: 25, -5, -30, 6, 10
please answer in computer assembler not c++
sub():
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-32], 1
mov DWORD PTR [rbp-28], 2
mov DWORD PTR [rbp-24], 3
mov DWORD PTR [rbp-20], 4
mov DWORD PTR [rbp-16], 5
mov DWORD PTR [rbp-12], 6
mov DWORD PTR [rbp-64], 9
mov DWORD PTR [rbp-60], 8
mov DWORD PTR [rbp-56], 7
mov DWORD PTR [rbp-52], 5
mov DWORD PTR [rbp-48], 8
mov DWORD PTR [rbp-44], 3
mov DWORD PTR [rbp-4], 0
.L5:
cmp DWORD PTR [rbp-4], 4
jg .L2
mov eax, DWORD PTR [rbp-4]
cdqe
mov edx, DWORD PTR [rbp-32+rax*4]
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-64+rax*4]
cmp edx, eax
jl .L3
mov eax, DWORD PTR [rbp-4]
cdqe
mov edx, DWORD PTR [rbp-32+rax*4]
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-64+rax*4]
sub edx, eax
mov eax, DWORD PTR [rbp-4]
cdqe
mov DWORD PTR [rbp-96+rax*4], edx
jmp .L4
.L3:
mov eax, DWORD PTR [rbp-4]
cdqe
mov edx, DWORD PTR [rbp-64+rax*4]
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-32+rax*4]
cmp edx, eax
jle .L4
mov eax, DWORD PTR [rbp-4]
cdqe
mov edx, DWORD PTR [rbp-64+rax*4]
mov eax, DWORD PTR [rbp-4]
cdqe
mov eax, DWORD PTR [rbp-32+rax*4]
sub edx, eax
mov eax, DWORD PTR [rbp-4]
cdqe
mov DWORD PTR [rbp-96+rax*4], edx
.L4:
add DWORD PTR [rbp-4], 1
jmp .L5
.L2:
mov eax, DWORD PTR [rbp-76]
pop rbp
ret