Question

In: Computer Science

Write a sequence of assembly language instructions to subtract each entry of an array A of...

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++

Solutions

Expert Solution

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


Related Solutions

1. Convert the machine language instructions into assembly language instructions: 7976C1 06
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
For the PIC16F887, using the execution delay of instructions, write assembly language commands to implement a...
For the PIC16F887, using the execution delay of instructions, write assembly language commands to implement a delay of 3 seconds
Write a possible assembly language instruction or set of instructions to accomplish the following: a) Compare...
Write a possible assembly language instruction or set of instructions to accomplish the following: a) Compare the byte stored at the memory location pointed to by register R4 to the upper (higher) byte stored in register R5 b) Branch to instruction at label ‘ZERO’ if the lower byte of register R6 is zero c) Jump to the instruction at label ‘EVEN’ if the value in register R7 is an even number
( Assembly Language ) Write a program that computes the 7th fibonacci number. The fibonacci sequence...
( Assembly Language ) Write a program that computes the 7th fibonacci number. The fibonacci sequence - 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, … what is the initialization of a, b, and d? - a b d 1 ? ? 1 2 ? ? 1 3 1 1 2 4 1 2 3 5 2 3 5 6 3 5 8 7 5 8 13 wrong initialization - a b d 1 0 1 1 2...
Assembly Language. Write a procedure that reverses order of a 1-D array using the stack. The...
Assembly Language. Write a procedure that reverses order of a 1-D array using the stack. The array is a string array, and the address along with the number of elements are passed through the stack. Then write a complete program to test your procedure.
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
What are the pseudo instructions commonly used in the MCS-51 assembly language? What effect does each...
What are the pseudo instructions commonly used in the MCS-51 assembly language? What effect does each directive have? 6. Provided data area from 1000H to 10FFH in external RAM, transfer the data to the area starting at 2500H in external RAM. Please write the program. 11. The crystal oscillator frequency of system is 12MHz. Write the delay subroutine with delay time of 50ms.
Use MIPS assembly language program to swap two of the integers in an integer array. The...
Use MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. The main function should: • Pass the starting address of the array in $a0. • Pass the indices of the two elements to swap in $a1 and $a2. • Preserve (i.e. push onto the stack) any T registers that it uses. • Call the Swap...
Thinking in Assembly language What values will be written to the array when the following code...
Thinking in Assembly language What values will be written to the array when the following code executes? .data array DWORD 4 DUP(0) .code main PROC mov eax,10 mov esi,0 call proc_1 add esi,4 add eax,10 mov array[esi],eax INVOKE ExitProcess,0 main ENDP proc_1 PROC call proc_2 add esi,4 add eax,10 mov array[esi],eax ret proc_1 ENDP proc_2 PROC call proc_3 add esi,4 add eax,10 mov array[esi],eax ret proc_2 ENDP proc_3 PROC mov array[esi],eax ret proc_3 ENDP
For 80x86 assembly language and computer architrctureIn terms of modules, define an export.Which entry...
For 80x86 assembly language and computer architrctureIn terms of modules, define an export.Which entry of the resource directory identifies the start of the export directory?What is the role of the import table in dynamic linking?What is the primary benefit of storing a precomputed import address into IMAGE_IMPORT_DESCRIPTOR.FirstThunk?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT