difference=%d\\n", first, second, result);
difference=16733234
difference=-2147483392
Try some leading minus signs.
easier in
I'm not an avid programmer. I hate to program, so I get it over as soon as possible. I'd rather design hardware.
But the language doesn't matter; I just need to settle on a notation that my customers can use. So, it's...
Absorb the characters after the "x" as nibbles packed into a 32-bit register. If there had been a leading - sign, negate that register after all the "0..F" characters are crunched.
of
The whole program is around 6 kloc, not the parser. The command parser proper is about 75 lines of executable code, and the "get an integer from the command string" subroutine is another 35 or so, now that I've added the signed "0x" hex option.
I'm up to about 260 distinct serial commands so far. The parser is looking pretty good, fast and nicely table-driven, so we'll use it in a lot of other products. We did a couple of products with proper SCPI syntax analyzers, and they were bags-o-worms. SCPI is insane.
John