The following is a PIC24 assembly language primer. It's designed to give you the information you need to ace the programming problems on the exams.
Since it is a summary of the ebook, it will help you with the homework, but it doesn't contain all the concepts or cover them in as much depth. For example, the ebook discusses defining variables and reserving space for them in memory, while the exam questions don't.
It will also be helpful for Labs 2-5, but likewise, there are differences between coding in the lab and in the ebook/tests. In the labs:
you always have to define variables and use the .space directive (this is sometimes already done in the ebook exercises)
you will be able to use the MPLAB debugger and view register contents
you will need to deal with MPLAB annoyances like cryptic errors and project/file management
On Exam 1, 2, and the final exam, you will have to translate C code into assembly. On Exam 2, some of the programming problems will probably be prefixed by questions about the contents of various registers and memory locations. On the final you may have an I2C coding question which is in C. Those subjects (Pointers and I2C) will be covered in the Exam Topics section.
On the exams, you're given a problem like this:
Then you're presented with a blank box surrounded by boilerplate code that you can ignore, like this:
You type your answer in the box, then click the save and run button. If you do a good job, you get this:
If not, you get this:
Or worse, your code doesn't compile at all:
To make the box bigger, click on the triangle in the lower right corner and drag it down. The results box has a similar triangle.
In the labs, you will be using the RIPO (Register Assignment / Input / Process / Output) method. For each line of C code, you:
; REGISTER ASSIGNMENTS
;; C code goes here
; INPUT
move the variables to registers
; PROCESS
do calculations and stuff with the registers
; OUTPUT
move the results of the calculation to the answer variable (in the above problem u16_a)
This is a very good method, but you obviously don't need to write "INPUT" "PROCESS" and "OUTPUT" on the test, since the automatic grader* doesn't care. I would just put a blank line between the different sections.
You can be as sloppy with your coding as you want, but saving a few seconds of typing at the expense of getting all muddled up on the problem isn't worth it, IMO. Just because you don't need to put in comments, you might want to use them to keep things straight, especially with more complicated problems involving lots of branching.
Assembly is case-insensitive, but C is not. So feel free to write "W2" or "w2", "MOV" or "mov" or even "mOv", but do not "U16_A" or you'll fail.
It's possible to solve the coding problems in a variety of clever ways:
only using one or two registers
doing some operations directly on memory locations rather than moving variables to registers
using one or two operand instructions that aren't covered well in class, like MOV W1
But since you don't get style points, there's no reason to strive for efficiency or try to conserve keystrokes.
*All exam programming answers will be reviewed by a human.