I assume that you intended to say writing data into code area (and possibly execute the written code :-).
Days are long gone when you _had_to_ use such tricks, i.e. self modifying code on processors without index registers.
Apart for the program loader (virtual memory manager), these should be no such needs ! If self modifying code is needed, use an interpreter with proper protection.
Even the x86 has usable memory protection features, unfortunately only on the segment register/descriptor level. Contrary to popular belief, the segment registers are still active on the 32 bit x86 but with the offsets usually set to 0, so it would be a 32 bit linear address space for code, data and stack. Only after this, is the virtual address translation done.
Even in this configuration, it is easy to group code, data and stack space into separate areas and apply segment protection.
However, would the segment override prefix opcodes still be able to write into wrong areas ? Anyway, a simple segment based protection would have avoided at least inadvertent access to wrong address space.
Actually compilers and linkers have generated program sections with executable and read only and read/write program sections for ages, I just wonder why the operating systems and hardware actually doesn't enforce this.
At least for hard real time applications, I would have stayed far away from that processor due to unpredictable latencies.