gcode_parse.h: order variables reasonably in groups of 4 bytes.

This uses 4 bytes less RAM, without any loss, due to fewer holes
in variable arrangements.

The general strategy is simple:

 - Ideally, all variables are aligned in groups of 4 bytes
   (32 bits). This allows fastest access on 32-bit CPUs and doesn't
   change anything on 8 or 16 bit ones.

 - 1x 32-bits variable = 4 bytes = 4-byte group.

 - 2x 16-bits variable together = 4-byte group.

 - 4x 8-bits variable together = 4-byte group.

 - Have as few incomplete groups as possible.

Another strategy is to simply order variables by size.

There's a compiler flag to pack such variable arrangements, but
this costs Flash size and processing time.
This commit is contained in:
Markus Hitter 2015-07-30 21:22:45 +02:00
parent e5729d6743
commit 608506719b
1 changed files with 6 additions and 6 deletions

View File

@ -45,17 +45,17 @@ typedef struct {
uint8_t option_inches :1; ///< inches or millimeters?
};
uint8_t G; ///< G command number
uint8_t M; ///< M command number
TARGET target; ///< target position: X, Y, Z, E and F
uint32_t N; ///< line number
uint32_t N_expected; ///< expected line number
int32_t S; ///< S word (various uses)
uint16_t P; ///< P word (various uses)
uint8_t T; ///< T word (tool index)
uint8_t G; ///< G command number
uint8_t M; ///< M command number
TARGET target; ///< target position: X, Y, Z, E and F
uint32_t N; ///< line number
uint32_t N_expected; ///< expected line number
uint8_t T; ///< T word (tool index)
uint8_t checksum_read; ///< checksum in gcode command
uint8_t checksum_calculated; ///< checksum we calculated