Click here to Skip to main content
15,900,725 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Practice safe programming ! Pin
Paul Conrad13-Aug-08 9:27
professionalPaul Conrad13-Aug-08 9:27 
GeneralRe: Practice safe programming ! Pin
KarstenK14-Aug-08 3:48
mveKarstenK14-Aug-08 3:48 
GeneralRe: Practice safe programming ! Pin
Paul Conrad14-Aug-08 6:21
professionalPaul Conrad14-Aug-08 6:21 
GeneralCalling a subroutine Pin
Timothy Baldwin12-Aug-08 11:34
Timothy Baldwin12-Aug-08 11:34 
GeneralRe: Calling a subroutine Pin
Chris Maunder12-Aug-08 16:42
cofounderChris Maunder12-Aug-08 16:42 
GeneralRe: Calling a subroutine Pin
Mike Dimmick17-Aug-08 10:39
Mike Dimmick17-Aug-08 10:39 
GeneralRe: Calling a subroutine Pin
Timothy Baldwin21-Aug-08 5:14
Timothy Baldwin21-Aug-08 5:14 
GeneralRe: Calling a subroutine Pin
supercat917-Aug-08 11:59
supercat917-Aug-08 11:59 
Timothy Baldwin wrote:
Why not write the subroutine to use the C calling convention?


Some microcontrollers have unchangeable routines in ROM to perform various functions like writing to flash memory. Some of them require that such routines be used when writing to flash because (1) none of the RAM in the system supports code execution, and (2) while a write to flash is taking place, none of the flash memory can be used for any purpose including program execution. The register and calling conventions for such routines are what they are, and there is no way a programmer or compiler author can change them.

Sometimes microcontrollers require some really nasty coding tricks to make things work in practical fashion. When I use such tricks I make sure to thoroughly document what I'm doing, and I avoid using such tricks purely for the sake of "looking impressive". On the other hand, if an interrupt routine is going to be executing 10,000 times per second on a micro which runs 1,000,000 instructions per second, having clear readable code which takes 30 cycles longer than necessary is not as good as having code which is tricky and hard to read, but runs 50 cycles faster.
GeneralCode which caused my PC hang [modified] PinPopular
Anand Desai6-Aug-08 22:41
Anand Desai6-Aug-08 22:41 
GeneralRe: Code which caused my PC hang PinPopular
leppie7-Aug-08 1:35
leppie7-Aug-08 1:35 
GeneralRe: Code which caused my PC hang Pin
Anand Desai7-Aug-08 2:14
Anand Desai7-Aug-08 2:14 
GeneralRe: Code which caused my PC hang Pin
leppie7-Aug-08 2:19
leppie7-Aug-08 2:19 
GeneralRe: Code which caused my PC hang Pin
Anand Desai7-Aug-08 2:21
Anand Desai7-Aug-08 2:21 
GeneralRe: Code which caused my PC hang Pin
Dan Neely7-Aug-08 2:16
Dan Neely7-Aug-08 2:16 
GeneralRe: Code which caused my PC hang Pin
Yusuf8-Aug-08 11:04
Yusuf8-Aug-08 11:04 
GeneralRe: Code which caused my PC hang Pin
AeonBlue7-Aug-08 4:42
AeonBlue7-Aug-08 4:42 
GeneralRe: Code which caused my PC hang Pin
Paul Conrad7-Aug-08 10:50
professionalPaul Conrad7-Aug-08 10:50 
JokeRe: Code which caused my PC hang Pin
Yusuf8-Aug-08 11:06
Yusuf8-Aug-08 11:06 
GeneralAttack of the notepads Pin
Llasus8-Aug-08 22:08
Llasus8-Aug-08 22:08 
GeneralRe: Attack of the notepads Pin
Jonathan C Dickinson9-Aug-08 2:41
Jonathan C Dickinson9-Aug-08 2:41 
GeneralRe: Code which caused my PC hang Pin
Jamie Nordmeyer11-Aug-08 11:03
Jamie Nordmeyer11-Aug-08 11:03 
JokeRe: Code which caused my PC hang Pin
Anand Desai12-Aug-08 23:26
Anand Desai12-Aug-08 23:26 
GeneralRe: Code which caused my PC hang Pin
Jamie Nordmeyer13-Aug-08 3:52
Jamie Nordmeyer13-Aug-08 3:52 
GeneralRe: Code which caused my PC hang Pin
neilmajithia14-Aug-08 2:33
neilmajithia14-Aug-08 2:33 
RantWe need more ITT Tech programmers PinPopular
gongchengshi5-Aug-08 11:27
gongchengshi5-Aug-08 11:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.