From 9ea3941ffe1d04a0a214e695f1302a571f9640b1 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Wed, 3 Jun 2015 22:15:19 +0200 Subject: [PATCH] gcode_process.c: be more explicit about X_MIN,... type. Big surprise, this makes the binary a whopping 286 bytes smaller with software endstops enabled. Looking at the produced assembly, the former code caused gcc to do the float -> integer conversion at runtime, using a __floatsisf(). Now the X_MIN, X_MAX... values are compiled in as integers directly. This is work related to issue #157. --- gcode_process.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gcode_process.c b/gcode_process.c index 07cb850..4784004 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -63,31 +63,30 @@ void process_gcode_command() { // implement axis limits #ifdef X_MIN - if (next_target.target.axis[X] < X_MIN * 1000.) - next_target.target.axis[X] = X_MIN * 1000.; + if (next_target.target.axis[X] < (int32_t)(X_MIN * 1000.)) + next_target.target.axis[X] = (int32_t)(X_MIN * 1000.); #endif #ifdef X_MAX - if (next_target.target.axis[X] > X_MAX * 1000.) - next_target.target.axis[X] = X_MAX * 1000.; + if (next_target.target.axis[X] > (int32_t)(X_MAX * 1000.)) + next_target.target.axis[X] = (int32_t)(X_MAX * 1000.); #endif #ifdef Y_MIN - if (next_target.target.axis[Y] < Y_MIN * 1000.) - next_target.target.axis[Y] = Y_MIN * 1000.; + if (next_target.target.axis[Y] < (int32_t)(Y_MIN * 1000.)) + next_target.target.axis[Y] = (int32_t)(Y_MIN * 1000.); #endif #ifdef Y_MAX - if (next_target.target.axis[Y] > Y_MAX * 1000.) - next_target.target.axis[Y] = Y_MAX * 1000.; + if (next_target.target.axis[Y] > (int32_t)(Y_MAX * 1000.)) + next_target.target.axis[Y] = (int32_t)(Y_MAX * 1000.); #endif #ifdef Z_MIN - if (next_target.target.axis[Z] < Z_MIN * 1000.) - next_target.target.axis[Z] = Z_MIN * 1000.; + if (next_target.target.axis[Z] < (int32_t)(Z_MIN * 1000.)) + next_target.target.axis[Z] = (int32_t)(Z_MIN * 1000.); #endif #ifdef Z_MAX - if (next_target.target.axis[Z] > Z_MAX * 1000.) - next_target.target.axis[Z] = Z_MAX * 1000.; + if (next_target.target.axis[Z] > (int32_t)(Z_MAX * 1000.)) + next_target.target.axis[Z] = (int32_t)(Z_MAX * 1000.); #endif - // The GCode documentation was taken from http://reprap.org/wiki/Gcode . if (next_target.seen_T) {