home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d110 / a68k.lha / A68k / Adirect.c < prev    next >
C/C++ Source or Header  |  1987-10-28  |  19KB  |  646 lines

  1. /*------------------------------------------------------------------*/
  2. /*                                    */
  3. /*              MC68000 Cross Assembler                */
  4. /*                                    */
  5. /*          Copyright    (c) 1985 by Brian R. Anderson            */
  6. /*                                    */
  7. /*     Assembler directive processing    - September 2, 1987        */
  8. /*                                    */
  9. /*   This program may be copied    for personal, non-commercial use    */
  10. /*   only, provided that the above copyright notice is included        */
  11. /*   on    all copies of the source code.    Copying    for any    other use   */
  12. /*   without the consent of the    author is prohibited.            */
  13. /*                                    */
  14. /*------------------------------------------------------------------*/
  15. /*                                    */
  16. /*        Originally published (in Modula-2) in            */
  17. /*        Dr.    Dobb's Journal, April, May, and June 1986.          */
  18. /*                                    */
  19. /*    AmigaDOS conversion copyright (c) 1987 by Charlie Gibbs.    */
  20. /*                                    */
  21. /*------------------------------------------------------------------*/
  22.  
  23. #include <stdio.h>
  24. #include "a68kdef.h"
  25. #include "a68kglb.h"
  26.  
  27. /* Functions */
  28. extern int  LineParts(), GetField(), Instructions();
  29. extern int  GetSize(), GetInstModeSize(), GetMultReg();
  30. extern int  ReadSymTab(), GetArgs(), GetAReg(),    OpenIncl();
  31. extern long AddrBndW(),    AddrBndL(), GetValue(),    CalcValue();
  32. extern char *malloc();
  33. extern FILE *fopen();
  34.  
  35.  
  36.  
  37. int ObjDir (f) FILE *f;
  38. /* Generates Object Code for Assembler Directives */
  39. {
  40.     register int i, j;
  41.     int     oploc,    dummy;
  42.     long newflags, templong;
  43.     char tempop[MAXLINE];
  44.  
  45.     AddrAdv = 0;
  46.  
  47.     if (strcmp (OpCode,    "ORG") == 0) {                  /* ORG */
  48.     templong = GetValue (SrcOp, SrcLoc);
  49.     if (Hunk2 < 0)
  50.         Error (SrcLoc, RelErr);    /* Can't ORG externally */
  51.     else if    (DefLine2 > LineCount)
  52.         Error (SrcLoc, FwdRef);    /* Illegal forward reference */
  53.     else {
  54.         AddrCnt = templong;
  55.         CurrHunk = Hunk2;
  56.     }
  57.     PrntAddr = TRUE;
  58.     return (Org);
  59.     }
  60.  
  61.     if (strcmp (OpCode,    "EQU") == 0) {                  /* EQU */
  62.     if (Label[0] ==    '\0')
  63.         Error (0, NeedLab);        /* Need    a label    */
  64.     ObjSrc = GetValue (SrcOp, SrcLoc);
  65.     if (DefLine2 > LineCount)
  66.         Error (SrcLoc, FwdRef);    /* Illegal forward reference */
  67.     Src.Hunk = Hunk2;
  68.     PrntAddr = TRUE;
  69.     return (Equ);
  70.     }
  71.  
  72.     if (strcmp (OpCode,    "DC") == 0) {                   /* DC */
  73.     if ((Size == Word) || (Size == Long))
  74.         AddrCnt = AddrBndW (AddrCnt);
  75.     i = SrcLoc;
  76.     while ((Line[i]    != ' ') && (Line[i] != '\0')) {
  77.         oploc = i;
  78.         if (Line[i]    == '\'') {          /* String */
  79.         i++;                /* Skip over delimiter */
  80.         while (i < strlen(Line)) {
  81.             if (Line[i]    == '\'') {  /* End of string? */
  82.             i++;            /* Check next character */
  83.             if (Line[i] != '\'')
  84.                 break;        /* End of string */
  85.             }    /* Otherwise it's an apostrophe in string */
  86.             Src.Hunk = ABSHUNK;            /* Absolute    value */
  87.             ObjString[nX++] = Line[i++];    /* Current char. */
  88.         }
  89.         } else {            /* Not a string    constant */
  90.         i = GetField (Line, i, SrcOp);
  91.         ObjSrc = GetValue (SrcOp, oploc);    /* Value */
  92.         if ((Src.Hunk =    Hunk2) != ABSHUNK) {    /* Hunk    no. */
  93.             templong = AddrCnt + nX;        /* Relocatable */
  94.             PutRel (Srec, templong, Hunk2, Size);
  95.         }
  96.         if (Size == 4) {
  97.             ObjString[nX++] = (ObjSrc >> 24) & 0x00FF;
  98.             ObjString[nX++] = (ObjSrc >> 16) & 0x00FF;
  99.         }
  100.         if (Size >= 2)
  101.             ObjString[nX++] = (ObjSrc >> 8) & 0x00FF;
  102.         ObjString[nX++]    = ObjSrc & 0x00FF;
  103.         }
  104.         if (Line[i]    == ',')
  105.         i++;            /* Skip    over separator */
  106.     }
  107.     if ((Line[i] !=    '\0') && (Line[i] != ' '))
  108.         Error (i, OperErr);        /* Didn't end properly */
  109.     AddrAdv    = InstSize = nX;
  110.     PrntAddr = TRUE;
  111.     return (DC);
  112.     }
  113.  
  114.     if (strcmp (OpCode,    "DS") == 0) {                   /* DS */
  115.     AddrAdv    = GetValue (SrcOp, SrcLoc);
  116.     if (Size == Word) {        /* Words */
  117.         AddrCnt = AddrBndW (AddrCnt);
  118.         AddrAdv <<=    1;
  119.     }
  120.     if (Size == Long) {        /* Long    words */
  121.         AddrCnt = AddrBndW (AddrCnt);
  122.         AddrAdv <<=    2;
  123.     }
  124.     if (Pass2 && (HunkType != HunkBSS)) {    /* If this isn't     */
  125.         templong = AddrAdv;            /*  a BSS hunk,         */
  126.         while (templong >= 4) {        /*  generate zeros   */
  127.         AppendSdata (f,    0L, 4);        /*  to fill the    area */
  128.         templong -= 4;
  129.         }
  130.         if (templong > 0) {
  131.         i = templong;
  132.         AppendSdata (f,    0L, i);
  133.         }
  134.     }
  135.     if (DestLoc != 0)
  136.         Error (DestLoc, OperErr);    /* Only    one operand is allowed */
  137.  
  138.     PrntAddr = TRUE;
  139.     return (DS);
  140.     }
  141.  
  142.     if (strcmp (OpCode,    "EVEN") == 0) {                /* EVEN */
  143.     AddrCnt    = AddrBndW (AddrCnt);
  144.     PrntAddr = TRUE;
  145.     return (Even);
  146.     }
  147.  
  148.     if (strcmp (OpCode,    "END") == 0) {                  /* END */
  149.     PrntAddr = TRUE;
  150.     if (Pass2)
  151.         if (SrcOp[0] != '\0')
  152.         EndAddr    = GetValue (SrcOp, SrcLoc);
  153.         else
  154.         EndAddr    = 0;
  155.     return (End);
  156.     }
  157.  
  158.     if (strcmp (OpCode,    "XDEF") == 0) {                 /* XDEF */
  159.     if (SFormat)
  160.         Error (OpLoc, NotSFmt);        /* Not in S-format */
  161.     i = SrcLoc;
  162.     while ((Line[i]    != ' ') && (Line[i] != '\0')) {
  163.         oploc = i;
  164.         i =    GetField (Line,    i, SrcOp);    /* Get a symbol    */
  165.         if (ReadSymTab (SrcOp)) {
  166.         if (!Pass2) {
  167.             if ((Sym->Flags & 0x60) == 0)
  168.             Sym->Flags |= 2;    /* Set XDEF flag */
  169.         } else {
  170.             AddRef (LineCount);
  171.             if (Sym->Defn == 0)
  172.             Error (oploc, Undef);    /* Never got defined */
  173.             else if (Sym->Flags    & 0x60)
  174.             Error (oploc, AddrErr);    /* Can't XDEF a register */
  175.         }
  176.         } else if (!Pass2) {        /* Not yet defined */
  177.         AddSymTab (SrcOp, 0L, CurrHunk,    0, 2);
  178.         }
  179.         if (Line[i]    == ',')
  180.         i++;                /* Skip    over separator */
  181.     }
  182.     return (Xdef);
  183.     }
  184.  
  185.     if (strcmp (OpCode,    "XREF") == 0) {                 /* XREF */
  186.     if (SFormat)
  187.         Error (OpLoc, NotSFmt);        /* Not in S-format */
  188.     i = SrcLoc;
  189.     while ((Line[i]    != ' ') && (Line[i] != '\0')) {
  190.         oploc = i;
  191.         i =    GetField (Line,    i, SrcOp);
  192.         if (Pass2) {
  193.         if (ReadSymTab (SrcOp) && (Sym->Defn !=    LineCount)) {
  194.             AddRef (LineCount);    /* Ignore extraneous XREF */
  195.         }
  196.         } else {
  197.         if (!ReadSymTab    (SrcOp)) {        /* Only    if not */
  198.             templong = ~(HeapLim - Heap);    /*   defined   */
  199.             templong &=    0x0000FFFF;
  200.             AddSymTab (SrcOp, 0L, templong, LineCount, 1);
  201.         }
  202.         }
  203.         if (Line[i]    == ',')
  204.         i++;            /* Skip    over separator */
  205.     }
  206.     return (Xref);
  207.     }
  208.  
  209.     if (strcmp (OpCode,    "PAGE") == 0) {                 /* PAGE */
  210.     if (Pass2)
  211.         LnCnt = LnMax;        /* Resume on a new page    */
  212.     return (Page);
  213.     }
  214.  
  215.     if (strcmp (OpCode,    "LIST") == 0) {                 /* LIST */
  216.     ListOff    = FALSE;
  217.     return (DoList);
  218.     }
  219.  
  220.     if ((strcmp(OpCode,"NOLIST")==0) || (strcmp(OpCode,"NOL")==0)) {
  221.     ListOff    = TRUE;                    /* NOLIST */
  222.     return (NoList);
  223.     }
  224.  
  225.     if (strcmp (OpCode,    "SPC") == 0) {                  /* SPC */
  226.     if (Pass2 && !ListOff && !SuppList) {
  227.         if (SrcOp[0] != '\0')
  228.         j = GetValue (SrcOp, SrcLoc);    /* Amount to space */
  229.         else
  230.         j = 1;                /* Default to one line */
  231.         for    (i = 0;    i < j; i++) {
  232.         if (LnCnt >= LnMax)
  233.             break;            /* Page    overflow */
  234.         fprintf    (List, "\n");           /* Space one line */
  235.         }
  236.     }
  237.     return (Space);
  238.     }
  239.  
  240.     if (strcmp (OpCode,    "TTL") == 0) {                  /* TTL */
  241.     for (i = SrcLoc, j = 0;    Line[i]    != '\0'; i++) {
  242.         TTLstring[j++] = Line[i];    /* Get title string */
  243.         if (j >= MAXLINE - 1)
  244.         break;            /* The string is full */
  245.     }
  246.     TTLstring[j] = '\0';
  247.     LnCnt =    LnMax;            /* Skip    to a new page */
  248.     return (Title);
  249.     }
  250.  
  251.     if (strcmp (OpCode,    "CNOP") == 0) {                 /* CNOP */
  252.     i = TRUE;            /* "Error-free" flag */
  253.  
  254.     ObjSrc = GetValue (SrcOp, SrcLoc);
  255.     if (DefLine2 > LineCount) {
  256.         Error (SrcLoc, FwdRef);    /* Illegal forward reference */
  257.         i =    FALSE;
  258.     }
  259.     if (Hunk2 != ABSHUNK) {
  260.         Error (SrcLoc, AbsReq);    /* Must    be absolute! */
  261.         i =    FALSE;
  262.     }
  263.  
  264.     ObjDest    = GetValue (DestOp, DestLoc);
  265.     if (DefLine2 > LineCount) {
  266.         Error (DestLoc, FwdRef);    /* Illegal forward reference */
  267.         i =    FALSE;
  268.     }
  269.     if (Hunk2 != ABSHUNK) {
  270.         Error (DestLoc, AbsReq);    /* Must    be absolute! */
  271.         i =    FALSE;
  272.     }
  273.  
  274.     if ((ObjDest !=    2) && (ObjDest != 4)) {
  275.         Error (DestLoc, OperErr);    /* DestOp must be 2 or 4 */
  276.         i =    FALSE;
  277.     }
  278.     if (((ObjSrc !=    0) && (ObjSrc != 2)) ||    (ObjSrc    >= ObjDest)) {
  279.         Error (SrcLoc, OperErr);    /* SrcOp must be 0 or 2    */
  280.         i =    FALSE;
  281.     }
  282.  
  283.     if (i) {                /* If no errors... */
  284.         AddrCnt = AddrBndW (AddrCnt);
  285.         if ((AddrCnt & 3L) != ObjSrc) {    /* and not aligned */
  286.         ObjOp =    NOP;
  287.         AddrAdv    = InstSize = nO    = 2;    /* generate a NOP */
  288.         PrntAddr = TRUE;
  289.         }
  290.     }
  291.     return (Cnop);
  292.     }
  293.  
  294.     if (strcmp (OpCode,    "INCLUDE") == 0) {              /* INCLUDE */
  295.     i = SrcLoc;
  296.     if ((Line[i]=='"') || (Line[i]=='\''))
  297.         i++;            /* Ignore quotes */
  298.     j = 0;
  299.     while ((Line[i]    != ' ')
  300.     && (Line[i] != '"')
  301.     && (Line[i] != '\'')
  302.     && (Line[i] != '\0'))
  303.         tempop[j++]    = Line[i++];
  304.     tempop[j] = '\0';
  305.     if (InF->UPtr == 0)
  306.         InF->Pos = ftell(InFile);    /* Position in outer file */
  307.     if (!OpenIncl (tempop, InclList)) {
  308.         Error (SrcLoc, NoIncl);    /* Couldn't open file */
  309.         if (InF->UPtr == 0)    {
  310.         InFile = fopen (InF->NPtr, "r");
  311.         fseek (InFile, InF->Pos, 0);
  312.         }
  313.         return (Include);        /* Return to outer file    */
  314.     }
  315.     InFNum++;                /* Bump    nesting    level */
  316.     if (--InF < LowInF)
  317.         LowInF = InF;
  318.     Heap2Space (strlen (tempop) + 1);    /* Check for space */
  319.     InF->UPtr = 0;                /* Not a user macro */
  320.     InF->NPtr = NextFNS;            /* New stack pointer */
  321.     strcpy (NextFNS, tempop);        /* File    name */
  322.     NextFNS    += strlen (tempop) + 1;        /* Next    available space    */
  323.     if (NextFNS > High2)
  324.         High2 = NextFNS;            /* Set high-water mark */
  325.     InF->NArg = -1;                /* Flag    as an INCLUDE */
  326.     InF->Line = 0;                /* Clear line counter */
  327.     return (Include);
  328.     }
  329.  
  330.     if (strcmp (OpCode,    "SET") == 0) {                  /* SET */
  331.     if (Label[0] ==    '\0')
  332.         Error (0, NeedLab);        /* Need    a label    */
  333.     ObjSrc = GetValue (SrcOp, SrcLoc);
  334.     if (DefLine2 > LineCount)
  335.         Error (SrcLoc, FwdRef);    /* Illegal forward reference */
  336.     Src.Hunk = Hunk2;
  337.     PrntAddr = TRUE;
  338.     if (!ReadSymTab    (Label))        /* Make    a new entry */
  339.         AddSymTab (Label, ObjSrc, Src.Hunk,    LineCount, 4);
  340.     else if    (Sym->Flags & 4) {        /* Re-SET the symbol */
  341.         Sym->Val = ObjSrc;            /* SET value */
  342.         Sym->Hunk =    Src.Hunk;        /* Hunk    number */
  343.         Sym->Defn =    LineCount;        /* Statement number */
  344.     }
  345.     return (Set);
  346.     }
  347.  
  348.     if (strcmp (OpCode,    "MACRO") == 0) {                /* MACRO */
  349.     Dir = Macro;
  350.     tempop[0] = ' ';
  351.     i = 0;                /* Prepend name    with a */
  352.     j = 1;                /*  blank and convert */
  353.     while (Label[i])        /*  it to upper    case */
  354.         tempop[j++]    = toupper (Label[i++]);
  355.     tempop[j] = '\0';
  356.  
  357.     if (!Pass2) {            /* Pass    1 */
  358.         if (Label[0] != '\0') {             /* Need a label */
  359.         templong = HeapLim - Heap;    /* Offset to text */
  360.         if (!ReadSymTab    (tempop))    /* Save    MACRO name */
  361.             AddSymTab (tempop, 0L, templong, LineCount,    8);
  362.         AddMacLine (Line);        /* Save    MACRO stmt. */
  363.  
  364.         while (strcmp (OpCode, "ENDM")) {
  365.             if (LineParts (dummy))
  366.             break;            /* Premature EOF */
  367.             AddMacLine (Line);        /* Store a line    */
  368.         }
  369.         }
  370.     } else {            /* Pass    2 */
  371.         if (Label[0] == '\0')
  372.         Error (0, NeedLab);        /* Need    a label    */
  373.         else {
  374.         ReadSymTab (tempop);
  375.         if (Sym->Defn != LineCount) {
  376.             Error (0, DupMac);        /* Duplicate MACRO */
  377.             AddRef (LineCount);
  378.         }
  379.         }
  380.         if (!SuppList)
  381.         WriteListLine (List);        /* Echo    MACRO */
  382.  
  383.         while (1) {
  384.         if (LineParts (dummy)) {
  385.             Error (OpLoc, NoENDM);    /* Premature EOF */
  386.             break;
  387.         } else {
  388.             if (strcmp (OpCode,    "ENDM") == 0)
  389.             break;
  390.             if (!SuppList)
  391.             WriteListLine (List);    /* Echo    a line */
  392.         }
  393.         }
  394.     }
  395.  
  396.     return (Macro);
  397.     }
  398.  
  399.     if (strcmp (OpCode,    "IFEQ") == 0) {                 /* IFEQ */
  400.     ObjSrc = GetValue (SrcOp, SrcLoc);
  401.     if (ObjSrc != 0)
  402.         SkipNest++;        /* Skip    to the next ENDC */
  403.     return (If);
  404.     }
  405.     if (strcmp (OpCode,    "IFNE") == 0) {                 /* IFNE */
  406.     ObjSrc = GetValue (SrcOp, SrcLoc);
  407.     if (ObjSrc == 0)
  408.         SkipNest++;
  409.     return (If);
  410.     }
  411.     if (strcmp (OpCode,    "IFGT") == 0) {                 /* IFGT */
  412.     ObjSrc = GetValue (SrcOp, SrcLoc);
  413.     if (ObjSrc <= 0)
  414.         SkipNest++;
  415.     return (If);
  416.     }
  417.     if (strcmp (OpCode,    "IFGE") == 0) {                 /* IFGE */
  418.     ObjSrc = GetValue (SrcOp, SrcLoc);
  419.     if (ObjSrc < 0)
  420.         SkipNest++;
  421.     return (If);
  422.     }
  423.     if (strcmp (OpCode,    "IFLT") == 0) {                 /* IFLT */
  424.     ObjSrc = GetValue (SrcOp, SrcLoc);
  425.     if (ObjSrc >= 0)
  426.         SkipNest++;
  427.     return (If);
  428.     }
  429.     if (strcmp (OpCode,    "IFLE") == 0) {                 /* IFLE */
  430.     ObjSrc = GetValue (SrcOp, SrcLoc);
  431.     if (ObjSrc > 0)
  432.         SkipNest++;
  433.     return (If);
  434.     }
  435.     if (strcmp (OpCode,    "IFC") == 0) {                  /* IFC */
  436.     if (strcmp (SrcOp, DestOp) != 0)
  437.         SkipNest++;
  438.     return (If);
  439.     }
  440.     if (strcmp (OpCode,    "IFNC") == 0) {                 /* IFNC */
  441.     if (strcmp (SrcOp, DestOp) == 0)
  442.         SkipNest++;
  443.     return (If);
  444.     }
  445.     if (strcmp (OpCode,    "IFD") == 0) {                  /* IFD */
  446.     if (ReadSymTab (SrcOp))
  447.         AddRef (LineCount);
  448.     if (DefLine2 > LineCount)
  449.         SkipNest++;
  450.     return (If);
  451.     }
  452.     if (strcmp (OpCode,    "IFND") == 0) {                 /* IFND */
  453.     if (ReadSymTab (SrcOp))
  454.         AddRef (LineCount);
  455.     if (DefLine2 <=    LineCount)
  456.         SkipNest++;
  457.     return (If);
  458.     }
  459.  
  460.     if (strcmp (OpCode,    "ENDC") == 0)                   /* ENDC */
  461.     return (EndC);                /* Just    ignore it */
  462.  
  463.     if ((strcmp    (OpCode, "CODE") == 0)                  /* CODE */
  464.     || (strcmp (OpCode,    "DATA") == 0)                   /* DATA */
  465.     || (strcmp (OpCode,    "BSS") == 0)) {                 /* BSS */
  466.     strcpy (DestOp,    OpCode);    /* Convert to corresponding */
  467.     strcpy (OpCode,    "SECTION");     /*  SECTION directive */
  468.     }
  469.     if (strcmp (OpCode,    "SECTION") == 0) {              /* SECTION */
  470.     if (SFormat)
  471.         Error (OpLoc, NotSFmt);        /* Not in S-format */
  472.     PrntAddr = TRUE;
  473.  
  474.     for (i = 0; DestOp[i]; i++)        /* Convert section type    */
  475.         DestOp[i] =    toupper    (DestOp[i]);    /*  to upper case */
  476.     if ((DestOp[0] == '\0') || (strcmp (DestOp, "CODE") == 0))
  477.         newflags = HunkCode;        /* Code    section    */
  478.     else if    (strcmp    (DestOp, "DATA") == 0)
  479.         newflags = HunkData;        /* Data    section    */
  480.     else if    (strcmp    (DestOp, "BSS") == 0)
  481.         newflags = HunkBSS;            /* BSS section */
  482.     else {
  483.         Error (DestLoc, OperErr);        /* Invalid type    */
  484.         strcpy (DestOp, "CODE");
  485.         newflags = HunkCode;        /* Make    it CODE    */
  486.     }
  487.     newflags <<= 16;    /* Shift to high-order 16 bits */
  488.  
  489.     tempop[0] = '\0';
  490.     j = DestLoc + strlen (DestOp);        /* Check for flags */
  491.     if (Line[j] == ',') {
  492.         j++;
  493.         GetField (Line, j, tempop);        /* Get specification */
  494.         for    (i = 0;    tempop[i]; i++)            /* Convert to */
  495.         tempop[i] = toupper (tempop[i]);    /* upper case */
  496.         if (strcmp (tempop,    "CHIP") == 0)
  497.         newflags |= MEMF_CHIP;            /* CHIP    memory */
  498.         else if (strcmp (tempop, "FAST") == 0)
  499.         newflags |= MEMF_FAST;            /* FAST    memory */
  500.         else
  501.         Error (j, OperErr);            /* Invalid */
  502.     }
  503.  
  504.     if (SrcOp[0] ==    '\0') {                 /* Unnamed section */
  505.         if ((strcmp    (DestOp, "DATA") == 0)
  506.         || (strcmp (DestOp,    "BSS") == 0)) {
  507.         Error (SrcLoc, NoSecNam);    /* Must    be named */
  508.         return (Section);
  509.         }
  510.     }
  511.     AddrCnt    = AddrBndL (AddrCnt);    /* Finish on long word */
  512.     strcpy (tempop,    "  ");          /* Two leading blanks */
  513.     strcat (tempop,    SrcOp);        /* Section name    */
  514.     if (ReadSymTab (tempop)) {    /* Scan    for section name */
  515.         if ((Sym->Hunk & 0xFFFF0000L) != (newflags & 0xFFFF0000L)) {
  516.         Error (DestLoc,    WrongTyp);    /* Continuation    in a */
  517.         return (Section);        /*  different type */
  518.         }
  519.         if (HunkType != HunkNone) {
  520.         if (Pass2) {
  521.             AddRef (LineCount);
  522.             DumpSdata (Srec);        /* Previous hunk's data */
  523.             if (!SFormat) {
  524.             templong = HunkEnd;    /* End of */
  525.             putl (Srec, templong);    /*  previous hunk */
  526.             }
  527.         }
  528.         Sect->Val = AddrCnt;        /* End of old section */
  529.         }
  530.         Sect = Sym;                /* Point to new    section    */
  531.         SectLine = LineCount;
  532.         AddrCnt = SectStart    = Sym->Val;    /* Continuation    */
  533.         TempAddr = StartAddr = AddrCnt;
  534.         CurrHunk = Sym->Hunk & 0x0000FFFFL;        /* Hunk    no. */
  535.         HunkType = (Sym->Hunk & 0x3FFF0000L) >> 16;    /* Type    */
  536.         HunkFlags =    Sym->Hunk & 0xC0000000L;    /* Flags */
  537.         if (Pass2 && !SFormat) {        /* Start a new hunk */
  538.         templong = HunkName;
  539.         putl (f, templong);
  540.         if (SrcOp[0])
  541.             DumpName (f, SrcOp,    0L);    /* Hunk    name */
  542.         else
  543.             DumpName (f, " ", 0L);
  544.         putl (f, HunkType);    /* Hunk    type */
  545.         LenPos = ftell (f);    /* Hunk    length goes here */
  546.         putl (f, 0L);        /* For now, set    it to zero */
  547.         }
  548.         return (Section);
  549.     }
  550.     if (Pass2) {
  551.         Error (OpLoc, ManySect);    /* Table overflowed in pass 1 */
  552.         return (Section);
  553.     }
  554.     if (NextHunk >=    ABSHUNK)    /* Set up a new    table entry */
  555.         return (Section);        /* Section table overflow */
  556.  
  557.     if (HunkType !=    HunkNone)
  558.         Sect->Val =    AddrCnt;    /* End of old section */
  559.  
  560.     AddrCnt    = SectStart = 0L;    /* Reset location counter */
  561.     TempAddr = StartAddr = AddrCnt;
  562.     HunkType = (newflags & 0x3FFF0000L) >> 16;    /* Type    */
  563.     HunkFlags = newflags & 0xC0000000L;        /* Flags */
  564.     SectLine = LineCount;        /* Starting line number    */
  565.     CurrHunk = NextHunk++;        /* Bump    next hunk number */
  566.     newflags |= CurrHunk;        /* Add hunk number */
  567.     AddSymTab (tempop, 0L, newflags, LineCount, 16); /* New    entry */
  568.     Sect = Sym;            /* Pointer to new entry    */
  569.     return (Section);
  570.     }
  571.  
  572.     if (strcmp (OpCode,    "IDNT") == 0) {                 /* IDNT */
  573.     i = SrcLoc;
  574.     if (Line[i] == '"')
  575.         i++;        /* Ignore quotation marks */
  576.     j = 0;
  577.     while ((Line[i]    != ' ') && (Line[i] != '"') && (Line[i] != '\0'))
  578.         IdntName[j++] = Line[i++];
  579.     IdntName[j] = '\0';
  580.     return (Idnt);
  581.     }
  582.  
  583.     if (strcmp (OpCode,    "DCB") == 0) {                  /* DCB */
  584.     if ((Size == Word) || (Size == Long))
  585.         AddrCnt = AddrBndW (AddrCnt);
  586.     ObjSrc = GetValue (SrcOp, SrcLoc);    /* Replication factor */
  587.     if (DefLine2 > LineCount) {
  588.         Error (SrcLoc, FwdRef);    /* Illegal forward reference */
  589.         ObjSrc = 0;
  590.     }
  591.     if (Hunk2 != ABSHUNK) {
  592.         Error (SrcLoc, AbsReq);    /* Must    be absolute! */
  593.         ObjSrc = 0;
  594.     }
  595.     ObjDest    = GetValue (DestOp, DestLoc);    /* Value to replicate */
  596.     Dest.Hunk = Hunk2;
  597.     for (i = 0; i <    ObjSrc;    i++) {
  598.         if (nX >= MAXLINE) {
  599.         Error (SrcLoc, DCOflo);        /* ObjString overflowed    */
  600.         break;
  601.         }
  602.         if (Dest.Hunk != ABSHUNK) {
  603.         templong = AddrCnt + nX;    /* Relocatable */
  604.         PutRel (Srec, templong,    Hunk2, Size);
  605.         }
  606.         if (Size ==    4) {
  607.         ObjString[nX++]    = (ObjDest >> 24) & 0x00FF;
  608.         ObjString[nX++]    = (ObjDest >> 16) & 0x00FF;
  609.         }
  610.         if (Size >=    2)
  611.         ObjString[nX++]    = (ObjDest >> 8) & 0x00FF;
  612.         ObjString[nX++] = ObjDest &    0x00FF;
  613.     }
  614.     AddrAdv    = InstSize = nX;
  615.     PrntAddr = TRUE;
  616.     return (DCB);
  617.     }
  618.  
  619.     if (strcmp (OpCode,    "EQUR") == 0) {                 /* EQUR */
  620.     if ((i = IsRegister (SrcOp, strlen (SrcOp))) < 0)
  621.         Error (SrcLoc, AddrErr);    /* Not a valid register    */
  622.     if (Label[0] ==    '\0')
  623.         Error (0, NeedLab);        /* Need    a label    */
  624.     else {
  625.         if (!ReadSymTab (Label))    /* Make    a new entry */
  626.         AddSymTab (Label, (long) i, 0L,    LineCount, 0x20);
  627.         GotEqur = TRUE;        /* We have at least one    EQUR */
  628.     }
  629.     return (Equr);
  630.     }
  631.  
  632.     if (strcmp (OpCode,    "REG") == 0) {                  /* REG */
  633.     if (Label[0] ==    '\0')
  634.         Error (0, NeedLab);        /* Need    a label    */
  635.     else {
  636.         i =    GetMultReg (SrcOp, FALSE, SrcLoc);
  637.         if (!ReadSymTab (Label))    /* Make    a new entry */
  638.         AddSymTab (Label, (long) i, 0L,    LineCount, 0x40);
  639.         GotEqur = TRUE;        /* We have at least one    EQUR */
  640.     }
  641.     return (Reg);
  642.     }
  643.  
  644.     return (None);                /* Not a directive */
  645. }
  646.