×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Merge 2 Arrays in Assembly Language (Both Arrays Are Sorted, Merged Array Should Be In Order), Using Irvine Library In Assembly Language Assignment Solution

July 10, 2024
Rehana Magnus
Rehana Magnus
🇨🇦 Canada
Assembly Language
Rehana Magnus, PhD in Computer Science from the esteemed Acadia Institute of Technology, Canada. With 6 years of experience, specializes in assembly language programming. Proficient in low-level coding, optimizing performance, and enhancing system functionality.
Key Topics
  • Instructions
    • Objective
  • Requirements and Specifications
Tip of the day
Use the REPL (Read-Eval-Print Loop) to test your code interactively, and practice writing concise, readable expressions to harness Scala’s powerful syntax effectively.
News
In 2024, JavaScript's Redux saw updates for efficient state management, and Tailwind CSS gained traction for responsive design. Meanwhile, C++ libraries like Boost.

Instructions

Objective

Write a program to merge 2 arrays in assembly language (both arrays are sorted, merged array should be in order), using Irvine library in Assembly language.

Requirements and Specifications

Description:

Write an x86 assembler program that will merge two (2) presorted lists of unsigned numbers (up to 32-bits in size). All lists will have items sorted in ascending order. Each list will have at least one value; there is no other restriction on the size of the lists.

The input lists for this program will be declared internally in the data segment of your program. Do not prompt the user for the input. An example of this declaration is given below. Note that in the final sorted list, all items in the input lists must be present

Caveats:

  • This program must include at least one procedure beyond MAIN.
  • Be sure to thoroughly test this program as you will need this code for a subsequent assignment.
  • In the above example, the 2nd list is larger than the first. However, when I test your solution, either list may be larger than the other.
  • Just upload a zip file with the ASM source file for this program.

Screenshots of output

Merge-two-arrays-in-ARM-assembly-language

Source Code

Title ArrayMerge include irvine32.inc .data a1 dword 1,3,4,7,9,15,17 a2 dword 2,6,8,10,11,14,18,19 a3 dword 20 dup(0) p1 byte "List1:",0 p2 byte "List2:",0 p3 byte "Merged:",0 .code main proc sub EAX,EAX mov ESI,OFFSET a1 ; list 1 mov EDI,OFFSET a2 ; list 2 mov EDX,OFFSET a3 ; merged list mov EBX, lengthof a1 ; elements in list 1 mov ECX, lengthof a2 ; elements in list 2 call Merge mov EDX, offset p1 call writestring call crlf mov ECX,lengthof a1 mov EDX,offset a1 call Display call crlf mov EDX, offset p2 call writestring call crlf mov ECX,lengthof a2 mov EDX,offset a2 call Display call crlf mov EDX, offset p3 call writestring call crlf mov ECX,lengthof a1 add ECX,lengthof a2 mov EDX,offset a3 call Display exit main endp ;===================================================================== Merge proc TheLoop: cmp ebx, 0 je AddA2 cmp ecx, 0 je AddA1 mov EAX,[ESI] cmp EAX,[EDI] jl AddA1 ;Jump if less jmp AddA2 ;Jump if greater or equal AddA1: cmp ebx, 0 je EndJump mov EAX,[ESI] mov [EDX],ax add ESI,4 add EDX,4 dec EBX jmp TheLoop AddA2: cmp ecx, 0 je EndJump mov EAX,[EDI] mov [EDX],ax add EDI,4 add EDX,4 dec ECX jmp TheLoop EndJump: ret Merge endp ;================================================================== Display proc DisplayLoop: mov EAX,[EDX] add EDX, 4 call writedec call crlf loop DisplayLoop ret Display endp ;=================================================================== end main

Similar Samples

Explore our curated selection of programming homework samples at ProgrammingHomeworkHelp.com. From Python projects to Java assignments and more, each sample is crafted to illustrate practical solutions and coding techniques. Whether you're a student or professional, our diverse samples provide valuable insights to enhance your programming skills and academic success.