Ben Cantrick (mackys) wrote,
Ben Cantrick
mackys

  • Mood:
  • Music:

Bad tools will make you hate life.

After 15 hours of hitting my head on things that should have taken 10 minutes, I have learned something today:


  • With good tools, you can make some pretty neat stuff in a reasonable amount of time. For instance, ~600 lines of main control code in a week that has yet to break in several fairly nasty integration tests.

  • With bad tools, you'll be hating your life and spending 15 hours doing something that should take you ten minutes.


I'm talking about compilers here, but the general lesson is a good one to remember.

I'd like to give the "pathetic and broken" award to the C2C compiler, which could not properly emit code to make this C statement work:

uchar8 = (uint16 >> 8) & 0xFF;

The really amusing irony here is that the uint16 is stored internally as a high byte and a low byte. All you need to do is take the high byte already stored in memory and copy it to the memory address of uchar8. Two instructions, max.

Nor could it manage this:

if(int16 < 0) { ... }

I shit you not - I had to hand-check the sign bit of my integer variable to see if it was negative, because the compiler couldn't emit code that would successfully do it! Three instructions for my version (mask with 0x8000, subtract 0x8000 from result, jump if result = zero). The C2C generated between 15 and 20 instructions to do the same thing, which kinda adds up when you only have 2k of instruction ROM to work with. And, let me repeat myself, the code it made still didn't work. Thought it did consistantly crash and freeze the PIC 16xxx I was working on. No small feat, as they're fairly goof-proof chips. After hacking it on my own, I got the interrupt handler working at 250 repetitions per second, rock solid. (Actually, theoretically it could do 800-900 second, but I didn't test it that fast.)

I'm smart enough to know that I probably wouldn't write a good compiler for the PIC. That makes me smarter than the people who wrote C2C. Apparently the BoostC compiler from the same site is going to supercede C2C. The sooner the better, if you ask me. Pay money for that thing? I'd rather stab myself in the crotch - repeatedly - with an angry, 800 lb blue marlin.

Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 6 comments