Epson S5U1C62000A Computer Hardware User Manual


 
102 EPSON S5U1C62000A MANUAL
(S1C60/62 FAMILY ASSEMBLER PACKAGE)
CHAPTER 6: LINKER
6.11 Automatic Insertion/Removal/Correction of "pset" Instruction
To branch the program sequence to another page, the pset instruction is required immediately before a
branch instruction (jp or call) is executed. Since the location of relocatable sections is not decided until the
linking process is completed, the linker has a function that automatically inserts, removes or corrects the
pset codes. This makes it possible to omit the pset instruction in the source. However, this function is
valid only for the branch instructions that use a label to specify the destination address.
This function can be disabled by specifying the -d option. The -dr option can also be specified to disable
only the pset deletion function (in the case of the -d option is not specified). To keep compatibility with
the older assembler asm62XX (when the sources for the asm62XX are used), the -dr option must be
specified.
For jp instruction
First the linker checks if the destination label and the jp instruction are within the same page.
If the label exists in the same page, the linker does not insert the pset code, or remove the existing one
for the jp instruction.
When the label exists in another bank/page, the linker inserts the adequate pset instruction code in
front of the jp instruction, or corrects the bank/page number in the pset code if the pset code has a
wrong operand.
Examples:
Original (source) After corrected (disassembled code)
ld a,b ld a,b
jp OTHER_PAGE pset XX ... Necessary "pset XX" instruction is inserted.
jp OTHER_PAGE
pset YY jp SAME_PAGE
jp SAME_PAGE ... "pset YY" is removed if unnecessary.
Even when "pset YY" is necessary, YY is checked
and corrected if wrong.
For call instruction
Subroutine calls between banks are not allowed because the return instructions cannot handle bank
numbers. Therefore if a wrong call is made between banks, an error will result. This occurs only when
the section that calls the subroutine and the section in which the subroutine exists are absolute
sections and are in different banks. Relocatable sections are located so that a cross bank call does not
occur. If the subroutine call is made within the same bank, the optimization process is the same as that
for the jp instruction.
Examples:
Original (source) After corrected (disassembled code)
ld a,b ld a,b
call SUBROUTINE pset XX
call SUBROUTINE
...Necessary "pset XX" instruction is inserted.
If both the subroutine and current section are absolute
and are in different banks, an error will result.
pset YY call SUBROUTINE
call SUBROUTINE ... "pset YY" is removed if unnecessary.
Even when "pset YY" is necessary, YY is checked and
corrected if wrong.
If both the subroutine and current section are absolute
and are in different banks, an error will result.
If the -dr option is specified, existing pset instructions will not be removed.