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

July 01, 2024
Rehana Magnus
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
News

## 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
``` 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 ```