On Wed, 15 Feb 2017 20:48:16 +0000, Trifle Menot wrote:
> With Borland C++ you can print out the assembly, and code the offset
> yourself, via more asm statements. But then you must manually maintain
> the asm code to match any change to the structure.
With OpenWatcom it's even easier than that (but still cumbersome):
#define MYSTRUCT_OFF_X 0
#define MYSTRUCT_OFF_Y 2
struct s {
unsigned short x;
unsigned short y;
} mystruct;
_asm {
mov word ptr [mystruct] + MYSTRUCT_OFF_X, ax
}
I have been using the above since some time now... and it works fine, the
preprocessor takes care of resolving #defines also within in-line
assembly blocks. It does require of course to adjust the defines each
time that the structure evolves. I am only wondering whether OpenWatcom
perhaps provides some more elegant trick for handling that in an
automated way - it does seem trivial after all (at least compared to the
other magic that OW is capable of). That is, some asm-aware equivalent of
the C offsetof() macro...
Mateusz