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
( 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...
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 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.
Write an assembly language program to define an array of 5 double words initialized to 33,44,25,72,23,11...
Write an assembly language program to define an array of 5 double words initialized to 33,44,25,72,23,11 (all decimal). Add the first three numbers together and subtract the last two numbers from the sum. Store the sum in EAX register. Display the sum by using Irvine32 library procedures or by dumping registers to the display and taking a screenshot.
in MARIE simulator, write assembly language to BUBBLE SORT 30 hexadecimals store in two array.
in MARIE simulator, write assembly language to BUBBLE SORT 30 hexadecimals store in two array.
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.
“Computer programming is creating a sequence of very precise instructions written in a language a computer...
“Computer programming is creating a sequence of very precise instructions written in a language a computer understands, to perform a specified task with a computer.” Discuss in detail the concept of extreme precision in computer programming.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT