Inter-compiler portability of asm between gdc and ldc2 (and dmd)

claptrap clap at trap.com
Wed Jul 15 09:38:38 UTC 2020


On Wednesday, 15 July 2020 at 07:34:08 UTC, Stefan Koch wrote:
> On Wednesday, 15 July 2020 at 00:26:13 UTC, Cecil Ward wrote:
>>
>> Has anyone for example done something using templates or 
>> mixin-ful goodness generating code on-the fly?
>>
>> Alternatively I could just give up and be forced to maintain 
>> two parallel implementations of certain modules forever more, 
>> provided there is zero runtime overhead, no cost in terms of 
>> speed or bloat.
>
> There is a workaround which I used and that involves runtime 
> overhead on startup.
> You just write the bytes that make up your function into an 
> executable page of memory.
> Set a function pointer to there, and you are done ;)

Do you pull them out manually or is there a way to get the start 
and end address of a function in a running program? So could I 
make an exe that when run dumps the bytes of one of its functions?


More information about the Digitalmars-d mailing list