
CHAPTER 3 CPU FUNCTIONS
37
(1) Program segment
The start address of this segment is determined by the program segment register (PS) and the offset from the
start address is specified by the prefetch pointer (PFP).
In this segment, an operation code, table data, etc., are placed.
By using the segment override prefix (PS:), the program segment can be used as the general variable area and
source data area in execution of instruction group A.
(2) Stack segment
The start address of this segment is determined by the stack segment register (SS) and the offset from the start
address is specified by the effective address when the stack pointer (SP) and base pointer (BP) as the base
address are used.
This is used as an area to save the contents of the return address (PS, PC content), program status word (PSW),
general register, etc., as a parameter transfer area and local variable area.
By using the segment override prefix (SS:), the stack segment can be used as a general variable area and
source data area in execution of instruction group A.
(3) Data segment 0
The start address of this segment is determined by the data segment 0 register (DS0) and the offset from the
start address is specified by the effective address when BP is not used as a base address.
This segment is used as an area to store general variables.
When executing instruction group A, it is used as a source data area. However, in this case, the content of the
index register (IX) becomes the offset.
For the effective address when BP is used as the base address, the stack segment is used as the default, but
data segment 0 can be used if the segment override prefix (DS0:) is used.
(4) Data segment 1
The start address of this segment is determined by the data segment 1 register (DS1). This can be used as a
destination data area when executing instruction group B. In this case, the content of the index register (IY)
becomes the offset.
If the segment override prefix (DS1:) is used, data segment 1 can be used as a general variable area or source
data area in execution of instruction group A.
3.4.3 Dynamic relocation
Relocating programs that are stored in two or more files separately in empty memory spaces for each execution is
called dynamic relocation.
Figure 3-8 shows a conceptual diagram of dynamic relocation.
For the V30MZ, memory addressing of a program can be determined only with the offset value for the base
address of each segment (specified by each segment register). Therefore, it is possible to allocate the program in an
arbitrary memory space by only adjusting to the physical address of the memory at which it is to be allocated
(however, this is only possible if the base address of each segment is not changed in the program). This increases
the degree of freedom of program allocation in the memory (addressing is possible in 16-byte units), enabling more
effective utilization of memory and making it easier to implement a system that executes multiple jobs and tasks.
This can be applied to executing a program in a file on an external storage medium such as a floppy disk and hard
disk with the OS controlling the memory allocation area, type, and segment registers, and loading the program in any
empty memory area.