A+ Work




In order to complete this assignment, you need to setup MASM (and Visual Studio) on your home computer or laptop if this is where you intend to do your assignments. If you plan to use the lab computers, go to NW201 and make sure the MASM environment is working.
A) [10 marks] Write a program which defines four double word variables, A, B, C & D in the data segment, assigns any values you like to the variables, and then solves the following equation:
A = (A - B) + (C - D) using only EAX and EBX
Show the final answer in a debugging window by setting a break point on the instruction which saves the answer back into variable A. Include a screenshot of the debugging window in the Word file. Also, call the DumpRegs library function to show the values in EAX and EBX. Include a screenshot of the console.
B) [10 marks] Write a program that uses a loop to calculate the first twenty-five values of the Fibonacci number sequence described by the formula: Fib(0) = 0, Fib(1) = 1, Fib(n) = Fib(n-1) + Fib(n-2). Place each value in the EAX register and display it using the WriteDec library function. Use the WriteString library function to print a string “, “,0 which is a comma, a space and a null terminator and the CrLf function to print a newline character (see Chapter 5.4.3, pages 158-70). Display each Fibonacci number inside the loop. The output would be something like:
0, 1, 1, 2, 3, 5, 8, 13, 21, ...
C) Use the following array definitions in the data segment of your program:
arrayA BYTE arrayB SWORD arrayC DWORD copyA BYTE copyB SWORD copyC DWORD
10, 20, 30 40, 50, 60, 70

-1, -2, -3, -4, -5, -6, -7, -8, -9, -10 100h, 200h, 300h, 400h

7 DUP(?)

10 DUP(?)

4 DUP(?)
Then create a program which:
a) Prints the original contents of the arrays in HEX using the WriteHex library function (single line with spaces).
COSC2406SS15 – Assembly Language Programming
b) Reverses the contents of the arrays using the SIZEOF, TYPE and LENGTHOF operators as well as a loop with indirect or indexed addressing. The copies would go into copy arrays – that is arrayA is reversed into copyA
c) Print the contents of the copy arrays (after the reversal) in HEX using the WriteHex library function.
Include a screenshot of the program output with the code in the Word document.
Submit your Word file (one file only) to CMS using the file name ASSIGN3_YourName.docx where YourName is ***** ***** name followed by your first name. Ex. Using my name, the file would be ASSIGN3_LajoieMichael.docx. Also, be sure to include your name at the beginning of the Word document