[MSX-C] Q&A official thread

صفحة 7/68
1 | 2 | 3 | 4 | 5 | 6 | | 8 | 9 | 10 | 11 | 12

بواسطة anonymous

incognito ergo sum (116)

صورة anonymous

31-08-2015, 23:54

AxelStone wrote:

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.

بواسطة AxelStone

Prophet (3199)

صورة AxelStone

01-09-2015, 09:49

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!

بواسطة Manuel

Ascended (19691)

صورة Manuel

01-09-2015, 23:20

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)?

بواسطة anonymous

incognito ergo sum (116)

صورة anonymous

02-09-2015, 03:40

Manuel wrote:

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.

بواسطة ARTRAG

Enlighted (6980)

صورة ARTRAG

02-09-2015, 08:19

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

بواسطة DarkSchneider

Paragon (1030)

صورة DarkSchneider

02-09-2015, 11:16

Because there was no chance for it. But it is a good practice to use typedefs.

بواسطة Manuel

Ascended (19691)

صورة Manuel

02-09-2015, 20:27

Um, any idea why VOID is a typedef for int?

That does mean VOID is something quite different than regular void...

بواسطة AxelStone

Prophet (3199)

صورة AxelStone

02-09-2015, 21:06

Manuel wrote:

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.

بواسطة Manuel

Ascended (19691)

صورة Manuel

02-09-2015, 21:25

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.)

بواسطة anonymous

incognito ergo sum (116)

صورة anonymous

03-09-2015, 03:45

Manuel wrote:

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.

صفحة 7/68
1 | 2 | 3 | 4 | 5 | 6 | | 8 | 9 | 10 | 11 | 12