Page 3 of 3
Re: better registers representation in C?
Posted: Mon Sep 05, 2011 12:25 am
by Owen
Except for when doing whole program optimization and with at least hidden symbols, the compiler can't assign variables to specific register slots across function calls in a safe manner. The register globals extension is used to allow e.g. the VM program counter or (for a stack machine) stack pointer to be placed in registers across multiple functions.
You can think of this as, almost, a custom calling convention exteennsion. Indeed, if you had one (e.g. Watcom's pragma based method) this would probably not be necessary (though, then again, it may still produce cleaner code)
Re: better registers representation in C?
Posted: Mon Sep 05, 2011 12:32 am
by Love4Boobies
That's what optimizing linkers are for---making things clean (e.g., LLVM gold plugin)
Re: better registers representation in C?
Posted: Mon Sep 05, 2011 2:03 am
by Thomas
Hi,
Just putting this for informational purposes only, the good old Turbo / Borland C++ had the feature of accessing registers like this. I do not have access to a Borland compiler right now , but i guess newer versions allows access to 32 bit registers
Code: Select all
_AX = 2 ;
_BX = 3 ;
_CX = _AX + _BX ;
--Thomas
Re: better registers representation in C?
Posted: Mon Sep 05, 2011 2:07 am
by Love4Boobies
Yes, miker00lz already mentioned that. At least what Owen (who will get his 5th start after just two more posts from the time I post this
) mentions is useful for a sucky toolchain...
Re: better registers representation in C?
Posted: Mon Sep 05, 2011 2:15 am
by Thomas
Yes, miker00lz already mentioned that. At least what Owen (who will get his 5th start after just two more posts from the time I post this
) mentions is useful for a sucky toolchain...
Sorry , missed that
. However redundancy does improve reliability at times
--Thomas