Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimization #476

Closed
SaymanNsk opened this issue Mar 22, 2024 · 4 comments
Closed

optimization #476

SaymanNsk opened this issue Mar 22, 2024 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@SaymanNsk
Copy link

what about register optimization? When calling some functions, it is not necessary to perform a series of pushes. if this is not dynamic loading of arguments or if this is not a large number of arguments, then they can be passed in registers. I would also like to see the assembly in the form of an asm text file. for example, to evaluate code, its correctness and optimality. To be honest, right now this compiler is not very usable.
In addition, there is no possibility to create “custom” load options and usability (for other systems).

@drcjt
Copy link
Owner

drcjt commented Mar 23, 2024

Thanks for your interest in this project.

Firstly the compiler does produce asm text files, look for files called .dasm in the output folders, for example CSharp-80\Samples\CalcPi\bin\Trs80\Debug\net8.0\CalcPi.dasm. The compiler works by producing assembly code which is then assembled by a z80 assembler. The list file from the assembler is also produced in the output folders, e.g. CSharp-80\Samples\CalcPi\bin\Trs80\Debug\net8.0\CalcPi.lst

Using registers rather that the stack to hold local variables, intermediate calculations etc.. is something I have considered. However, the z80 processor has a very limited set of registers and almost every non trivial method would likely end up having to spill data stored in the registers a lot. Note that the compiler will pass parameters in registers in certain limited cases such as when calling intrinsic methods. It is likely that I'll look at inlining before register allocation as this will have much more impact on the ability to use very small methods in C#.

It's not clear to me what you mean by "custom" load profiles? There are some compiler options - see the details in ConfigurationOptions class.

The compiler is quite usable for the use cases as described in the main readme as is demonstrated by the samples including fully functioning snake game and wumpus game that work on the TRS-80. I'm not sure what you were expecting to be able to accomplish with an 8-bit processor and 64k of addressable RAM but to be honest the compiler has far surpassed what I expected would be possible.

@SaymanNsk
Copy link
Author

Modern 8bit computers have memory more than 64kb. ZX-Sprinter (Sprinter-2000) have 4096kb. Or ZX-Evo have 4096kb too. With MMU. 16kb pages (256 pages).
ZX-Spectrum 128 have 128kb of RAM, with 0x7ffd memory port for switch pages in 3 cpu window (0xc000 - 0xffff area).
How i can use this MMU`s in your compiler?

@drcjt
Copy link
Owner

drcjt commented Apr 19, 2024

@SaymanNsk, CSharp-80 doesn't currently have any support for bank switching or other advanced memory models. I have added some information about the memory map here - https://github.com/drcjt/CSharp-80/wiki/Memory-Models.

@drcjt
Copy link
Owner

drcjt commented Apr 19, 2024

@SaymanNsk I've added two separate issues for register allocation and advanced memory models:

@drcjt drcjt self-assigned this Apr 19, 2024
@drcjt drcjt added the question Further information is requested label Apr 19, 2024
@drcjt drcjt closed this as completed Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants