int main by bQ1Bs1q

VIEWS: 4 PAGES: 2

									                                      ENCM415 Assignment 3

                                  Practice for Post-Lab. Quiz 1
There is no due date or marks. However completely this assignment effectively gives you around 1.5% on the term
                            mark as it requires completing Tasks, 1, 2 and 3 of Lab. 2


In Task 1 of Lab. 2, you are asked to make a main( ) function for Lab. 2 and cut-and-paste the code shown on the
next page.


Then in a new file "picturecontrolCPP.cpp" in your Lab. 2 directory you need to build the C++ functions

           o   void StartPictureCommand(void); changes the volatile variable start_picture_again defined in
               main.cpp (meaning its external to this file) to 1 when switch 1 is held down and then released.
           o   void NextLineCommand(void); changes the volatile variable next_line to 1 when switch 2 is held
               down and then released.

Then in Task 2, you are asked to set up a test environment which, in Task 3, is used to test the two new C++
functions void StartPictureCommand(void) and void NextLineCommand(void)



You are now going to use a test driven development approach to developing the functions void
StartPictureCommandASM(void) and void NextLineCommandASM(void)

Q1. Tests to be built first. Make copies of the tests for void StartPictureCommand (void) and void
NextLineCommand (void)— see Task 3 – and change so that these tests would validate void
StartPictureCommandASM(void) and void NextLineCommandASM(void)

Q2. Build the stubs for void StartPictureCommandASM(void) and void NextLineCommandASM(void) – you can’t
look at “any book or reference sheet” once you have start the coding – you are doing this under “EXAM
CONDITIONS”. Using the tests from Q1 to check that the stubs work properly as stubs.

Q3. Write just enough code (in assembly) to satisfy all the tests for void StartPictureCommandASM(void) and void
NextLineCommandASM(void)

Q4 – if you want a “LOT” of practice in writing assembly code for the first quiz

Remove Lab2main.cpp from your Lab2 project and write (then test) Lab2mainASM.asm, the assembly language
version of the code in Lab2main.cpp

Note you function must be _main_namemangle – the same function name as produced by the compiler for main( )
main( )is as follows

volatile long int next_line = 0;
volatile long int start_picture_again = 0;

#define NUM_PICTURE_LINES 7
long int picture_Letter_A[NUM_PICTURE_LINES] = {
  0x04,        // __*__
  0x1B,        // **_**
  0x11,        // *___*
  0x1F,        // *****
  0x11,        // *___*
  0x11,        // *___*
  0x11};       // *___*

void StartPictureCommand(void);
void NextLineCommand(void);

int main( ) { // NOTE -- there is NO code here about the audio control that was present in main( ) in Lab. 1

long int switch_result = 0;
Initialize_ProgrammableFlagsASM( ); // Initialize PF8, PF9, PF10 and PF11 as input lines -- SMOKE WARNING
InitializeLEDInterfaceASM( );  // Initialize the LED interface

while (1) {
     start_picture_again = 0;
     while (start_picture_again == 0) StartPictureCommand( );
     // remember variable start_picture_again is VOLATILE
    // so it can be changed "outside" of this function -- changed inside StartPictureCommand( );

     WriteLEDASM(0); // Clear the TV screen -- all LEDs OFF

      // Set a pointer to point to the bit pattern that is the first line in the TV
     long int *picture_pointer = &picture_Letter_A[0]; // same as long int *picture_pointer =
picture_Letter_A;


     // Now display the picture on the "SMALLEST TV SCREEN IN THE WORLD"
     for (int count = 0; count < NUM_PICTURE_LINES; count++) {
        next_line = 0;
        while (next_line == 0) NextLineCommand( ); // remember next_line is VOLATILE
        WriteLEDASM(*picture_pointer++);           // Show the next line in the picture
    }
}

								
To top