Hi,
I've been thinking about developing a pre-assembler, or compiler that products fasm code.
I've thought of a few features that I think would be useful for developing programs in an (almost) assembly language, but I'm not sure whether it is worth doing it.
The main feature is register allocation. My idea is to allow programs to be written with an unlimited amount of registers (ie. not needing to worry about which registers are being used by sections of code and therefore not having to save/restore or re-write code when the use of registers change). The compiler would determine when a register needs to be saved/restored to/from the stack or global variables.
For example, say you write a macro that prints out a string using certain registers and you use that macro everywhere in your code. If you then change the macro to display the message in another way, which requires the use of more registers, you would either need to push/pop the extra registers in the macro, or go through all of your code to make sure those registers are available where the macro is used.
With my idea, you can easily split procedural-based code up into smaller sections of code, or macros and edit them without effecting the rest of the code, while still making the code quite efficient.
I was also planning to add extra features to this so that you can create libraries, or partially-built code based on these 'macros' so that you could efficiently reuse code that you or someone else has previously written.
For example, you could use a 'macro' called 'myLibraryFile.printMessage', or something similar throughout your program and the compiler would extract the code from the macro and allocate all of the registers before it is assembled.
I'm not sure if what I've written will make much sense to you, but does anyone have any thoughts on this? Is it a good idea, or is it a waste of time & perhaps I should just use a higher level language instead?
|