Wednesday 15 September 2010

cpu architecture - C programming and error_code variable efficiency -


I have ever read most code uses int to deal with standard error Kind of). But I am thinking that if there is any benefit to using uint_8 then it will be a compiler - the most compiler on most architectures - produce instructions using instant address mode - that is, embed Do 1-byte integer instruction? I am thinking about it that the key command compares after a function, its return type is used as a UIT_8.

I was thinking about things wrongly because starting with 1 byte type just causes alignment issues - perhaps a completely sensible reason that compile 4-bytes Likes to pack things in and it probably uses all the reasons - and since it is a problem related to stack rather than a heap, there is no real overhead.

I'm thinking about doing the right thing but for the sake of logic it says that it is a popular cheap microprocessor for an intelligent clock and it is configured with 1 memory, but its instruction There are different addressing modes in the set: D

Another question will be specialist (x86) to discuss: in: literally:

  uint_32 x = func (); X1 ==;  

and

  uint_8 x = func (); X1 ==;  

The same type? Or the compiler will generate 8-byte literal in the second case. If so, then it is used as a comparison instruction which is literally as an instant value and can be returned to generate returns as a register reference. .

What a special compiler will do for the following code:

  Extras int Fu (zero); Zero times (zero) {if (foo () == 31) {// error code 31 do_something (); } Else {do_somehing_else (); }} 0: 55 push% EBP 1: 89E5% MOV% esp,% ebp3: 83EC 08 sub $ 0x8,% esp 6: e8fcffffff call 7 & lt; Bar + 0x7 & gt; B: 83F8 1F CMP $ 0 x 1f,% eXE: 74 08GE 18LT; Bar + 0x18 & gt; 10: C9 Leave 11: E9 FC FF FF FF JMP 12 and LT; Bar + 0x12 & gt; 16: 89F 6 mov% esi,% esi 18: C9 Leave 19: E9 FC FF FF FF JMP 1A and LT; Bar + 0x1a & gt;  

3 byte instructions for CAP if foo () returns a four, then b: 3 C 1f cmp $ 0x1f,% al

If you have the skills Are looking for Do not assume comparison of goods in% A1 is faster than comparing% eax


No comments:

Post a Comment