News for hackers. Stuff that matters.
Re:Why I Chose to Learn C by danielweber on Friday March 29, 2013 @03:48PM (#5462659)
If your architecture allows it, sure.

I was reading some old Apple II assembly last year, and one very common way to do loops is like this:

1. Is 10 equal to 0?

2. If so, go to step 6.

3. Do a bunch of stuff.

4. Decrement the first number written in step 1.

5. Go to step 1.

6. Rest of program.

Re:Why I Chose to Learn C by ajross on Friday March 29, 2013 @04:20PM (#5462824)
To be clear, even on architectures that allow it (or OS environments: the NX bit on modern x86 boxes means that you can't write to code space without mmap'ing the region yourself), it's a Very Bad Idea. Code and data use different L1 caches (on Sandy/Ivy Bridge, there's even a still lower level "uop" cache for code!), and keeping them coherent after self-modifying code has run is (1) extraordinarily difficult to get right and (2) hugely slow, much slower than simply indirecting on data in the first place.