[MSX-C] Q&A official thread

Pagina 49/57
42 | 43 | 44 | 45 | 46 | 47 | 48 | | 50 | 51 | 52 | 53 | 54

Van ARTRAG

Enlighted (6832)

afbeelding van ARTRAG

29-10-2016, 10:33

Actually, the ASM code has many points where it is easy to do much better, look e.g. at the loops with char indexes.
Nevertheless, when one passes pointers to functions it seems quite efficient and clean (look at the FSM() code)

Van Manuel

Ascended (18744)

afbeelding van Manuel

29-10-2016, 10:40

We haven't changed anything about symbol file support in quite a while...

Van ARTRAG

Enlighted (6832)

afbeelding van ARTRAG

29-10-2016, 10:46

As I've left Hitech C apart for a while (2/3 years) it is possible that the problem has appeared in previous updates of the debugger....
BTW I've opened a issue on github, sorry for the offtopic

Van DarkSchneider

Paladin (942)

afbeelding van DarkSchneider

31-10-2016, 09:43

ARTRAG wrote:

For the sake of comparison, this is a sample code developed for Hitech-C (cross compiler v7.8pl2) with its compiled counterpart. Look at the LST files to see the generated code.
This is the main file compiled (LINK).
Could someone try to compile it in MSX-C and post the ASM?
https://github.com/artrag/C-experiments-for-msx

Manuel, the SYM file seems not supported anymore by the last openmsx debugger.
Is this a problem of mine or a real issue in the last openmsx release?

Hi, for MSX-C the libs and functions are different. Even does not exist sys.h nor msxio.h. Don't know what is setvdpwvram(), there is no loadvrampalette()... Also there is no enum in K&R.

Do you have the equivalences?. I could simply define them to get the asm code.

Already adapted defining the functions. Here the whole folder:
https://dl.dropboxusercontent.com/u/56103320/Files/MSX/disk_artrag.zip
demofsm.c - the code as is adapted.
demofsm.mac - the ASM result.
demofsmc.c - the MSX-C optimized version.
demofsmc.mac - the MSX-C optimized ASM result.

The MSX-C optimized changes FOR by WHILE and all possible INT to UINT to avoid signed math, both cases involving functions calling.

Van Wolverine_nl

Paragon (1159)

afbeelding van Wolverine_nl

31-10-2016, 09:29

@DarkSchneider: forgot to tell the struct typedef thing worked fine, but it is kinda linear in its usage, tried to use it within a function, but it gave error that it wasn't declared. So i put it globally declared.

@ARTRAG: What DarkSchneider says is true, and you can create a seperate lib for those different functions.

Van ARTRAG

Enlighted (6832)

afbeelding van ARTRAG

01-11-2016, 08:27

Thanks for compiling my test file
It seems that msx-c does not use ix and it at all.
The functions accepting pointers to structs can become very large and potentially inefficient if you use only HL and ADD/SBC

Van DarkSchneider

Paladin (942)

afbeelding van DarkSchneider

01-11-2016, 09:28

ARTRAG wrote:

Thanks for compiling my test file
It seems that msx-c does not use ix and it at all.
The functions accepting pointers to structs can become very large and potentially inefficient if you use only HL and ADD/SBC

I didn't used another "trick" for MSX-C involving pointer parameters. Define a static struct *local = parameter and use that local. Also use statics when variable is much used to avoid stack access (slow because the add HL and add SP, HL etc.).
Updated:
https://dl.dropboxusercontent.com/u/56103320/Files/MSX/disk_artrag.zip
Functions interact and fsm modifired with that. Files are demfsmc2.c and demfsmc2.mac.

It is usual C compiled ASM to have some more lines than handmade code. But in the real usage there is not noticeable impact. Having +60K cycles per interrupt, a few lines are not really a concern in practice. There are other worries like some work within loops to avoid and things like that. ASM lines involving registers are not really much a burden.

Even is an interesting note about no usage of IX and IY. Probably a compiler made for 64KB has no room for that logic.

Van ARTRAG

Enlighted (6832)

afbeelding van ARTRAG

01-11-2016, 11:35

DarkSchneider wrote:

Even is an interesting note about no usage of IX and IY. Probably a compiler made for 64KB has no room for that logic.

Even the cp/m version of the Hi-tech compiler supports IX and IY. I'd rather say that it is an indication of the age of the compiler, probably derived by an 8080 product.

Van DarkSchneider

Paladin (942)

afbeelding van DarkSchneider

01-11-2016, 14:20

ARTRAG wrote:
DarkSchneider wrote:

Even is an interesting note about no usage of IX and IY. Probably a compiler made for 64KB has no room for that logic.

Even the cp/m version of the Hi-tech compiler supports IX and IY. I'd rather say that it is an indication of the age of the compiler, probably derived by an 8080 product.

Good to know. What I miss is the fast calling convention for functions. See table 12 here:
http://msx.hansotten.com/index.php?page=msx-c-manual
Hi-tech if I am not mistaken always uses the stack. I'd like to use registers for few params functions. For both speed and integration with ASM made functions.

How is the ASM generated by the CP/M version for that code?

Van ARTRAG

Enlighted (6832)

afbeelding van ARTRAG

01-11-2016, 14:35

The Hi-tech C passes the function parameters using registers when you use ansi c definitions and the stack when you use old k&r definitions.
I do not have the cp/m version anymore, I cannot compile sorry

Pagina 49/57
42 | 43 | 44 | 45 | 46 | 47 | 48 | | 50 | 51 | 52 | 53 | 54