Mysteries revealed and solved
- Comparing values
- Multiple word arithmetic
- Instructions:
addc
, subb
, cpb
- Carry is
C
- Borrow is
-C
Z
is sticky and can only be cleared
- Tens complement — Wikipedia or YouTube
- Storing large constant arrays
- Data memory size is much smaller than program memory size
- In the PIC24HJ64GP502: 128KB of program memory & 8KB of data memory
- But data addresses are 16 bits long 64KB to be accessed
- Initialize global data by copying from program memory
- Multiplication
- Two registers can be muliiplied and stored into a two successive registers
- Signed and unsigned multiplication requires different instructions
- A 17⨯17 bit hardware multiplier is used.
- Division
- Requires use of
REPEAT
instruction
- The
DIV
instruction must be executed 18 times
- Requires 19 clock cycles, but may be interrupted
- Uses a non-restoring algorithm
- C Preprocessor magic
- PIC processor restart
- Making better music