DEF Assign 07
DEF Assign 07
DEF Assign 07
Assignment 7
Purpose
In this lab, youll be spending some time analyzing some assembly and then youll be creating a project which will
implement a C program that does math tricks.
You can choose to do this exercise with a partner if you wish or you can do it on your own.
Objective
This assignment will make you familiar with:
Looking up and reading the instruction sheets for the 6808 to determine clock cycles, addressing modes,
The craft of taking code developed in the C programming language and implementing it in 6808 assembly
through proper assembly code design practices (i.e. through the use of developing and calling subroutines).
What to Submit
Your report-like submission will include the 2 required tables for Question 1 as well as a nicely formatted (and
commented) copy of your source code for Question 2. Please ensure that the name(s) of the people who worked on
the assignment are found on the title page of the hardcopy submission.
Submit your report document as well as a ZIP file containing your CodeWarrior 6808 Project (from Question 2) into
the eConestoga dropbox no later than 2:00pm (i.e. end of the last lab) on the due date. As well, you will submit a
hardcopy (print out) of your Assignment answers by the same time. If you are doing this assignment with a partner,
only one hardcopy is necessary but please ensure that both partners names are on the document. Please use the
following ZIP file naming scheme when submitting your code:
If you did the assignment alone then name the ZIP file <lastname>-<firstname>-ALONE.zip
o e.g. SMITH-JOHN-ALONE.zip
If you did the assignment with a partner, then include both partners full names in the ZIP file name
o e.g. SMITH-JOHN-JONES-PETER.zip (where John Smith and Peter Jones worked on it together)
o only one of the partners needs to submit the ZIP file
Question 1
Using the information contained in Table 4-10 (page 50) of the 6808 instruction manual in Module-07 of eConestoga. Using the code provided below
(which you may remember as an example used in Module-08) please create:
Complete the information in this table for LINE-02, LINE-03, LINE-06, LINE-10, LINE-14, LINE-19 and LINE-21 of the following code. This table
will look similar in format and content to those shown in Module-09 on slides 13, 14, 15 and 16.
NOTE: In order to do these calculations youll need to analyze all of the lines of code as to their addressing mode and # of clock cycles, but all
you need to record in Table 1.2 are the items requested above.
Question 2
At the end of this document some C source code. Transform the program from the C code into assembly for the 6808 Microcontroller. Remember when
converting this C code to follow best practices covered in DEF in terms of implementing subroutines in assembly
NOTES:
1. You may be able to re-use some of your assembly code from Assignment 06 here like I say in SEF, code re-use is a good thing!
2. Keep in mind that once your translated this program into assembly you can step through it to ensure that it behaves correctly and calculates
the expected results. Try executing your assembly program with different starting values
3. Remember to properly comment your final assembly code (with header comments and line comments if you like, you can re-use the
comments that Ive provided in the C program! Comment re-use who ever thought of that ?!? )
4. In your hardcopy submission format your final commented assembly code as I did in the sample code from Question 1.
#include <stdio.h>
#include <string.h>
/* =======================================================================================
The purpose of this program is to perform a "magical" number trick ...
Tell someone to pick a random number between 1 and 15 and you will get
them to do some simple math using that number ... at the end of the trick,
you will tell them what number they ended up at. The answer will ALWAYS be
3!!
ANSWER: 3!!!
====================================================================================== */
void main(void)
{
int originalSecretNumberPicked = 8; // choose number between 1 and 15 - found at $80 in the 6808
int intermediateCalc = 0; // if you want / need to store this number - place it at $81
int finalAnswer = 0; // store the final result at $84 in the 6808
intermediateCalc = squareIt(originalSecretNumberPicked);
// STEP 2
intermediateCalc = addThem(intermediateCalc, originalSecretNumberPicked); // STEP 3
intermediateCalc = divideNumOneByNumTwo(intermediateCalc, originalSecretNumberPicked); // STEP 4
Fall 2015 Due: Dec 11, 2015
Page 5 (by 2:00pm End of the last Lab)
Digital Engineering Fundamentals
Assignment 7
intermediateCalc = addThem(intermediateCalc, 17);
// STEP 5
intermediateCalc = addThem(intermediateCalc, -originalSecretNumberPicked); // STEP 6
// is your answer 3 ?!?! Pick another starting number and try again ...
/* -------------------------------------------------------- */
/* The following three functions are simple supporting */
/* mathematical functions - for SQUARING a number, ADDING */
/* two numbers together and DIVIDING one number by another */
/* -------------------------------------------------------- */
int squareIt(int numToSquare)
{
return(numToSquare * numToSquare);
}