Why code and data have different addressing mode?

36 views Asked by At

I learnt from assembly language some addressing mode. But I find out that for different segment, we have different addressing mode, for example, you cannot use PC-relative addressing for data. Why is that?

1

There are 1 answers

2
Tim D On

For an operating system with properly implemented integrity, code should not be allowed to manipulate its own memory space other than some high level functionality such as loading additional modules, otherwise it would not be possible to debug a program that is changing itself to something else at run-time. A program's data space; however, can be manipulated as required by the program. It is likely best practice for an operating system implementation to clearly separate code space and data space to avoid problems with accidentally manipulating the code space.