Question

In x86 architecture, write an assembly program for the following: Xarray is an unsigned array of...

In x86 architecture, write an assembly program for the following:
Xarray is an unsigned array of bytes. Yarray is a signed array of words that has same number of elements as Xarray. Zarray is an uninitialized signed array of doublewords. Write a program that adds each element of Xarray to the corresponding element in Yarray and stores the result as an element in Zarray.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER :-

Assembly program

DATA SEGMENT
     XARRAY DB 36H,55H,27H,42H  
     ;initialize array with 1 byte size of elements
     YARRAY DW 63H,76H,82H,48H
     ;initialize array with 2 byte size of elements
     ZARRAY DD 70H,85H,91H,98H
     ;declaring an array to save the result with size of 4 bytes                                
ENDS

CODE SEGMENT 
    ASSUME DS:DATA CS:CODE
    ;DATA and CODE are the assumed names given to data segment and code segment            respectively

START:
      MOV AX,DATA
      ;data is moved to AX register which helps in moving data to data segment
      MOV DS,AX
      ;data is moved from AX register to data segment
      LEA SI,XARRAY
      ;load effective address from array variable to register
      LEA DI,YARRAY
      ;load effective address from array variable to register
      LEA BX,ZARRAY
      ;load effective address from array variable to register
      MOV CX,5
      ;the value 5 is moved to register which helped to create a loop of 5 iterations 
LOOP1:      
       MOV AL,[SI]                          
       ;move the value from SI register to AL register
       ADD AL,[DI]
       ;add the value from DI register to AL register and store the value in AL
       MOV [BX],AL           
       ;move the value from AL register to BX register
       INC BX
       ;increment of address
       INC SI
       ;increment of address
       INC DI 
       ;increment of address     
       LOOP LOOP1   
       ;the loop continuous depending on CX register value
     
      MOV AH,4CH
      INT 21H     
      ;the above two instructions are used to exit
ENDS
END START
Add a comment
Know the answer?
Add Answer to:
In x86 architecture, write an assembly program for the following: Xarray is an unsigned array of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • We are using the Kip Irvine Assembly Language for x86 Processors. The programming language is Assembly,...

    We are using the Kip Irvine Assembly Language for x86 Processors. The programming language is Assembly, and we are using visual studio community. Please specify any questions. Directions Declare an array of 60 uninitialized unsigned doubleword values. Create another array of 60 unsigned doublewords, initialized to ‘abcd’. Look at these arrays in the memory window and note how they are stored. (Intel architecture uses little - endian order) ATTEMPT ONLY IF YOU KNOW OTHERWISE I WILL DOWNVOTE.

  • Assembly Language Program Help Write a procedure named CountNearMatches that receives pointers to two arrays of...

    Assembly Language Program Help Write a procedure named CountNearMatches that receives pointers to two arrays of signed doublewords, a parameter that indicates the length of the two arrays, and a parameter that indicates the maximum allowed difference (called diff) between any two matching elements. For each element x(i) in the first array, if the difference between it and the corresponding y(i) in the second array is less than or equal to diff, increment a count. At the end, return a...

  • Please provide x86 (MASM not NASM) .386 (32bit) assembly program for the following (needs to be...

    Please provide x86 (MASM not NASM) .386 (32bit) assembly program for the following (needs to be compatible with Visual Studio 2015.asm file): (10 points) Write an assembly program to find the largest element by searching an array int aryll-[11, 15,-3,-4, 0,60.11,-9,18) int index-l; int max- 0; int arraySize-sizeof array /sizeof max while (index < arraySize) if (ary[index] > max) max = ary[index]; - Use cmp instruction and the appropriate jump instruction (signed or unsigned) to translate the if and while...

  • E2.15 In assembly code, write a program to count the number of elements in an array...

    E2.15 In assembly code, write a program to count the number of elements in an array that are smaller than 16. The array is stored at memory locations starting from $1010. The array has 30 8-bit unsigned elements. Store the count in the memory location $C001.

  • Assembly for x86 please. Thank you COSC 2325.S01 Program Nine Problem: Write an assembly procedure to sort the following array into numerical order and print the resulting array 5.8.6.3.4.1,0,9.2.7...

    Assembly for x86 please. Thank you COSC 2325.S01 Program Nine Problem: Write an assembly procedure to sort the following array into numerical order and print the resulting array 5.8.6.3.4.1,0,9.2.7 COSC 2325.S01 Program Nine Problem: Write an assembly procedure to sort the following array into numerical order and print the resulting array 5.8.6.3.4.1,0,9.2.7

  • X86 Assembly language lab: TITLE Lab 3: assembly language fundamentals               ;;;;; Q1: Don't...

    X86 Assembly language lab: TITLE Lab 3: assembly language fundamentals               ;;;;; Q1: Don't forget to document your program            ; Name:Yuyan Wang ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;; Answer each question below by writing code at the APPROPRIATE places in the file. ;;;;; Hint: the appropriate place is not always right below the question. ;;;;; Q2: Write the directive to bring in the IO library           ;;;;; Q3: Create a constant called MAX and initialize it to 150...

  • Write this code using x86 assembly language using the irvine32 library

    Write this code using x86 assembly language using the irvine32 library Create a procedure that fills an array of doublewords with N random integers, making sure the values fall within the range j...k, inclusive. When calling the procedure, pass a pointer to the array that will hold the data, pass N, and pass the values of j and k. Preserve all register values between calls to the procedure. Write a test program that calls the procedure twice, using different values...

  • Write a program in ARM assembly language that copies each element of array A to consecutive...

    Write a program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc. The array A is 12 elements long, and each element is a number that is 32 bits (1 word) wide. Assume the base address of array A is in register R2, and the base address of array B is in R3.

  • MIPS CODE required to write an assembly program to find the maximum of an array of integers by...

    required to write an assembly program to find the maximum of anarray of integers by doing the following:1. Prompt user to input array size n (n <= 10)2. Prompt user to input element values of array A one by one3. Display the result on the console.This program must at least include one function. The main program will read the valuesof the array (as user inputs the element values) and stores them in the memory (datasegments section) and at the end...

  • Convert this C++ program to x86 assembly language using the Irvine library: #include <iostream> unsigned int...

    Convert this C++ program to x86 assembly language using the Irvine library: #include <iostream> unsigned int x; unsigned int c; unsigned int result; // f(x) = 8x + c // Make sure to push and pop all necessary registers to the stack to // ensure only the EAX register is modified upon return from the function unsigned int Equation(unsigned int x, unsigned int c) { // You CANNOT use the mul or imul operations to perform the multiplication return (8...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT