- * The symbol line defines (Def) or references (Ref) the symbol
- * 'string' with the value nnnn. The defined value is relative to
- * the current area base address. References to constants and ex-
- * ternal global symbols will always appear before the first area
- * definition. References to external symbols will have a value of
- * zero.
+ * The symbol line defines (Def) or references (Ref) the symbol
+ * 'string' with the value nnnn. The defined value is relative to
+ * the current area base address. References to constants and ex-
+ * ternal global symbols will always appear before the first area
+ * definition. References to external symbols will have a value of
+ * zero.
- * The area line defines the area label, the size (ss) of the
- * area in bytes, and the area flags (ff). The area flags specify
- * the ABS, REL, CON, OVR, and PAG parameters:
+ * The area line defines the area label, the size (ss) of the
+ * area in bytes, and the area flags (ff). The area flags specify
+ * the ABS, REL, CON, OVR, and PAG parameters:
- * The R line provides the relocation information to the linker.
- * The nn nn value is the current area index, i.e. which area the
- * current values were assembled. Relocation information is en-
- * coded in groups of 4 bytes:
+ * The R line provides the relocation information to the linker.
+ * The nn nn value is the current area index, i.e. which area the
+ * current values were assembled. Relocation information is en-
+ * coded in groups of 4 bytes:
- * 1. n1 is the relocation mode and object format
- * 1. bit 0 word(0x00)/byte(0x01)
- * 2. bit 1 relocatable area(0x00)/symbol(0x02)
- * 3. bit 2 normal(0x00)/PC relative(0x04) relocation
- * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for
- * byte data
- * 5. bit 4 signed(0x00)/unsigned(0x10) byte data
- * 6. bit 5 normal(0x00)/page '0'(0x20) reference
- * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference
- * 8. bit 7 normal(0x00)/MSB of value
+ * 1. n1 is the relocation mode and object format
+ * 1. bit 0 word(0x00)/byte(0x01)
+ * 2. bit 1 relocatable area(0x00)/symbol(0x02)
+ * 3. bit 2 normal(0x00)/PC relative(0x04) relocation
+ * 4. bit 3 1-byte(0x00)/2-byte(0x08) object format for
+ * byte data
+ * 5. bit 4 signed(0x00)/unsigned(0x10) byte data
+ * 6. bit 5 normal(0x00)/page '0'(0x20) reference
+ * 7. bit 6 normal(0x00)/page 'nnn'(0x40) reference
+ * 8. bit 7 normal(0x00)/MSB of value
- * 2. n2 is a byte index into the corresponding (i.e. pre-
- * ceeding) T line data (i.e. a pointer to the data to be
- * updated by the relocation). The T line data may be
- * 1-byte or 2-byte byte data format or 2-byte word
- * format.
+ * 2. n2 is a byte index into the corresponding (i.e. pre-
+ * ceeding) T line data (i.e. a pointer to the data to be
+ * updated by the relocation). The T line data may be
+ * 1-byte or 2-byte byte data format or 2-byte word
+ * format.
- * The P line provides the paging information to the linker as
- * specified by a .setdp directive. The format of the relocation
- * information is identical to that of the R line. The correspond-
- * ing T line has the following information:
- * T xx xx aa aa bb bb
+ * The P line provides the paging information to the linker as
+ * specified by a .setdp directive. The format of the relocation
+ * information is identical to that of the R line. The correspond-
+ * ing T line has the following information:
+ * T xx xx aa aa bb bb
- * Where aa aa is the area reference number which specifies the
- * selected page area and bb bb is the base address of the page.
- * bb bb will require relocation processing if the 'n1 n2 xx xx' is
- * specified in the P line. The linker will verify that the base
- * address is on a 256 byte boundary and that the page length of an
- * area defined with the PAG type is not larger than 256 bytes.
+ * Where aa aa is the area reference number which specifies the
+ * selected page area and bb bb is the base address of the page.
+ * bb bb will require relocation processing if the 'n1 n2 xx xx' is
+ * specified in the P line. The linker will verify that the base
+ * address is on a 256 byte boundary and that the page length of an
+ * area defined with the PAG type is not larger than 256 bytes.
- * The module asout.c contains the following local variables:
- * int rel[] relocation data for code/data array
- * int * relp pointer to rel array
- * int txt[] assembled code/data array
- * int * txtp pointer to txt array
+ * The module asout.c contains the following local variables:
+ * int rel[] relocation data for code/data array
+ * int * relp pointer to rel array
+ * int txt[] assembled code/data array
+ * int * txtp pointer to txt array
-/*)Function VOID outrb(esp, r)
- *
- * expr * esp pointer to expr structure
- * int r relocation mode
- *
- * The function outrb() processes a byte of generated code
- * in either absolute or relocatable format dependent upon
- * the data contained in the expr structure esp. If the
- * .REL output is enabled then the appropriate information
- * is loaded into the txt and rel buffers.
- *
- * local variables:
- * int n symbol/area reference number
- * int * relp pointer to rel array
- * int * txtp pointer to txt array
- *
- * global variables:
- * sym dot defined as sym[0]
- * int oflag -o, generate relocatable output flag
- * int pass assembler pass number
- *
- * functions called:
- * VOID aerr() assubr.c
- * VOID outchk() asout.c
- * VOID out_lb() asout.c
- * VOID out_rb() asout.c
- * VOID out_tb() asout.c
- *
- * side effects:
- * The current assembly address is incremented by 1.
+/*)Function VOID outrb(esp, r)
+ *
+ * expr * esp pointer to expr structure
+ * int r relocation mode
+ *
+ * The function outrb() processes a byte of generated code
+ * in either absolute or relocatable format dependent upon
+ * the data contained in the expr structure esp. If the
+ * .REL output is enabled then the appropriate information
+ * is loaded into the txt and rel buffers.
+ *
+ * local variables:
+ * int n symbol/area reference number
+ * int * relp pointer to rel array
+ * int * txtp pointer to txt array
+ *
+ * global variables:
+ * sym dot defined as sym[0]
+ * int oflag -o, generate relocatable output flag
+ * int pass assembler pass number
+ *
+ * functions called:
+ * VOID aerr() assubr.c
+ * VOID outchk() asout.c
+ * VOID out_lb() asout.c
+ * VOID out_rb() asout.c
+ * VOID out_tb() asout.c
+ *
+ * side effects:
+ * The current assembly address is incremented by 1.
- if (pass == 2) {
- if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
- out_lb(lobyte(esp->e_addr),0);
- if (oflag) {
- outchk(1, 0);
- *txtp++ = lobyte(esp->e_addr);
- }
- } else {
- r |= R_BYTE | R_BYT2 | esp->e_rlcf;
- if (r & R_MSB) {
- out_lb(hibyte(esp->e_addr),r|R_RELOC|R_HIGH);
- } else {
- out_lb(lobyte(esp->e_addr),r|R_RELOC);
- }
- if (oflag) {
- outchk(2, 4);
- out_tw(esp->e_addr);
- if (esp->e_flag) {
- n = esp->e_base.e_sp->s_ref;
- r |= R_SYM;
- } else {
- n = esp->e_base.e_ap->a_ref;
- }
- *relp++ = r;
- *relp++ = txtp - txt - 2;
- out_rw(n);
- }
- }
- }
- ++dot.s_addr;
+ if (pass == 2) {
+ if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
+ out_lb(lobyte(esp->e_addr),0);
+ if (oflag) {
+ outchk(1, 0);
+ *txtp++ = lobyte(esp->e_addr);
+ }
+ } else {
+ r |= R_BYTE | R_BYT2 | esp->e_rlcf;
+ if (r & R_MSB) {
+ out_lb(hibyte(esp->e_addr),r|R_RELOC|R_HIGH);
+ } else {
+ out_lb(lobyte(esp->e_addr),r|R_RELOC);
+ }
+ if (oflag) {
+ outchk(2, 4);
+ out_tw(esp->e_addr);
+ if (esp->e_flag) {
+ n = esp->e_base.e_sp->s_ref;
+ r |= R_SYM;
+ } else {
+ n = esp->e_base.e_ap->a_ref;
+ }
+ *relp++ = r;
+ *relp++ = txtp - txt - 2;
+ out_rw(n);
+ }
+ }
+ }
+ ++dot.s_addr;
-/*)Function VOID outrw(esp, r)
- *
- * expr * esp pointer to expr structure
- * int r relocation mode
- *
- * The function outrw() processes a word of generated code
- * in either absolute or relocatable format dependent upon
- * the data contained in the expr structure esp. If the
- * .REL output is enabled then the appropriate information
- * is loaded into the txt and rel buffers.
- *
- * local variables:
- * int n symbol/area reference number
- * int * relp pointer to rel array
- * int * txtp pointer to txt array
- *
- * global variables:
- * sym dot defined as sym[0]
- * int oflag -o, generate relocatable output flag
- * int pass assembler pass number
- *
- * functions called:
- * VOID aerr() assubr.c
- * VOID outchk() asout.c
- * VOID out_lw() asout.c
- * VOID out_rw() asout.c
- * VOID out_tw() asout.c
- *
- * side effects:
- * The current assembly address is incremented by 2.
+/*)Function VOID outrw(esp, r)
+ *
+ * expr * esp pointer to expr structure
+ * int r relocation mode
+ *
+ * The function outrw() processes a word of generated code
+ * in either absolute or relocatable format dependent upon
+ * the data contained in the expr structure esp. If the
+ * .REL output is enabled then the appropriate information
+ * is loaded into the txt and rel buffers.
+ *
+ * local variables:
+ * int n symbol/area reference number
+ * int * relp pointer to rel array
+ * int * txtp pointer to txt array
+ *
+ * global variables:
+ * sym dot defined as sym[0]
+ * int oflag -o, generate relocatable output flag
+ * int pass assembler pass number
+ *
+ * functions called:
+ * VOID aerr() assubr.c
+ * VOID outchk() asout.c
+ * VOID out_lw() asout.c
+ * VOID out_rw() asout.c
+ * VOID out_tw() asout.c
+ *
+ * side effects:
+ * The current assembly address is incremented by 2.
- if (pass == 2) {
- if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
- out_lw(esp->e_addr,0);
- if (oflag) {
- outchk(2, 0);
- out_tw(esp->e_addr);
- }
- } else {
- r |= R_WORD | esp->e_rlcf;
- if (r & R_BYT2) {
- rerr();
- if (r & R_MSB) {
- out_lw(hibyte(esp->e_addr),r|R_RELOC);
- } else {
- out_lw(lobyte(esp->e_addr),r|R_RELOC);
- }
- } else {
- out_lw(esp->e_addr,r|R_RELOC);
- }
- if (oflag) {
- outchk(2, 4);
- out_tw(esp->e_addr);
- if (esp->e_flag) {
- n = esp->e_base.e_sp->s_ref;
- r |= R_SYM;
- } else {
- n = esp->e_base.e_ap->a_ref;
- }
- *relp++ = r;
- *relp++ = txtp - txt - 2;
- out_rw(n);
- }
- }
- }
- dot.s_addr += 2;
+ if (pass == 2) {
+ if (esp->e_flag==0 && esp->e_base.e_ap==NULL) {
+ out_lw(esp->e_addr,0);
+ if (oflag) {
+ outchk(2, 0);
+ out_tw(esp->e_addr);
+ }
+ } else {
+ r |= R_WORD | esp->e_rlcf;
+ if (r & R_BYT2) {
+ rerr();
+ if (r & R_MSB) {
+ out_lw(hibyte(esp->e_addr),r|R_RELOC);
+ } else {
+ out_lw(lobyte(esp->e_addr),r|R_RELOC);
+ }
+ } else {
+ out_lw(esp->e_addr,r|R_RELOC);
+ }
+ if (oflag) {
+ outchk(2, 4);
+ out_tw(esp->e_addr);
+ if (esp->e_flag) {
+ n = esp->e_base.e_sp->s_ref;
+ r |= R_SYM;
+ } else {
+ n = esp->e_base.e_ap->a_ref;
+ }
+ *relp++ = r;
+ *relp++ = txtp - txt - 2;
+ out_rw(n);
+ }
+ }
+ }
+ dot.s_addr += 2;
-/*)Function VOID outdp(carea, esp)
- *
- * area * carea pointer to current area strcuture
- * expr * esp pointer to expr structure
- *
- * The function outdp() flushes the output buffer and
- * outputs paging information to the .REL file.
- *
- * local variables:
- * int n symbol/area reference number
- * int r relocation mode
- * int * relp pointer to rel array
- * int * txtp pointer to txt array
- *
- * global variables:
- * int oflag -o, generate relocatable output flag
- * int pass assembler pass number
- *
- * functions called:
- * VOID outbuf() asout.c
- * VOID outchk() asout.c
- * VOID out_rw() asout.c
- * VOID out_tw() asout.c
- *
- * side effects:
- * Output buffer flushed to .REL fiel.
- * Paging information dumped to .REL file.
+/*)Function VOID outdp(carea, esp)
+ *
+ * area * carea pointer to current area strcuture
+ * expr * esp pointer to expr structure
+ *
+ * The function outdp() flushes the output buffer and
+ * outputs paging information to the .REL file.
+ *
+ * local variables:
+ * int n symbol/area reference number
+ * int r relocation mode
+ * int * relp pointer to rel array
+ * int * txtp pointer to txt array
+ *
+ * global variables:
+ * int oflag -o, generate relocatable output flag
+ * int pass assembler pass number
+ *
+ * functions called:
+ * VOID outbuf() asout.c
+ * VOID outchk() asout.c
+ * VOID out_rw() asout.c
+ * VOID out_tw() asout.c
+ *
+ * side effects:
+ * Output buffer flushed to .REL fiel.
+ * Paging information dumped to .REL file.
- if (oflag && pass==2) {
- outchk(HUGE,HUGE);
- out_tw(carea->a_ref);
- out_tw(esp->e_addr);
- if (esp->e_flag || esp->e_base.e_ap!=NULL) {
- r = R_WORD;
- if (esp->e_flag) {
- n = esp->e_base.e_sp->s_ref;
- r |= R_SYM;
- } else {
- n = esp->e_base.e_ap->a_ref;
- }
- *relp++ = r;
- *relp++ = txtp - txt - 2;
- out_rw(n);
- }
- outbuf("P");
- }
+ if (oflag && pass==2) {
+ outchk(HUGE,HUGE);
+ out_tw(carea->a_ref);
+ out_tw(esp->e_addr);
+ if (esp->e_flag || esp->e_base.e_ap!=NULL) {
+ r = R_WORD;
+ if (esp->e_flag) {
+ n = esp->e_base.e_sp->s_ref;
+ r |= R_SYM;
+ } else {
+ n = esp->e_base.e_ap->a_ref;
+ }
+ *relp++ = r;
+ *relp++ = txtp - txt - 2;
+ out_rw(n);
+ }
+ outbuf("P");
+ }
- * The function outchk() checks the data and relocation buffers
- * for space to insert the nt data words and nr relocation words.
- * If space is not available then output the current data and
- * initialize the data buffers to receive the new data.
+ * The function outchk() checks the data and relocation buffers
+ * for space to insert the nt data words and nr relocation words.
+ * If space is not available then output the current data and
+ * initialize the data buffers to receive the new data.
- * local variables:
- * int rel[] relocation data for code/data array
- * int * relp pointer to rel array
- * int txt[] assembled code/data array
- * int * txtp pointer to txt array
+ * local variables:
+ * int rel[] relocation data for code/data array
+ * int * relp pointer to rel array
+ * int txt[] assembled code/data array
+ * int * txtp pointer to txt array
-/*)Function VOID outgsd()
- *
- * The function outgsd() performs the following:
- * (1) outputs the .REL file radix
- * (2) outputs the header specifying the number
- * of areas and global symbols
- * (3) outputs the module name
- * (4) set the reference number and output a symbol line
- * for all external global variables and absolutes
- * (5) output an area name, set reference number and output
- * a symbol line for all global relocatables in the area.
- * Repeat this proceedure for all areas.
- *
- * local variables:
- * area * ap pointer to an area structure
- * sym * sp pointer to a sym structure
- * int i loop counter
- * int j loop counter
- * int c string character value
- * int narea number of code areas
- * char * ptr string pointer
- * int nglob number of global symbols
- * int rn symbol reference number
- *
- * global variables:
- * area * areap pointer to an area structure
- * char module[] module name string
- * sym * symhash[] array of pointers to NHASH
- * linked symbol lists
- * int xflag -x, listing radix flag
- *
- * functions called:
- * int fprintf() c_library
- * VOID outarea() asout.c
- * VOID outsym() asout.c
- * int putc() c_library
- *
- * side effects:
- * All symbols are given reference numbers, all symbol
- * and area information is output to the .REL file.
+/*)Function VOID outgsd()
+ *
+ * The function outgsd() performs the following:
+ * (1) outputs the .REL file radix
+ * (2) outputs the header specifying the number
+ * of areas and global symbols
+ * (3) outputs the module name
+ * (4) set the reference number and output a symbol line
+ * for all external global variables and absolutes
+ * (5) output an area name, set reference number and output
+ * a symbol line for all global relocatables in the area.
+ * Repeat this proceedure for all areas.
+ *
+ * local variables:
+ * area * ap pointer to an area structure
+ * sym * sp pointer to a sym structure
+ * int i loop counter
+ * int j loop counter
+ * int c string character value
+ * int narea number of code areas
+ * char * ptr string pointer
+ * int nglob number of global symbols
+ * int rn symbol reference number
+ *
+ * global variables:
+ * area * areap pointer to an area structure
+ * char module[] module name string
+ * sym * symhash[] array of pointers to NHASH
+ * linked symbol lists
+ * int xflag -x, listing radix flag
+ *
+ * functions called:
+ * int fprintf() c_library
+ * VOID outarea() asout.c
+ * VOID outsym() asout.c
+ * int putc() c_library
+ *
+ * side effects:
+ * All symbols are given reference numbers, all symbol
+ * and area information is output to the .REL file.
- register struct area *ap;
- register struct sym *sp;
- register int i, j;
- char *ptr;
- int c, narea, nglob, rn;
+ register struct area *ap;
+ register struct sym *sp;
+ register int i, j;
+ char *ptr;
+ int c, narea, nglob, rn;
- /*
- * Output Radix and number of areas and symbols
- */
- if (xflag == 0) {
- fprintf(ofp, "X%c\n", hilo ? 'H' : 'L');
- fprintf(ofp, "H %X areas %X global symbols\n", narea, nglob);
- } else
- if (xflag == 1) {
- fprintf(ofp, "Q%c\n", hilo ? 'H' : 'L');
- fprintf(ofp, "H %o areas %o global symbols\n", narea, nglob);
- } else
- if (xflag == 2) {
- fprintf(ofp, "D%c\n", hilo ? 'H' : 'L');
- fprintf(ofp, "H %u areas %u global symbols\n", narea, nglob);
- }
+ /*
+ * Output Radix and number of areas and symbols
+ */
+ if (xflag == 0) {
+ fprintf(ofp, "X%c\n", hilo ? 'H' : 'L');
+ fprintf(ofp, "H %X areas %X global symbols\n", narea, nglob);
+ } else
+ if (xflag == 1) {
+ fprintf(ofp, "Q%c\n", hilo ? 'H' : 'L');
+ fprintf(ofp, "H %o areas %o global symbols\n", narea, nglob);
+ } else
+ if (xflag == 2) {
+ fprintf(ofp, "D%c\n", hilo ? 'H' : 'L');
+ fprintf(ofp, "H %u areas %u global symbols\n", narea, nglob);
+ }
- register char *ptr;
- register int c;
-
- fprintf(ofp, "A ");
- ptr = &ap->a_id[0];
- while (ptr < &ap->a_id[NCPS]) {
- if ((c = *ptr++) != 0)
- putc(c, ofp);
- }
- if (xflag == 0) {
- fprintf(ofp, " size %X flags %X\n", ap->a_size, ap->a_flag);
- } else
- if (xflag == 1) {
- fprintf(ofp, " size %o flags %o\n", ap->a_size, ap->a_flag);
- } else
- if (xflag == 2) {
- fprintf(ofp, " size %u flags %u\n", ap->a_size, ap->a_flag);
- }
+ fprintf(ofp, "A %s", ap->a_id);
+ if (xflag == 0) {
+ fprintf(ofp, " size %X flags %X\n", ap->a_size, ap->a_flag);
+ } else
+ if (xflag == 1) {
+ fprintf(ofp, " size %o flags %o\n", ap->a_size, ap->a_flag);
+ } else
+ if (xflag == 2) {
+ fprintf(ofp, " size %u flags %u\n", ap->a_size, ap->a_flag);
+ }
- register char *ptr;
- register int c;
-
- fprintf(ofp, "S ");
- ptr = &sp->s_id[0];
- while (ptr < &sp->s_id[NCPS]) {
- if ((c = *ptr++) != 0)
- putc(c, ofp);
- }
- fprintf(ofp, " %s", sp->s_type==S_NEW ? "Ref" : "Def");
- if (xflag == 0) {
- fprintf(ofp, "%04X\n", sp->s_addr);
- } else
- if (xflag == 1) {
- fprintf(ofp, "%06o\n", sp->s_addr);
- } else
- if (xflag == 2) {
- fprintf(ofp, "%05u\n", sp->s_addr);
- }
+ fprintf(ofp, "S %s", sp->s_id);
+ fprintf(ofp, " %s", sp->s_type==S_NEW ? "Ref" : "Def");
+ if (xflag == 0) {
+ fprintf(ofp, "%04X\n", sp->s_addr);
+ } else
+ if (xflag == 1) {
+ fprintf(ofp, "%06o\n", sp->s_addr);
+ } else
+ if (xflag == 2) {
+ fprintf(ofp, "%05u\n", sp->s_addr);
+ }
- while (n--) {
- if (xflag == 0) {
- fprintf(ofp, " %02X", (*p++)&0377);
- } else
- if (xflag == 1) {
- fprintf(ofp, " %03o", (*p++)&0377);
- } else
- if (xflag == 2) {
- fprintf(ofp, " %03u", (*p++)&0377);
- }
- }
+ while (n--) {
+ if (xflag == 0) {
+ fprintf(ofp, " %02X", (*p++)&0377);
+ } else
+ if (xflag == 1) {
+ fprintf(ofp, " %03o", (*p++)&0377);
+ } else
+ if (xflag == 2) {
+ fprintf(ofp, " %03u", (*p++)&0377);
+ }
+ }