3 ms·
When I took a compiler class back in the early '90s, the project was to write the compiled machine code into an array, then cast the array into a function, and
by SeanLuke 5y ago
When I took a compiler class back in the early '90s, the project was to write the compiled machine code into an array, then cast the array into a function, and execute it. I and another student were doing it on 68040 NeXT workstations. One other student was doing it on a Mac, one on a VAX, and the rest on PCs (the PC students largely failed!). We were mystified why, when we tried to execute our code, it was as if it wasn't there. Took us a while to realize that the 68040 had separate instruction and data caches, and even more time (and emailing people at NeXT) to determine what the cache flush procedure was.
- rkeene2 5y agoI once saw code like: unsigned short main[] = {0104525, 0xb8e5, 32, 0, 0xC35D}; and I made a tool to generate it automatically from a function [0]. [0] https://rkeene.org/viewer/tmp/ret32-maker.c.htm https://rkeene.org/viewer/tmp/ret32-maker.c.htm
- foota 5y agoYou may be thinking of https://jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-a-function.html https://jroweboy.github.io/c/asm/2015/01/26/when-is-main-not...