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

Allow Users To Multiply 2 Arrays Using Yasm Assembly Language Assignment Solution

July 01, 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
When working on OCaml assignments, make use of pattern matching to simplify your code. It provides a clean and efficient way to handle different cases, especially for recursive functions and data structures like lists and trees. This can reduce complexity and improve readability.
News
Universities worldwide are seeing a surge in programming enrollment, as coding becomes an essential skill across disciplines. To meet growing academic pressures, more students are seeking online help for programming assignments and coursework.

Instructions

Objective

Write a program that allows users to multiply 2 arrays using Yasm assembly language.

Requirements and Specifications

The task in the main section is to explicitly follow the equation and iteratively add -3 to the indexed value in array a, subtract the indexed value in array b by 14 and finally addthese two parts and store the resulting value in memory location result.

You are allowed to use a maximum of three general purpose registers in this lab. You are not allowed to change any values in the memory locations of a and b. Some of the opcodes of use in this lab are:

  • mov - moving data from register-register, register-variable etc
  • lea - loading the effective address of a variable to a register.
  • add - adding two values in registers or in variables.
  • sub - subtract two values in registers or in variables

Screenshots of output

multiply-2-arrays-using-Yasm-Assembly-language

Source Code

segment .data a dw -4, 22, 144 ; array of 3 values b db -3, -16, 12 ; array of 3 values result dq 0 ; memory to result segment .text global main main: mov rcx, 0 ; rcx will be i in the loop, initialize to 0 sumloop: movsx rax, word[a + rcx*2] ; load word value a[i] add rax, -3 ; add -3 to get (-3 + a[i]) movsx rbx, byte[b + rcx] ; load byte value b[i] sub rbx, 14 ; subtract 14 to get (b[i]-14) add rax, rbx ; add (-3 + a[i]) + (b[i]-14) add [result], rax ; add this result to total result inc rcx ; increment i cmp rcx, 3 ; compare i with 3 jl sumloop ; repeat while i < 3 xor rax, rax ; zero out rax xor rbx, rbx ; zero out rbx xor rcx, rcx ; zero out rcx ret

Similar Samples

Explore our diverse collection of programming assignment samples at ProgrammingHomeworkHelp.com. Our examples cover various languages and topics, showcasing our expertise in delivering high-quality solutions tailored to academic needs. Discover how our samples can assist you in mastering programming concepts effectively.