Common Programming Errors in Program 2 and Suggestions on How to Fix Them

    1. If you need to use a constant like 16 or x3300 in the program, you cannot assume that it exists in a partiular memory location. You can use the locations just following the TRAP x25 to store constants, and use the LD instruction to load these values.

    2. Registers may not have the value 0 when the program starts execution - clear them using AND R0, R0, #0 before using them as source operands in any instruction

    3. Every program needs to have a TRAP x25 instruction to stop execution.

    4. If you need to set the condition codes depending on the value in a certain register (so that a branch instruction can follow), you can use:

       This is a better option than storing a register to memory & loading it back to set the condition codes.