4 * Copyright (C) 1989-2010 Alan R. Baldwin
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * With enhancements from:
26 * John L. Hartman (JLH)
27 * jhartman@compuserve.com
30 * w_mckinnon@conknet.com
37 * The module lkrloc3.c contains the functions which
38 * perform the version 3 relocation calculations.
40 * lkrloc3.c contains the following functions:
53 * lkrloc3.c the local variable errmsg3[].
57 /*)Function VOID reloc3(c)
61 * The function reloc3() calls a particular relocation
62 * function determined by the process code.
68 * int lkerr error flag
71 * int fprintf() c_library
72 * VOID rele3() lkrloc3.c
73 * VOID relp3() lkrloc3.c
74 * VOID relr3() lkrloc3.c
75 * VOId relt3() lkrloc3.c
78 * Refer to the called relocation functions.
104 fprintf(stderr
, "Undefined Relocation Operation\n");
112 /*)Function VOID relt3()
114 * The function relt3() evaluates a T line read by
115 * the linker. Each byte value read is saved in the
116 * rtval[] array, rtflg[] is set, and the number of
117 * evaluations is maintained in rtcnt.
121 * T xx xx nn nn nn nn nn ...
124 * In: "T n0 n1 n2 n3 ... nn"
126 * Out: 0 1 2 .. rtcnt
127 * +----+----+----+----+----+
128 * rtval | n0 | n1 | n2 | .. | nn |
129 * +----+----+----+----+----+
130 * rtflag| 1 | 1 | 1 | 1 | 1 |
131 * +----+----+----+----+----+
133 * The T line contains the assembled code output by the assem-
134 * bler with xx xx being the offset address from the current area
135 * base address and nn being the assembled instructions and data in
142 * int rtcnt number of values evaluated
143 * int rtflg[] array of evaluation flags
144 * int rtval[] array of evaluation values
147 * int eval() lkeval.c
151 * Linker input T line evaluated.
161 rtval
[rtcnt
] = eval();
169 /*)Function VOID relr3()
171 * The function relr3() evaluates a R line read by
172 * the linker. The R line data is combined with the
173 * previous T line data to perform the relocation of
174 * code and data bytes. The S19 / IHX output and
175 * translation of the LST files to RST files may be
180 * R 0 0 nn nn n1 n2 xx xx ...
182 * The R line provides the relocation information to the linker.
183 * The nn nn value is the current area index, i.e. which area the
184 * current values were assembled. Relocation information is en-
185 * coded in groups of 4 bytes:
187 * 1. n1 is the relocation mode and object format
188 * 1. bit 0 word(0x00)/byte(0x01)
189 * 2. bit 1 relocatable area(0x00)/symbol(0x02)
190 * 3. bit 2 normal(0x00)/PC relative(0x04) relocation
191 * 4. bit 3 1-byte(0x00)/2-byte(0x08) byte data
192 * 5. bit 4 signed(0x00)/unsigned(0x10) byte data
193 * 6. bit 5 normal(0x00)/page '0'(0x20) reference
194 * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference
196 * 2. n2 is a byte index into the corresponding (i.e. pre-
197 * ceeding) T line data (i.e. a pointer to the data to be
198 * updated by the relocation). The T line data may be
199 * 1-byte or 2-byte byte data format or 2-byte word
202 * 3. xx xx is the area/symbol index for the area/symbol be-
203 * ing referenced. the corresponding area/symbol is found
204 * in the header area/symbol lists.
206 * The groups of 4 bytes are repeated for each item requiring relo-
207 * cation in the preceeding T line.
210 * areax **a pointer to array of area pointers
211 * int aindex area index
212 * char *errmsg3[] array of pointers to error strings
213 * int error error code
214 * int mode relocation mode
215 * adrr_t paga paging base area address
216 * a_uint pags paging symbol address
217 * a_uint r PCR relocation value
218 * a_uint reli relocation initial value
219 * a_uint relv relocation final value
220 * int rindex symbol / area index
221 * a_uint rtbase base code address
222 * a_uint rtofst rtval[] index offset
223 * int rtp index into T data
224 * sym **s pointer to array of symbol pointers
227 * head *hp pointer to the head structure
228 * int lkerr error flag
229 * a_uint pc relocated base address
230 * int pcb bytes per instruction word
231 * rerr rerr linker error structure
232 * FILE *stderr standard error device
235 * a_uint adb_1b() lkrloc.c
236 * a_uint adb_2b() lkrloc.c
237 * a_uint adb_lo() lkrloc3.c
238 * a_uint adb_hi() lkrloc3.c
243 * a_uint evword() lkrloc.c
244 * int eval() lkeval.c
245 * int fprintf() c_library
248 * VOID lkulist lklist.c
250 * VOID relerr3() lkrloc3.c
251 * int symval() lksym.c
254 * The R and T lines are combined to produce
255 * relocated code and data. Output Sxx / Ixx
256 * and relocated listing files may be produced.
265 int aindex
, rindex
, rtp
, error
, i
;
266 a_uint r
, rtbase
, rtofst
, paga
= 0, pags
= 0;
271 * Get area and symbol lists
279 if (eval() != (R3_WORD
| R3_AREA
) || eval()) {
280 fprintf(stderr
, "R input error\n");
288 aindex
= (int) evword();
289 if (aindex
>= hp
->h_narea
) {
290 fprintf(stderr
, "R area error\n");
299 ap
= a
[aindex
]->a_bap
;
301 rtabnk
->b_rtaflg
= rtaflg
;
302 if (ofp
!= ap
->a_ofp
) {
308 rtaflg
= rtabnk
->b_rtaflg
;
314 rtbase
= adb_xb(0, 0);
320 pc
= adb_xb(a
[aindex
]->a_addr
, 0);
323 * Number of 'bytes' per PC address
328 printf("area %d base address: 0x%x size: 0x%x rtbase: 0x%x\n", aindex
,
329 a
[aindex
]->a_addr
, a
[aindex
]->a_size
, rtbase
);
332 * Do remaining relocations
338 if ((mode
& R_ESCAPE_MASK
) == R_ESCAPE_MASK
)
340 mode
= ((mode
& ~R_ESCAPE_MASK
) << 8) | eval();
341 /* printf("unescaping rmode\n"); */
345 rindex
= (int) evword();
348 * R3_SYM or R3_AREA references
351 if (rindex
>= hp
->h_nsym
) {
352 fprintf(stderr
, "R symbol error\n");
356 reli
= symval(s
[rindex
]);
359 else if ((IS_R_J11(mode
) || IS_R_J19(mode
)) && (rindex
== 0xFFFF)) {
360 /* absolute acall/ajmp address */
363 /* end sdld specific */
365 if (rindex
>= hp
->h_narea
) {
366 fprintf(stderr
, "R area error\n");
370 reli
= a
[rindex
]->a_addr
;
377 if (mode
& R3_BYTE
) {
378 reli
-= (pc
+ (rtp
-rtofst
) + 1);
380 reli
-= (pc
+ (rtp
-rtofst
) + 2);
385 * R3_PAG0 or R3_PAG addressing
387 if (mode
& (R3_PAG0
| R3_PAG
)) {
388 paga
= sdp
.s_area
->a_addr
;
394 /* pdk instruction fusion */
396 relv
= adb_3b(reli
, rtp
);
398 /* pdk addresses in words, not in bytes,
399 * for goto/call instructions and byte selections.
401 int jump
= 1, mask
= 0;
402 if (rtval
[rtp
+ 4] == 15) {
403 jump
= rtval
[rtp
+ 3] & 0x70;
405 if (get_sdld_target() == TARGET_ID_PDK
) {
406 set_sdld_target(TARGET_ID_PDK15
);
407 } else if (get_sdld_target() != TARGET_ID_PDK15
) {
410 } else if (rtval
[rtp
+ 4] == 14) {
411 jump
= rtval
[rtp
+ 3] & 0x38;
413 if (get_sdld_target() == TARGET_ID_PDK
) {
414 set_sdld_target(TARGET_ID_PDK14
);
415 } else if (get_sdld_target() != TARGET_ID_PDK14
) {
418 } else if (rtval
[rtp
+ 4] == 13) {
419 jump
= rtval
[rtp
+ 3] & 0x1C;
421 if (get_sdld_target() == TARGET_ID_PDK
) {
422 set_sdld_target(TARGET_ID_PDK13
);
423 } else if (get_sdld_target() != TARGET_ID_PDK13
) {
427 /* T*SN and SET* instructions for PDK13 needed to
428 * be handled specially since their address is
429 * in between the opcode.
431 if ((rtval
[rtp
+ 3] & 0x1F00) == 0x300 ||
432 (rtval
[rtp
+ 3] & 0x1F00) == 0x200) {
438 (mask
>> 0) | (mask
>> 1) | (mask
>> 2);
439 const int igoto
= (mask
>> 0) | (mask
>> 1);
440 if (((mode
& R3_BYTE
) && !(mode
& R3_USGN
)) ||
441 jump
== icall
|| jump
== igoto
) {
442 /* Addresses cannot be bigger than N - 1 bits.
443 * Any bits that are set past that point are
444 * marker bits that should be not shifted.
446 int marker
= rtval
[rtp
+ 1] & 0x80;
447 rtval
[rtp
+ 1] &= ~0x80;
450 rtval
[rtp
] |= (rtval
[rtp
+ 1] & 1) << 7;
452 rtval
[rtp
+ 1] |= marker
;
455 const int inst
= (rtval
[rtp
+ 3] << 8) | rtval
[rtp
+ 2];
457 /* Do the actual opcode fusion and ignore the two
458 * bytes taken for the opcode by the assembler.
460 if (IS_R_J11(mode
)) {
461 rtval
[rtp
+ 2] |= rtval
[rtp
];
462 rtval
[rtp
+ 3] |= rtval
[rtp
+ 1];
463 } else if (mode
& R3_MSB
) {
464 rtval
[rtp
+ 2] |= rtval
[rtp
+ 1];
465 rtval
[rtp
] = rtval
[rtp
+ 1];
468 rtval
[rtp
+ 2] |= rtval
[rtp
];
472 const int addr
= (rtval
[rtp
+ 1] << 8) | rtval
[rtp
];
473 static int errorCount
= 0;
474 if (vpdkinst(inst
, addr
, rtval
[rtp
+ 4])) {
475 if (errorCount
< 3) {
477 } else if (errorCount
== 3) {
478 puts("?ASlink-Warning-More instruction address errors omitted");
491 * R3_BYTE or R3_WORD operation
493 else if (mode
& R3_BYTE
) {
496 /* This is a three byte address, of which
497 * we will select one byte.
502 relv
= adb_24_bit(reli
, rtp
);
505 else if (mode
& R_HIB
)
507 /* printf("24 bit address selecting hi byte.\n"); */
508 relv
= adb_24_hi(reli
, rtp
);
510 else if (mode
& R3_MSB
)
512 /* Note that in 24 bit mode, R3_MSB
513 * is really the middle byte, not
514 * the most significant byte.
516 * This is ugly and I can only apologize
519 /* printf("24 bit address selecting middle byte.\n"); */
520 relv
= adb_24_mid(reli
, rtp
);
524 /* printf("24 bit address selecting lo byte.\n"); */
525 relv
= adb_24_lo(reli
, rtp
);
528 else if (mode
& R3_BYTX
) {
529 /* This is a two byte address, of
530 * which we will select one byte.
533 relv
= adb_bit(reli
, rtp
);
534 } else if (mode
& R3_MSB
) {
535 relv
= adb_hi(reli
, rtp
);
537 relv
= adb_lo(reli
, rtp
);
540 relv
= adb_1b(reli
, rtp
);
542 } else if (IS_R_J11(mode
)) {
544 * JLH: 11 bit jump destination for 8051.
545 * Forms two byte instruction with
546 * op-code bits in the MIDDLE!
547 * rtp points at 3 byte locus:
548 * first two will get the address,
549 * third one has raw op-code
553 * Calculate absolute destination
554 * relv must be on same 2K page as pc
556 relv
= adb_2b(reli
, rtp
);
558 if ((relv
& ~((a_uint
) 0x000007FF)) !=
559 ((pc
+ rtp
- rtofst
) & ~((a_uint
) 0x000007FF))) {
564 * Merge MSB with op-code,
565 * ignoring top 5 bits of address.
566 * Then hide the op-code.
568 rtval
[rtp
] = ((rtval
[rtp
] & 0x07)<<5) | rtval
[rtp
+2];
572 else if (IS_R_J19(mode
)) {
574 * BK: 19 bit jump destination for DS80C390.
575 * Forms four byte instruction with
576 * op-code bits in the MIDDLE!
577 * rtp points at 4 byte locus:
578 * first three will get the address,
579 * fourth one has raw op-code
581 relv
= adb_3b(reli
, rtp
);
584 * Calculate absolute destination
585 * relv must be on same 512K page as pc
587 if ((relv
& ~((a_uint
) 0x0007FFFF)) !=
588 ((pc
+ rtp
- rtofst
) & ~((a_uint
) 0x0007FFFF))) {
593 * Merge MSB with op-code,
594 * ignoring top 5 bits of address.
595 * Then hide the op-code.
597 rtval
[rtp
] = ((rtval
[rtp
] & 0x07)<<5) | rtval
[rtp
+3];
601 else if (IS_C24(mode
))
606 relv
= adb_3b(reli
, rtp
);
610 /* 16 bit address. */
611 relv
= adb_2b(reli
, rtp
);
615 * R3_BYTE with R3_BYTX offset adjust
617 if (mode
& R3_BYTE
) {
618 if (mode
& R3_BYTX
) {
619 rtofst
+= (a_bytes
- 1);
624 * Unsigned Byte Checking
626 if (mode
& R3_USGN
&& mode
& R3_BYTE
&& relv
& ~((a_uint
) 0x000000FF))
630 * PCR Relocation Error Checking
632 if (mode
& R3_PCR
&& mode
& R3_BYTE
) {
634 if (r
!= (a_uint
) ~0x7F && r
!= 0)
639 * Page Relocation Error Checking
641 if ((TARGET_IS_GB
|| TARGET_IS_Z80
) &&
642 mode
& R3_PAG0
&& (relv
& ~0xFF || paga
|| pags
))
644 if (mode
& R3_PAG
&& (relv
& ~0xFF))
647 if ((mode
& R_BIT
) && (relv
& ~0x87FF))
649 /* end sdld specific */
655 rerr
.aindex
= aindex
;
657 rerr
.rtbase
= rtbase
+ rtp
- rtofst
- 1;
658 rerr
.rindex
= rindex
;
659 rerr
.rval
= relv
- reli
;
660 relerr3(errmsg3
[error
]);
662 for (i
=rtp
; i
<rtp
+a_bytes
; i
++) {
679 /* 0 */ "LKRLOC3 Error List",
680 /* 1 */ "Unsigned Byte error",
681 /* 2 */ "Byte PCR relocation error",
683 /* 4 */ "Page0 relocation error",
684 /* 5 */ "Page Mode relocation error",
685 /* 6 */ "2K Page relocation error",
686 /* 7 */ "512K Page relocation error",
690 /* 10 */ "Bit-addressable relocation error",
691 /* 11 */ "Invalid address for instruction",
692 /* 12 */ "mismatched pdk targets; expected pdk15",
693 /* 13 */ "mismatched pdk targets; expected pdk14",
694 /* 14 */ "mismatched pdk targets; expected pdk13"
695 /* end sdld specific */
699 /*)Function VOID relp3()
701 * The function relp3() evaluates a P line read by
702 * the linker. The P line data is combined with the
703 * previous T line data to set the base page address
704 * and test the paging boundary and length.
708 * P 0 0 nn nn n1 n2 xx xx
710 * The P line provides the paging information to the linker as
711 * specified by a .setdp directive. The format of the relocation
712 * information is identical to that of the R line. The correspond-
713 * ing T line has the following information:
714 * T xx xx aa aa bb bb
716 * Where aa aa is the area reference number which specifies the
717 * selected page area and bb bb is the base address of the page.
718 * bb bb will require relocation processing if the 'n1 n2 xx xx' is
719 * specified in the P line. The linker will verify that the base
720 * address is on a 256 byte boundary and that the page length of an
721 * area defined with the PAG type is not larger than 256 bytes.
724 * areax **a pointer to array of area pointers
725 * int aindex area index
726 * int mode relocation mode
727 * a_uint relv relocation value
728 * int rindex symbol / area index
729 * int rtp index into T data
730 * sym **s pointer to array of symbol pointers
733 * head *hp pointer to the head structure
734 * int lkerr error flag
735 * sdp sdp base page structure
736 * FILE *stderr standard error device
739 * a_uint adb_2b() lkrloc.c
740 * a_uint evword() lkrloc.c
741 * int eval() lkeval.c
742 * int fprintf() c_library
744 * int symval() lksym.c
747 * The P and T lines are combined to set
748 * the base page address and report any
763 * Get area and symbol lists
771 if (eval() != (R3_WORD
| R3_AREA
) || eval()) {
772 fprintf(stderr
, "P input error\n");
779 aindex
= (int) evword();
780 if (aindex
>= hp
->h_narea
) {
781 fprintf(stderr
, "P area error\n");
787 * Do remaining relocations
792 rindex
= (int) evword();
795 * R3_SYM or R3_AREA references
798 if (rindex
>= hp
->h_nsym
) {
799 fprintf(stderr
, "P symbol error\n");
803 relv
= symval(s
[rindex
]);
805 if (rindex
>= hp
->h_narea
) {
806 fprintf(stderr
, "P area error\n");
810 relv
= a
[rindex
]->a_addr
;
818 aindex
= (int) adb_2b(0, 2);
819 if (aindex
>= hp
->h_narea
) {
820 fprintf(stderr
, "P area error\n");
824 sdp
.s_areax
= a
[aindex
];
825 sdp
.s_area
= sdp
.s_areax
->a_bap
;
826 sdp
.s_addr
= adb_2b(0, 4);
827 if (sdp
.s_area
->a_addr
& 0xFF || sdp
.s_addr
& 0xFF)
828 relerp3("Page Definition Boundary Error");
831 /*)Function VOID rele3()
833 * The function rele3() closes all open output files
834 * at the end of the linking process.
840 * int oflag output type flag
841 * int uflag relocation listing flag
844 * VOID lkfclose() lkbank.c
845 * VOID lkflush() lkout.c
846 * VOID lkulist() lklist.c
849 * All open output files are closed.
865 /*)Function VOID relerr3(str)
867 * char *str error string
869 * The function relerr3() outputs the error string to
870 * stderr and to the map file (if it is open).
876 * FILE *mfp handle for the map file
879 * VOID errdmp3() lkrloc3.c
882 * Error message inserted into map file.
889 errdmp3(stderr
, str
);
894 /*)Function VOID errdmp3(fptr, str)
896 * FILE *fptr output file handle
897 * char *str error string
899 * The function errdmp3() outputs the error string str
900 * to the device specified by fptr. Additional information
901 * is output about the definition and referencing of
902 * the symbol / area error.
905 * int mode error mode
906 * int aindex area index
907 * int lkerr error flag
908 * int rindex error index
909 * sym **s pointer to array of symbol pointers
910 * areax **a pointer to array of area pointers
911 * areax *raxp error area extension pointer
914 * sdp sdp base page structure
917 * int fprintf() c_library
918 * VOID prntval() lkrloc.c
925 const char errdmp3_null_srcname
[] = "<missing>";
928 errdmp3(FILE *fptr
, char *str
)
930 int mode
, aindex
, rindex
;
939 aindex
= rerr
.aindex
;
940 rindex
= rerr
.rindex
;
945 fprintf(fptr
, "\n?ASlink-Warning-%s", str
);
949 * Print symbol if symbol based
952 fprintf(fptr
, " for symbol %s\n",
953 &s
[rindex
]->s_id
[0]);
961 /* 11111111112222222222333333333344444444445555555555666666666677777*/
962 /*12345678901234567890123456789012345678901234567890123456789012345678901234*/
965 " file module area offset\n");
967 " Refby %-14.14s %-14.14s %-14.14s ",
968 (hp
->h_lfile
&& hp
->h_lfile
->f_idp
) ? hp
->h_lfile
->f_idp
: errdmp3_null_srcname
,
970 &a
[aindex
]->a_bap
->a_id
[0]);
971 prntval(fptr
, rerr
.rtbase
);
977 raxp
= s
[rindex
]->s_axp
;
981 /* 11111111112222222222333333333344444444445555555555666666666677777*/
982 /*12345678901234567890123456789012345678901234567890123456789012345678901234*/
985 " Defin %-14.14s %-14.14s %-14.14s ",
986 (raxp
->a_bhp
->h_lfile
&& raxp
->a_bhp
->h_lfile
->f_idp
) ? raxp
->a_bhp
->h_lfile
->f_idp
: errdmp3_null_srcname
,
987 &raxp
->a_bhp
->m_id
[0],
988 &raxp
->a_bap
->a_id
[0]);
990 prntval(fptr
, s
[rindex
]->s_addr
);
992 prntval(fptr
, rerr
.rval
);
996 /*)Function VOID relerp3(str)
998 * char *str error string
1000 * The function relerp3() outputs the paging error string to
1001 * stderr and to the map file (if it is open).
1007 * FILE *mfp handle for the map file
1010 * VOID erpdmp3() lkrloc3.c
1013 * Error message inserted into map file.
1020 erpdmp3(stderr
, str
);
1025 /*)Function VOID erpdmp3(fptr, str)
1027 * FILE *fptr output file handle
1028 * char *str error string
1030 * The function erpdmp3() outputs the error string str
1031 * to the device specified by fptr.
1034 * head *thp pointer to head structure
1037 * int lkerr error flag
1038 * sdp sdp base page structure
1041 * int fprintf() c_library
1042 * VOID prntval() lkrloc.c
1050 erpdmp3(FILE *fptr
, char *str
)
1054 thp
= sdp
.s_areax
->a_bhp
;
1059 fprintf(fptr
, "\n?ASlink-Warning-%s\n", str
);
1065 /* 111111111122222222223333333333444444444455555555556666666666777*/
1066 /*123456789012345678901234567890123456789012345678901234567890123456789012*/
1068 " file module pgarea pgoffset\n");
1070 " PgDef %-14.14s %-14.14s %-14.14s ",
1071 thp
->h_lfile
->f_idp
,
1073 &sdp
.s_area
->a_id
[0]);
1074 prntval(fptr
, sdp
.s_area
->a_addr
+ sdp
.s_addr
);
1078 /*)Function a_uint adb_bit(v, i)
1080 * a_uint v value to add to byte
1081 * int i rtval[] index
1083 * The function adb_bit() converts the single
1084 * byte address value contained in rtval[i] to bit-
1085 * addressable space and adds the value of v to it.
1086 * The new value of rtval[i] is returned.
1089 * a_uint j temporary evaluation variable
1098 * The value of rtval[] is changed.
1103 adb_bit(a_uint v
, int i
)
1107 j
= adb_lo(v
, i
) & 0xFF;
1108 if ((j
>= 0x20) && (j
<= 0x2F)) {
1110 } else if ((j
< 0x80) || ((j
& 0x07) != 0)) {
1111 return(0x100);//error
1115 j
= rtval
[i
+1] = j
+ (rtval
[i
] & 0x07);
1117 j
= rtval
[i
] = j
+ (rtval
[i
+1] & 0x07);
1121 /* end sdld specific */
1123 /*)Function a_uint adb_lo(v, i)
1125 * int v value to add to byte
1126 * int i rtval[] index
1128 * The function adb_lo() adds the value of v to the
1129 * value contained in rtval[i] through rtval[i + a_bytes - 1].
1130 * The new value of rtval[i] ... is returned.
1131 * The rtflg[] flags are cleared for all rtval[i] ... except
1135 * a_uint j temporary evaluation variable
1138 * hilo byte ordering parameter
1144 * The value of rtval[] is changed.
1145 * The rtflg[] values corresponding to all bytes
1146 * except the LSB of the value are cleared to reflect
1147 * the fact that the LSB is the selected byte.
1161 * LSB is lowest order byte of data
1163 m
= (hilo
? a_bytes
-1 : 0);
1164 for (n
=0; n
<a_bytes
; n
++) {
1165 if(n
!= m
) rtflg
[i
+n
] = 0;
1170 /*)Function a_uint adb_hi(v, i)
1172 * int v value to add to byte
1173 * int i rtval[] index
1175 * The function adb_hi() adds the value of v to the
1176 * value contained in rtval[i] through rtval[i + a_bytes - 1].
1177 * The new value of rtval[i] .... is returned.
1178 * The LSB rtflg[] is cleared.
1181 * a_uint j temporary evaluation variable
1184 * hilo byte ordering parameter
1190 * The value of rtval[] is changed.
1191 * The rtflg[] values corresponding to all bytes
1192 * except the 2nd byte (MSB) are cleared to reflect
1193 * the fact that the MSB is the selected byte.
1207 * MSB is next lowest order byte of data
1209 m
= (hilo
? a_bytes
-2 : 1);
1210 for (n
=0; n
<a_bytes
; n
++) {
1211 if(n
!= m
) rtflg
[i
+n
] = 0;
1217 /*)Function a_uint adb_24_bit(v, i)
1219 * a_uint v value to add to byte
1220 * int i rtval[] index
1222 * The function adb_24_bit() converts the single
1223 * byte address value contained in rtval[i] to bit-
1224 * addressable space and adds the value of v to it.
1225 * The new value of rtval[i] is returned.
1228 * a_uint j temporary evaluation variable
1237 * The value of rtval[] is changed.
1248 j
= adb_24_lo(v
, i
) & 0xFF;
1249 if ((j
>= 0x20) && (j
<= 0x2F)) {
1251 } else if ((j
< 0x80) || ((j
& 0x07) != 0)) {
1252 return(0x100);//error
1256 j
= rtval
[i
+2] = j
+ (rtval
[i
+1] & 0x07);
1258 j
= rtval
[i
] = j
+ (rtval
[i
+1] & 0x07);
1263 /*)Function a_uint adb_24_hi(v, i)
1265 * a_uint v value to add to byte
1266 * int i rtval[] index
1268 * The function adb_24_hi() adds the value of v to the
1269 * 24 bit value contained in rtval[i] - rtval[i+2].
1270 * The new value of rtval[i] / rtval[i+1] is returned.
1271 * The LSB & middle byte rtflg[] is cleared.
1274 * a_uint j temporary evaluation variable
1277 * hilo byte ordering parameter
1283 * The value of rtval[] is changed.
1284 * The rtflg[] value corresponding to the
1285 * LSB & middle byte of the word value is cleared to
1286 * reflect the fact that the MSB is the selected byte.
1299 /* Remove the lower two bytes. */
1313 /*)Function a_uint adb_24_mid(v, i)
1315 * a_uint v value to add to byte
1316 * int i rtval[] index
1318 * The function adb_24_mid() adds the value of v to the
1319 * 24 bit value contained in rtval[i] - rtval[i+2].
1320 * The new value of rtval[i] / rtval[i+1] is returned.
1321 * The LSB & MSB byte rtflg[] is cleared.
1324 * a_uint j temporary evaluation variable
1327 * hilo byte ordering parameter
1333 * The value of rtval[] is changed.
1334 * The rtflg[] value corresponding to the
1335 * LSB & MSB of the 24 bit value is cleared to reflect
1336 * the fact that the middle byte is the selected byte.
1349 /* remove the MSB & LSB. */
1356 /*)Function a_uint adb_24_lo(v, i)
1358 * a_uint v value to add to byte
1359 * int i rtval[] index
1361 * The function adb_24_lo() adds the value of v to the
1362 * 24 bit value contained in rtval[i] - rtval[i+2].
1363 * The new value of rtval[i] / rtval[i+1] is returned.
1364 * The MSB & middle byte rtflg[] is cleared.
1367 * a_uint j temporary evaluation variable
1370 * hilo byte ordering parameter
1376 * The value of rtval[] is changed.
1377 * The rtflg[] value corresponding to the
1378 * MSB & middle byte of the word value is cleared to
1379 * reflect the fact that the LSB is the selected byte.
1392 /* Remove the upper two bytes. */
1406 /*)Function VOID vpdkinst(inst, addr, ver)
1408 * int inst instruction
1410 * int ver PDK version
1412 * The function vpdkinst() tests whether the address
1413 * does not exceed the allowed maximum size of the
1417 * a_uint j temporary evaluation variable
1420 * hilo byte ordering parameter
1426 * The value of rtval[] is changed.
1427 * The rtflg[] value corresponding to the
1428 * MSB & middle byte of the word value is cleared to
1429 * reflect the fact that the LSB is the selected byte.
1434 vpdkinst(inst
, addr
, ver
)
1440 case 13: /* PDK 13 */
1441 switch (inst
& 0x1C00) {
1468 /* Address was right shifted to fit into the
1471 if ((addr
>> 1) > 0xF) {
1474 } else if (inst
& 0x100) {
1478 } else if (addr
> 0x1F) {
1484 case 14: /* PDK 14 */
1485 switch (inst
& 0x3800) {
1514 } else if ((inst
& 0x300) == 0x300) {
1518 } else if ((inst
& 0x300) == 0x200 && addr
> 0xFF) {
1520 } else if ((inst
& 0x300) == 0x100 && addr
> 0x3F) {
1526 case 15: /* PDK 15 */
1527 switch (inst
& 0x7000) {
1554 switch (inst
& 0xC00) {
1561 if (addr
> 0xFF || (addr
& 0x1)) {
1566 if ((inst
& 0x200) && addr
> 0xFF) {
1568 } else if (!(inst
& 0x200) && addr
> 0x7F) {
1581 /* end sdld specific */