C86 Compiler
The error messages the compiler gives when you forget this are a bit ambiguous. For example, if I declare a variable "int i;" in the middle of a function, the compiler simply reports the error "unexpected symbol 'i' found".
For example, instead of
Write the function like this:void MyFunction(void) { Func1(); /* BAD! Don't put code before variable declarations. */ int j; . . for(int i = 0; i < 100; i++) Func2(); /* BAD! Don't declare i here. */ char c = 'X'; /* BAD! Don't declare c here. */ . . }
void MyFunction(void) { int j; /* GOOD! All declarations go here. */ int i; char c; Func1(); /* GOOD! Start code after declarations. */ . . for(i = 0; i < 100; i++) Func2(); /* GOOD! Declaration for i not in for(). */ c = 'X'; /* GOOD! Don't initialize c here. */ . . }
result = 10 - myVAr / myNum; /* BAD!! */
Break it up as:
result = myVar / myNum;
result = 10 - result;
int result; long bigNumber; ... result = (int)bigNumber / 3; /* BAD!! */Do the following:
int result; long bigNumber; ... result = (int)bigNumber; result = result / 3;
NASM
Emu86