Assembler code in ASCII C?

Door coldbreeze

Expert (127)

afbeelding van coldbreeze

15-03-2009, 06:59

Does ASCII C allow putting Assembler blocks in otherwise C source code? If so, what is the syntax?

(I am using ASCII MSX-C v1.20p)

Aangemeld of registreer om reacties te plaatsen

Van dvik

Prophet (2200)

afbeelding van dvik

15-03-2009, 15:23

The ASCII C standard does not specify how do do assembler code in C code, but most (all) compilers provide inline assembly but the syntax and calling convensions are different depending on compiler and target.

Van SLotman

Paragon (1239)

afbeelding van SLotman

15-03-2009, 23:51

Would it be something like ASM { code }; ? I remember seeing it a long time ago, not sure if it was to ASCII C or other C compiler...

Van Alex

Master (205)

afbeelding van Alex

15-03-2009, 23:54

I don't believe ASCII MSX-C supports this. What I usually do is put the assembly code in a separate source which I compile with gen80. The functions can then be invoked from the C source code and the C module and the assembly module can be linked together with l80. I don't remember the calling convention by heart for parameters that are passed to the functions. I do remember though that parameters must be returned in registers; A for functions that are declared to return a byte/char and HL for functions that are declared to return an int or a pointer.

Van coldbreeze

Expert (127)

afbeelding van coldbreeze

16-03-2009, 01:31

I have not come across any evidence that ASCII MSX-C supports ASM inclusions, hence the original question.

Alex, is there any way you could check as to what the calling convention is in ASCII MSX-C for externally compiled binary? (BTW, I also use gen80 on MSX, and sjasm when I compile my Assembler code on a PC).

Van dvik

Prophet (2200)

afbeelding van dvik

16-03-2009, 03:24

Sorry, I thought you meant ANSI C, not ASCII C. I never used ASCII C so I have no idea if it supports inline assembly. Both HiTech C and sdcc support inline assembly and their respective documentation details the calling conventions.

Van MicroTech

Champion (385)

afbeelding van MicroTech

16-03-2009, 11:12

Afaik there is no way to use inline assembly with ASCII-C.
As Alex suggests you should put your asm code in an external module, assemble it and link it to the "C compiled" part.
Some time ago I found on the net a msxCMan.htm file explaining (also) calling conventions, if you wish I can send you.
Did you already check here?

@Alex: files ascii-c1.pma, c2 and c3 on MSX Plaza are not reachable, could you check and/or eventually send them to me, please?
Thanks

Van coldbreeze

Expert (127)

afbeelding van coldbreeze

16-03-2009, 16:10

I suspected it to be the case.

I would greatly appreciate if you could email me msxCMan.htm file with the calling conventions to:
bk.7.coldbreeze@spamgourmet.com

Many thanks!

Van MicroTech

Champion (385)

afbeelding van MicroTech

17-03-2009, 10:16

You should have mail...

Van coldbreeze

Expert (127)

afbeelding van coldbreeze

18-03-2009, 11:13

Yes, I have received your email. Thank you very much for the document and your tips on how to bind the C code with Assembly! This is exactly what I have been looking for.