Let's go for a very general question.
Question: Somebody knows the sintaxis to insert asm code into a C program?
Yes, it's all very well explained in pages 54-60 of the MSX-C manual. Now we're getting into the main reason why I prefer the MSX-C compiler to alternatives like Hitech-C or SDCC: the way it passes parameters during function calls.
This is a subject that will take a bit longer to explain, but it's not complex. I will prepare some quick demo code tonight or tomorrow after I finish work, and I'll write a more detailed article for the blog a few days/weeks later.
I agree MSX-C is best choice to develop. I have seen codes made in hitech, sdcc or solidc and they are different! Some of them has partial implementations of msx lib but even function names are different so it is no a standard way of learning MSX-C. I think that so much dispersión is not good, the best way to learnc C is with a common base. At this point of the thread I hope that anyone following the thread will be convinced to use MSX-C. All codes attached are designed for it!
JaviLM: any idea why they used non-standard things like VOID (in capitals) and TINY (instead of char or something)? What else is non-standard compared to 'normal' C programs (besides the K&R style stuff)?
JaviLM: any idea why they used non-standard things like VOID (in capitals) and TINY (instead of char or something)? What else is non-standard compared to 'normal' C programs (besides the K&R style stuff)?
Actually, the underlying language is standard C. Those types are just typedefs defined in types.h:
If you prefer to use the standard types then you're perfectly able to do so:
However, the MSX-C standard library and the extended MSX-C Library disk use this syntax with types in uppercase, so I personally prefer to go with the same syntax.
Why did they choose to define those types in uppercase? No idea, but probably to make them stand out from the standard types in the language.
It usually allows to port the code across different compilers or platforms where standard C types have been implemented with different sizes. Anyway I doubt ASCII will release other versions of its compiler with different implementations for C types
Because there was no chance for it. But it is a good practice to use typedefs.
Um, any idea why VOID is a typedef for int?
That does mean VOID is something quite different than regular void...
Um, any idea why VOID is a typedef for int?
That does mean VOID is something quite different than regular void...
Surely it returns a predefined value as NULL. Some cross compilers as sdcc needs return statement even in void functions. You simply puts return; in order to indicate method finished.
A void method has no return value, which means nothing needs to be returned as it will not be used by the caller anyway.
Needing a return statement in void functions is violating the C language spec, isn't it? The compiler can know the function ended, because the matching brace was encountered while parsing the code... Anyway, I don't think this is related to the VOID being a char. (I said int in my previous post, but I meant char of course... sorry for the confusion.)
Um, any idea why VOID is a typedef for int?
That does mean VOID is something quite different than regular void...
Support for void functions was added to the C language after K&R, and after MSX-C was released.
In the MSX-C V1.2 User's Manual, page 72, it says that ...the soon-to-be-standard ANSI includes useful types such as void... ...those types are declared for the convenience of the programmer.