Hi All,
What is the C equivalent function to the Spectrum basic IN and OUT:?
Regards
Dodger
What is the C equivalent function to the Spectrum basic IN and OUT:?
The best way to do it it to use the __sfr syntax, for 8 bit ports this is:
And for 16 bit io:
The syntax is supported by both compilers and the IO access is inlined.
Code: Select all
__sfr __at 0x1f IO8;
int x = IO8; // Reads port 0x1f
...
IO8 = 2; // Writes 2 to port IO8
Code: Select all
__sfr __banked __at 0xfff3 IO16;
...
int x = IO16; // Reads port 0xfff3
IO16 = 2; // Writes 2 to port IO16