Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Jan Waclawek
10/19/11 01:40
Read: 621 times
Bratislava
Slovakia


 
#184269 - the programmer blindness
In assembler (not on a '51, but that's unimportant) the equivalent of a switch/case statement with consecutive values went like:
  dec a
  jz  DO_SOMETHING
  dec a
  jz  DO_SOMETHING_ELSE
  dec a
  jz  DO_SOMETHING_ELSE  ;do the same for both cases
  dec a
  jz  DO_SOMETHING_DIFFERENT
  dec a
  jz  DO_SOMETHING_MORE
etc.
 


I needed to insert one value into the list (and shift the rest). As the "insert into list" involved also changing several tables and some other code, I did it conditionally so that I can revert quickly in case of problems. Of course I use copy-paste often.

  dec a
  jz  DO_SOMETHING
  dec a
  jz  DO_SOMETHING_ELSE
  dec a
  jz  DO_SOMETHING_ELSE  ;do the same for both cases
  dec a
.if NEW_STUFF
  dec a
  jz  DO_THE_NEW_STUFF
.endif
  jz  DO_SOMETHING_DIFFERENT
  dec a
  jz  DO_SOMETHING_MORE
 
The error went unnoticed for years, as its symptoms were incidentally masked (by the order of commands arriving from a different device). Now the error somehow surfaced and I had to find it. After a couple of tests i KNEW it is in this sequence, but it took me half a day to spot it.

Of course, most of bugs look trivial *after* you find it.

JW

List of 10 messages in thread
TopicAuthorDate
the programmer blindness      Jan Waclawek      10/19/11 01:40      
   split hairs      Joseph Hebert      10/19/11 07:45      
   Double Dec      Michael Karas      10/19/11 08:44      
      unreachable code      Maarten Brock      10/20/11 05:53      
         Analysis tools      Oliver Sedlacek      10/21/11 09:36      
   re: blindness      Andy Peters      10/19/11 12:04      
   re:blindness      Stefan KAnev      10/19/11 12:32      
      Thanks all for the comments.      Jan Waclawek      10/19/11 14:13      
         but remember      Erik Malund      10/19/11 14:18      
   What is this, really?      Richard Erlacher      10/19/11 21:04      

Back to Subject List