Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSerapth

Posted 23 October 2012 - 03:39 PM

You must learn what your code converts to. My ASM programming site: http://sungod777.zxq.net/


No, you mustn't. In fact, you should very much do the exact opposite of this, especially when starting out.

To the OP, if I hear you are learning assembly as a first language, I am going to hunt you down and beat you with a dead mackerel.

Besides, even your example doesn't guarantee the byte order within the struct. The compiler is perfectly within it's rights and in fact, probably will, byte pad that value to get the ideal alignment.

From the C++ 03 standard:
Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated so that later members have higher addresses within a class object. The order of allocation of nonstatic data members separated by an access-specifier is unspecified (11.1). Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements for space for managing virtual functions (10.3) and virtual base classes (10.1).

This is completely ignoring the fact "rightmost" byte is completely relative to the system you are running on. If you insist on giving beginners bad advice, please at least make it factually correct bad advice.

#1Serapth

Posted 23 October 2012 - 03:36 PM

You must learn what your code converts to. My ASM programming site: http://sungod777.zxq.net/


No, you mustn't. In fact, you should very much do the exact opposite of this, especially when starting out.

To the OP, if I hear you are learning assembly as a first language, I am going to hunt you down and beat you with a dead mackerel.

Besides, even your example doesn't guarantee the byte order within the struct. The compiler is perfectly within it's rights and in fact, probably will, byte pad that value to get the ideal alignment.

From the C++ 03 standard:
Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated so that later members have higher addresses within a class object. The order of allocation of nonstatic data members separated by an access-specifier is unspecified (11.1). Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements for space for managing virtual functions (10.3) and virtual base classes (10.1).

If you insist on giving beginners bad advice, please at least make it factually correct bad advice.

PARTNERS