0

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?

JiangFeng
  • 355
  • 2
  • 14

1 Answers1

0

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.

Tim D
  • 650
  • 1
  • 12
  • 18
  • I know about this, that's why we have .text and .data seperated. What I want to know is why they use different addressing mode? – JiangFeng Aug 30 '17 at 02:14
  • I don't know more detail. There are several different memory spaces with different addressing modes available in hardware. The number of different spaces, modes and how the operating system uses these would be arbitrary decisions by the hardware and operating system designers. Implementations of programming languages just have to follow along with the decisions made by these designers. – Tim D Aug 30 '17 at 14:28