Helpful Information: To solve Assembly programs, it is often useful to first cre

Helpful Information:
To solve Assembly programs, it is often useful to first create the algorithm which can be in pseudocode
or a language like Java. Based on your limited understanding of assembly, the programs for this
assignment will be limited to using:
a) Integers (either signed or unsigned) and strings.
b) Addition and/or subtraction operations only.
c) The programs will be constructed using just a main method.
d) All variables will be global variables – in Java terms, these would be static class variables (There
will be NO local variables.)
e) Loops and jumps
f) Arrays including the length property
You cannot use these because you do not know how yet:
a) Local variables
b) IF or SWITCH statements
c) Multiplication, division, modulus
d) Math library functions
You must fully comment your assembly programs. The pseudo-code or Java program code will be useful
for these comments.
The IRVINE library will be used in all the programs. No other libraries can be used.
To print a single character, use the WriteChar library function. The character to be printed is placed in
the AL register before calling WriteChar. The value in AL must be the actual character or the ASCII value
of the character.
.code
mov AL, ˈ*ˈ ; stores the asterisk character in the AL register
call WriteChar ; prints the character in the AL register
Important Requirements for these programs:
a) For this assignment, you are restricted to the following Irvine Library functions:
ReadInt ReadDec CrLf WriteString WriteChar
WriteInt WriteDec WriteBin WriteHex
b) You must fully comment your assembly programs. The pseudo-code or Java program code will be
useful for these comments.
c) You are restricted to only instructions and operators discussed in the lectures to the end of Module
5.
d) Make sure your name, course code, term, assignment number, date, question number are included
at the beginning of every program as a comment.
e) Use meaningful descriptive variable names.
f) Your code must be submitted. Programs which do not assemble and run will have a maximum grade
of 60%.
Questions:
A) [20 marks] Write an assembly program that uses a loop to calculate the first thirty values of a
number sequence described by the formula: F(0) = 1, F(1) = 4, F(2) = 3, F(3) = 2, and then F(n) =
2*F(n-1) + Fib(n-4) for n >=4. Your program needs to print the values as a comma separated – the
first four values are simply printed and the remaining values are calculated using a loop.
Here is the logic for the loop to calculate the values for F(n) where n > 3:
int a = 1, b = 4, c = 3, d = 2;
int current = 2 * d + a; //current = F(4)
for( int i = 4; i < n; ++i ) { //at this point, current = F(i) a = b; b = c; c = d; d = current; current = 2 *d + a; } //at this point, current = F(n) 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 when you are finished (see Chapter 5.4.3, pages 158-70). The output would be something like this: 1, 4, 3, 2, 5, 14, 31, 64, 133, 280, … question B) [10 marks] Create an array of 20 WORD values initialized to zero. Using a loop, populate the array with a sum series where the first element will be 1, the second will be 3 (1+2), the third will be 6 (1+2 +3), etc… Using second loop, print the values in the array so that ever number is separated by a comma and a space. BONUS: 1 mark if you do not print the comma after the last number.

Posted in Uncategorized

Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount