Cog Resources
TODO
Cog Memory
Each Cog has 512 longs (= 2 kiB) of Cog RAM. The first 496 can be used for any purpose, the next 8 have some special purposes and the final 8 are hardware I/O registers. The normal RAM locations are also often referred to as "Registers" due to them being directly addressible by most instructions.
| Address (Dec) | Address (Hex) | Symbol | Description |
|---|---|---|---|
| 0 - 495 | $000-$1EF | Normal RAM | |
| 496 | $1F0 | IJMP3 | INT3 call address |
| 497 | $1F1 | IRET3 | INT3 return address |
| 498 | $1F2 | IJMP2 | INT2 call address |
| 499 | $1F3 | IRET2 | INT2 return address |
| 500 | $1F4 | IJMP1 | INT1 call address |
| 501 | $1F5 | IRET1 | INT1 return address |
| 502 | $1F6 | PA | Used with CALLPA, CALLD and LOC |
| 503 | $1F7 | PB | Used with CALLPB, CALLD and LOC |
| 504 | $1F8 | PTRA | Pointer A register |
| 505 | $1F9 | PTRB | Pointer B register |
| 506 | $1FA | DIRA | I/O port A direction register |
| 507 | $1FB | DIRB | I/O port B direction register |
| 508 | $1FC | OUTA | I/O port A output register |
| 509 | $1FD | OUTB | I/O port B output register |
| 510 | $1FE | INA | I/O port A input register |
| 511 | $1FF | INB | I/O port B input register |
Note that the interrupt call/return locations can be used for other purposes when the respective interrupt is not in use.
Similarily, PTRA/PTRB/PA/PB are normal general-purpose registers aside from their special uses.
Q Register
Each Cog contains a hidden "Q" register that is used for certain operations.
The following instructions can set Q:
- SETQ and SETQ2: Q is set to the given D value.
- XORO32: Q is set to the XORO32 result.
- RDLUT: Q is set to data read from lookup memory.
- GETXACC: Q is set to the Goertzel sine accumulator value.
- CRCNIB: Q is shifted left by 4 bits.
- COGINIT/QDIV/QFRAC/QROTATE: Q is set to 0 if executed without SETQ.
The current Q value can be read (ab)using MUXQ as such:
MOV qval,#0 'reset qval
MUXQ qval,##$FFFFFFFF 'for each '1' bit in Q, set the same bit in qval