PIC16C - Language spec considers certain RAM to be shared between banks, but this isn't true of all processors #8212
Labels
Feature: Processor/PIC
Status: Triage
Information is being gathered
Type: Bug
Something isn't working
Describe the bug
The PIC16 language specification includes the following comment and code:
https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Processors/PIC/data/languages/pic16_instructions.sinc#L166-L170
These processors have multiple RAM banks, selected by bits in the status register. On some processors, the top 16 bits are shared (that is, 0x70 in bank 0 and 0xf0 in bank 1 point to the same register). However, this isn't true for all processors in this series. Page 22 of the manual available at https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/30390e.pdf shows that this is true only for the PIC16C76/77. For the PIC16C73/73A/74/74A, 0x70 and 0xf0 are separate registers, and for the PIC16C72 it is irrelevant because the last implemented memory address is 0xBF.
To Reproduce
Steps to reproduce the behavior:
BSF STATUS, RP0
,CLRF 0x70
Expected behavior
The instruction is interpreted to affect memory location 0xF0
Environment (please complete the following information):
Additional context
I commented out the snippet of code mentioned above and restarted Ghidra. The decompilation view now shows that the correct memory variables are being affected. The listing view shows that the instruction is still affecting the incorrect label:
After selecting "Patch Instruction", pressing "Enter" twice without making any changes, and re-running Analysis, the listing view and instruction info are correct (TP3 is the label for data location 0xF4, and note that the "Address" in the right pane of the instruction info screen is also now correct.) Re-running analysis without first patching the instruction did not fix the address.
The text was updated successfully, but these errors were encountered: