Closed znhocn closed 5 years ago
well disregard last comment, I am not sure that vscode understands sfr/sbit syntax either...
@zerog2k
I think VSCode understands the __sfr/__sbit
syntax. I tried it and there is no error.
There are two syntaxes __sfr/__sbit
and SFR()/SBIT()
in the header file provided by SDCC.
C:\Users\<name>\.platformio\packages\toolchain-sdcc\include\mcs51\
I am not sure which syntax is better.
Why do I use SFR()/SBIT()
syntax ?
Because it's easier to modify from the STC original header.
STC Original Header:
sfr ACC = 0xE0;
sfr B = 0xF0;
sfr PSW = 0xD0;
sbit CY = PSW^7;
sbit AC = PSW^6;
sbit F0 = PSW^5;
sfr P4 = 0xC0;
sbit P40 = P4^0;
sbit P41 = P4^1;
sbit P42 = P4^2;
sbit P43 = P4^3;
The STC original header is used in the keil compiler and cannot be used in SDCC.
Thanks!
@znhocn regarding the stc specific headers, I wonder if using a different declaration format would make it easier for editors like vscode to manage c intellisense better. I think this worked better for me https://github.com/zerog2k/stc_diyclock/blob/master/src/stc15.h
e.g. using
instead of
Not sure which is the preferred way, but I think for some reason vscode doesnt like these SFR/SBIT/etc macro style for discovering declarations of sfrs, etc.