- May 11, 2008
- 19,574
- 1,195
- 126
After doing this, i realized one issue :
This kind of reverse engineering to optimize code only works with my version GNU GCC 4.4.2. It is very likely that if i use a newer version or a compiler from another vendor, that this optimization may not produce the self code.
The last version i made (have not posted it yet, but it checks for a NULL pointer, a pointer to a NULL string and for word aligned strings. Easy to implement, it is just checking the pointer it self.
Thus i will start to experiment with optimizing the code in assembly while respecting the calling convention C. But even this will only work if the calling convention does not change. But that is a matter of placing clear comment about what calling convention is used and what kind of compiler if problems would arise. It is not that necessary, it is more a practice, a skill that i would like to learn just in case i might need it one day for work related projects. As for hobby material, it is always handy to know these kind of background information.
This kind of reverse engineering to optimize code only works with my version GNU GCC 4.4.2. It is very likely that if i use a newer version or a compiler from another vendor, that this optimization may not produce the self code.
The last version i made (have not posted it yet, but it checks for a NULL pointer, a pointer to a NULL string and for word aligned strings. Easy to implement, it is just checking the pointer it self.
Thus i will start to experiment with optimizing the code in assembly while respecting the calling convention C. But even this will only work if the calling convention does not change. But that is a matter of placing clear comment about what calling convention is used and what kind of compiler if problems would arise. It is not that necessary, it is more a practice, a skill that i would like to learn just in case i might need it one day for work related projects. As for hobby material, it is always handy to know these kind of background information.