remote TABs in doc/ and test/
This commit is contained in:
@@ -127,17 +127,17 @@ and predecrement operators if you don't need the resulting value. That means,
|
||||
use
|
||||
|
||||
<tscreen><verb>
|
||||
...
|
||||
++i;
|
||||
...
|
||||
...
|
||||
++i;
|
||||
...
|
||||
</verb></tscreen>
|
||||
|
||||
instead of
|
||||
|
||||
<tscreen><verb>
|
||||
...
|
||||
i++;
|
||||
...
|
||||
...
|
||||
i++;
|
||||
...
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
@@ -148,24 +148,24 @@ The compiler produces optimized code, if the value of a pointer is a constant.
|
||||
So, to access direct memory locations, use
|
||||
|
||||
<tscreen><verb>
|
||||
#define VDC_STATUS 0xD601
|
||||
*(char*)VDC_STATUS = 0x01;
|
||||
#define VDC_STATUS 0xD601
|
||||
*(char*)VDC_STATUS = 0x01;
|
||||
</verb></tscreen>
|
||||
|
||||
That will be translated to
|
||||
|
||||
<tscreen><verb>
|
||||
lda #$01
|
||||
sta $D601
|
||||
lda #$01
|
||||
sta $D601
|
||||
</verb></tscreen>
|
||||
|
||||
The constant value detection works also for struct pointers and arrays, if the
|
||||
subscript is a constant. So
|
||||
|
||||
<tscreen><verb>
|
||||
#define VDC ((unsigned char*)0xD600)
|
||||
#define STATUS 0x01
|
||||
VDC[STATUS] = 0x01;
|
||||
#define VDC ((unsigned char*)0xD600)
|
||||
#define STATUS 0x01
|
||||
VDC[STATUS] = 0x01;
|
||||
</verb></tscreen>
|
||||
|
||||
will also work.
|
||||
@@ -182,14 +182,14 @@ Initialization of local variables when declaring them gives shorter and faster
|
||||
code. So, use
|
||||
|
||||
<tscreen><verb>
|
||||
int i = 1;
|
||||
int i = 1;
|
||||
</verb></tscreen>
|
||||
|
||||
instead of
|
||||
|
||||
<tscreen><verb>
|
||||
int i;
|
||||
i = 1;
|
||||
int i;
|
||||
i = 1;
|
||||
</verb></tscreen>
|
||||
|
||||
But beware: To maximize your savings, don't mix uninitialized and initialized
|
||||
@@ -201,18 +201,18 @@ variables, you force the compiler to allocate space for the uninitialized
|
||||
variables each time, it parses an initialized one. So do this:
|
||||
|
||||
<tscreen><verb>
|
||||
int i, j;
|
||||
int a = 3;
|
||||
int b = 0;
|
||||
int i, j;
|
||||
int a = 3;
|
||||
int b = 0;
|
||||
</verb></tscreen>
|
||||
|
||||
instead of
|
||||
|
||||
<tscreen><verb>
|
||||
int i;
|
||||
int a = 3;
|
||||
int j;
|
||||
int b = 0;
|
||||
int i;
|
||||
int a = 3;
|
||||
int j;
|
||||
int b = 0;
|
||||
</verb></tscreen>
|
||||
|
||||
The latter will work, but will create larger and slower code.
|
||||
@@ -228,17 +228,17 @@ common cases.
|
||||
Don't use
|
||||
|
||||
<tscreen><verb>
|
||||
char* a;
|
||||
char b, c;
|
||||
char b = *(a + c);
|
||||
char* a;
|
||||
char b, c;
|
||||
char b = *(a + c);
|
||||
</verb></tscreen>
|
||||
|
||||
Use
|
||||
|
||||
<tscreen><verb>
|
||||
char* a;
|
||||
char b, c;
|
||||
char b = a[c];
|
||||
char* a;
|
||||
char b, c;
|
||||
char b = a[c];
|
||||
</verb></tscreen>
|
||||
|
||||
instead.
|
||||
|
||||
Reference in New Issue
Block a user