From 0dc623d4eb5fd9dd68e9438dc80d94224efe72b6 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Wed, 23 Feb 2011 02:39:04 +0100 Subject: [PATCH] gcode_parse.c: added comments, which show possible variable overflows. Stay tuned, the fix is just around the corner. --- config.h.dist | 1 + gcode_parse.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/config.h.dist b/config.h.dist index d508570..36cc491 100644 --- a/config.h.dist +++ b/config.h.dist @@ -44,6 +44,7 @@ // for threaded rods, this is (steps motor per turn) / (pitch of the thread) // for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) // half-stepping doubles the number, quarter stepping requires * 4, etc. +// valid range = 0.020 to 4194.303 #define STEPS_PER_MM_X 320.000 #define STEPS_PER_MM_Y 320.000 #define STEPS_PER_MM_Z 320.000 diff --git a/gcode_parse.c b/gcode_parse.c index 006da46..e414d24 100644 --- a/gcode_parse.c +++ b/gcode_parse.c @@ -47,6 +47,22 @@ decfloat read_digit __attribute__ ((__section__ (".bss"))); GCODE_COMMAND next_target __attribute__ ((__section__ (".bss"))); +/* + decfloat_to_int() is the weakest subject to variable overflow. For evaluation, we assume a build room of +-1000 mm and STEPS_PER_MM_x between 1.000 and 4096. Accordingly for metric units: + + df->mantissa: +-0..1048075 (20 bit - 500 for rounding) + df->exponent: 0, 2, 3 or 4 (10 bit) + multiplicand / denominator: 20..4194303 / 1000 (22 bit - 10 bit) or + 0..4095 / 1 (12 bit - 0 bit) + + imperial units: + + df->mantissa: +-0..32267 (15 bit - 500 for rounding) + df->exponent: 0, 2, 3 or 4 (10 bit) + multiplicand: 1..105000 (17 bit) + denominator: 1 or 10 ( 4 bit) +*/ + /* utility functions */