Description
1 8051 Microcontroller Programming using Edsim51
If you have not already installed Edsim51 simulator, follow these instructions:
http://www.edsim51.com/installationInstructions.html
To see a list of all assembly commands, visit the following link:
https://www.keil.com/support/man/docs/is51/is51_opcodes.htm
The fibonacci sequence is defined as follows:
Xn = X(n−1) + X(n−2)
X = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, …
Write a subroutine that generates the first N series of the fibonacci sequence and stores it on the memory.
You can manually set the N in R7 and use that through your code, The output should be stored on the
memory, starting from address 0x40H, and should be reused to generate the next output. That means,
you have to read the memory location N − 2 and N − 1 in order to generate the output N. You can
assume that 2 < N < 13, that means you will only need 8 bit to store the output, and the first two
members of the sequence can be written manually to the proper memory location (Through coding).
Test your code on the following values of N : 6, 9, 12.
Here are some useful commands for this assignment:
• DJNZ Rx, offset
• MOV A, @Rx
• MOV @Rx, A
• INC Rx
• DEC Rx
1
• ADD A, @Rx
• ADDC A, @Rx
2 Bonus point (10%)
Try to implement a 16 bit version of the function. That means, your code should be able to handle
2 < N < 25. You have to assign two memory location per each member of the sequence, one for the
lower 8 bits and one for the higher 8 bits. Test your code for N : 15, 19.
3 Assignment Deliverable
– Your code should be commented.
– Submit commented assembly file.
– Submit screenshot showing the data in code memory and register values for each test case.
– Submit the assignment before deadline through Canvas, in a zip file.
2