Monday, October 20, 2008

Think I'll code in Pascal...

I am working in a very hardware centric environment, and every time I come to talk to physical devices, they are all "ones based". For example, there are three LED's, LED_1, LED_2, LED_3. I want to handle them in a table in software, they become LED[0], LED[1] and LED[2]. But that is only because I'm using C. If I were using Pascal I would be calling them LED[1], LED[2] and LED[3].

But no, I'm using C.

Of course, I could make the arrays one entry larger than I need, and ignore LED[0]. Quite right, unless I was in reduced memory space (I've got 2k RAM on one of these systems, and things are getting tight).

Then when it comes to processor pins, they are zero based numbers, and for bit masks I need to be zero based. Oh, why do hardware designers have to start with one being first instead of zero.

No comments: