[SOLVED] CSC3210–Assignment 3

30.00 $

Category:

Description

5/5 - (2 votes)

Objective: Learn memory organization/layout, data transfer concepts and instructions, direct memory access, memory allocation.

Requirements:

1.       (5 points) Write an assembly program to compute the following expressions

–          Create a DWORD array named ‘z’ of size 3 using DUP operator. Leave the array ‘z’ uninitialized. You can denote the items in the array as [𝑧!, 𝑧”, 𝑧#], where 𝑧! is the first item, 𝑧”   is the second item,  𝑧# is the third item

–          Update each array item using the following expressions.

𝑧! = 𝑥 + 130

𝑧” = 𝑦 + 𝑥 −        𝑧!

𝑧# = 𝑟 + 𝑥 − 13

–          Where x, y, r are 16-bit integer memory variables.

–          x = 10, y = 15, r = 4

–          Use mov, movzx, movsx, add, sub instructions only.

–          (hint: Do not alter the value of x, y and r during the computation. Transfer them to appropriate registers to do computation)

–          At the end, open memory window to see the variable z stored in memory (little endian format). – If you code correctly, 𝑧! = 140 in decimal,  𝑧” = −115   in decimal, 𝑧# = 1            in decimal

–          Use the debugger to verify your answer.

o    Submit the following:

§   Rename the asm file using your last name  as Lastname1.asm

§   Screenshot of the code and memory window showing the content of the variable z (little endian format).

2.       (5 points) Use a loop instruction with indirect addressing to solve the problem.

–          Do not copy the elements to any other array.

–          Use the LOOP and XCHG instruction.

–          The input array, inputStr contains elements: “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”.

–          The array’s elements after running the program should look like: “H”, “G”, “F”, “E”, “D”, “C”, “B”, “A”.

o    Submit the following:

§   Rename the asm file using your last name as Lastname2.asm

§   Screenshot of the code and memory window showing the content of the variable inputStr.

3.       (5 points) Write an assembly program that does the following:

–          Define the following value 0506030704080102h in the .data segment using the 64-bit unsigned identifier named qVal.

–          You can subdivide the qVal value into 4 words – 0506, 0307, 4080, 0102 – Extract these words from qVal using PTR operator.

–          Find the sum of the words. The sum should be D17h.

–          Store the result in any 16-bit register.

–          The direction of adding two words goes from left to right.

o    Submit the following:

§  Rename the asm file using your last name as Lastname3.asm

§  Screenshot of the code and memory window showing the result in a 16-bit register.

Note:

§  Comment header for .ASM files:

Student: Full name

Class: CSC3210

Assignment#: 3

Description: This program ………….

§  Follow the program standards as presented in your book. Pay more attention to code comments and           consistent indentation.

§  Create a new project for every question. Do not use one project with multiple .asm files.