Lab 3: 8/16 Bit Assembly Language Programming

This lab has you convert a C program that performs 8/16-bit unsigned operations into PIC24 assembly language. 

Basics

Be sure:

  if (u16_b & 0x0100) { 

    u16_a = u16_b + u8_c;

    u16_b = u16_a - u16_b;

  } else {

    u16_b = u16_a - u16_b;

    u16_a = ~u16_b;

  }

  u8_c = u8_c + 0x5;

  u8_e++;

}

Test started.

 a:34af, b:29fe, c: a458, d:45, e:00 is correct; saw

a1:0000, b1:0d60, c1: 0000, d1:00, e1:00 FAIL

 a:34af, b:0d70, c: 522c, d:45, e:01 is correct; saw

a1:5201, b1:0d64, c1: 0001, d1:58, e1:01 FAIL

...

Prelab (20 points)

Like this (for example.s)

Variable declarations from example.s

From example.s

Pre-lab checkoff

Task 1 (60 points)

From case3.s. At the top, u8_e has been moved into W4. You'll need to put the other variables into the designated registers. Replace the highlighted line that says "Your code goes here". HINT: You might want to do your 8-bit variables first.

From example.s. You only need two labels for this code. 

HINT: If you put your labels all the way to the left, they'll be easier to find.

Note that we're actually checking if A is not greater than B. If A>B, we want to keep going, so we don't need another branch and another label.

PASSing the tests

Once you have all your assembly written, and gotten your program to build without errors, now is the time to examine the UART Output Window. Probably you're seeing a lot of FAIL. Don't worry. 

TA Checkoff

Show the TA something like this for your assigned case (60 pts):

FINALLY

Once you've been checked off:

4. Debug and get a screenshot of your watched variables. They should contain the same values as in the last iteration of your program from the previous screenshot.

Report

0.

Submit: