src/dps8/dps8_append.c
// Translate a segno:offset to a absolute address.
// Return 0 if successful.
Translate a segno:offset to a absolute address.
Return 0 if successful.
Translate a segno : offset to a absolute address . Return 0 if successful .
int dbgLookupAddress (word18 segno, word18 offset, word24 * finalAddress,
                      char * * msg)
  {
    _ptw0 PTW1;
    _sdw0 SDW1;
   if (2u * segno >= 16u * (cpu . DSBR.BND + 1u))
     {
       if (msg)
         * msg = "DSBR boundary violation.";
       return 1;
     }
    if (cpu . DSBR . U == 0)
      {
        word24 y1 = (2 * segno) % 1024;
        word24 x1 = (2 * segno) / 1024; 
        word36 PTWx1;
        core_read ((cpu . DSBR . ADDR + x1) & PAMASK, & PTWx1, __func__);
        PTW1 . ADDR = GETHI (PTWx1);
        PTW1 . U = TSTBIT (PTWx1, 9);
        PTW1 . M = TSTBIT (PTWx1, 6);
        PTW1 . DF = TSTBIT (PTWx1, 2);
        PTW1 . FC = PTWx1 & 3;
        if (! PTW1 . DF)
          {
            if (msg)
              * msg = "!PTW0.F";
            return 2;
          }
        y1 = (2 * segno) % 1024;
        word36 SDWeven, SDWodd;
        core_read2 (((((word24)PTW1 .  ADDR & 0777760) << 6) + y1) & PAMASK, & SDWeven, & SDWodd, __func__);
        SDW1 . ADDR = (SDWeven >> 12) & 077777777;
        SDW1 . R1 = (SDWeven >> 9) & 7;
        SDW1 . R2 = (SDWeven >> 6) & 7;
        SDW1 . R3 = (SDWeven >> 3) & 7;
        SDW1 . DF = TSTBIT(SDWeven, 2);
        SDW1 . FC = SDWeven & 3;
        SDW1 . BOUND = (SDWodd >> 21) & 037777;
        SDW1 . R = TSTBIT (SDWodd, 20);
        SDW1 . E = TSTBIT (SDWodd, 19);
        SDW1 . W = TSTBIT (SDWodd, 18);
        SDW1 . P = TSTBIT (SDWodd, 17);
        SDW1 . U = TSTBIT (SDWodd, 16);
        SDW1 . G = TSTBIT (SDWodd, 15);
        SDW1 . C = TSTBIT (SDWodd, 14);
        SDW1 . EB = SDWodd & 037777;
      }
    else 
      {
        word36 SDWeven, SDWodd;
        core_read2 ((cpu . DSBR . ADDR + 2 * segno) & PAMASK, & SDWeven, & SDWodd, __func__);
        SDW1 . ADDR = (SDWeven >> 12) & 077777777;
        SDW1 . R1 = (SDWeven >> 9) & 7;
        SDW1 . R2 = (SDWeven >> 6) & 7;
        SDW1 . R3 = (SDWeven >> 3) & 7;
        SDW1 . DF = TSTBIT (SDWeven, 2);
        SDW1 . FC = SDWeven & 3;
        SDW1 . BOUND = (SDWodd >> 21) & 037777;
        SDW1 . R = TSTBIT(SDWodd, 20);
        SDW1 . E = TSTBIT(SDWodd, 19);
        SDW1 . W = TSTBIT(SDWodd, 18);
        SDW1 . P = TSTBIT(SDWodd, 17);
        SDW1 . U = TSTBIT(SDWodd, 16);
        SDW1 . G = TSTBIT(SDWodd, 15);
        SDW1 . C = TSTBIT(SDWodd, 14);
        SDW1 . EB = SDWodd & 037777;
      }
    if (SDW1 . DF == 0)
      {
        if (msg)
          * msg = "!SDW0.F != 0";
        return 3;
      }
    if (((offset >> 4) & 037777) > SDW1 . BOUND)
      {
        if (msg)
          * msg = "C(TPR.CA)0,13 > SDW.BOUND";
        return 4;
      }
    if (SDW1 . U)
      {
        * finalAddress = (SDW1 . ADDR + offset) & PAMASK;
      }
    else
      {
        word24 y2 = offset % 1024;
        word24 x2 = (offset) / 1024; 
        word36 PTWx2;
        core_read ((SDW1 . ADDR + x2) & PAMASK, & PTWx2, __func__);
        PTW1 . ADDR = GETHI (PTWx2);
        PTW1 . U = TSTBIT (PTWx2, 9);
        PTW1 . M = TSTBIT (PTWx2, 6);
        PTW1 . DF = TSTBIT (PTWx2, 2);
        PTW1 . FC = PTWx2 & 3;
        if ( !PTW1 . DF)
          {
            if (msg)
              * msg = "!PTW0.F";
            return 5;
          }
        y2 = offset % 1024;
        * finalAddress = ((((word24)PTW1 . ADDR & 0777760) << 6) + y2) & PAMASK;
      }
    if (msg)
      * msg = "";
    return 0;
  }
int dbgLookupAddress ( word18 segno , word18 offset , word24 * finalAddress , char * * msg ) { _ptw0 PTW1 ; _sdw0 SDW1 ; if ( 2u * segno >= 16u * ( cpu . DSBR . BND + 1u ) ) { if ( msg ) * msg = " " ; return 1 ; } if ( cpu . DSBR . U == 0 ) { word24 y1 = ( 2 * segno ) % 1024 ; word24 x1 = ( 2 * segno ) / 1024 ; word36 PTWx1 ; core_read ( ( cpu . DSBR . ADDR + x1 ) & PAMASK , & PTWx1 , __func__ ) ; PTW1 . ADDR = GETHI ( PTWx1 ) ; PTW1 . U = TSTBIT ( PTWx1 , 9 ) ; PTW1 . M = TSTBIT ( PTWx1 , 6 ) ; PTW1 . DF = TSTBIT ( PTWx1 , 2 ) ; PTW1 . FC = PTWx1 & 3 ; if ( ! PTW1 . DF ) { if ( msg ) * msg = " " ; return 2 ; } y1 = ( 2 * segno ) % 1024 ; word36 SDWeven , SDWodd ; core_read2 ( ( ( ( ( word24 ) PTW1 . ADDR & 0777760 ) << 6 ) + y1 ) & PAMASK , & SDWeven , & SDWodd , __func__ ) ; SDW1 . ADDR = ( SDWeven >> 12 ) & 077777777 ; SDW1 . R1 = ( SDWeven >> 9 ) & 7 ; SDW1 . R2 = ( SDWeven >> 6 ) & 7 ; SDW1 . R3 = ( SDWeven >> 3 ) & 7 ; SDW1 . DF = TSTBIT ( SDWeven , 2 ) ; SDW1 . FC = SDWeven & 3 ; SDW1 . BOUND = ( SDWodd >> 21 ) & 037777 ; SDW1 . R = TSTBIT ( SDWodd , 20 ) ; SDW1 . E = TSTBIT ( SDWodd , 19 ) ; SDW1 . W = TSTBIT ( SDWodd , 18 ) ; SDW1 . P = TSTBIT ( SDWodd , 17 ) ; SDW1 . U = TSTBIT ( SDWodd , 16 ) ; SDW1 . G = TSTBIT ( SDWodd , 15 ) ; SDW1 . C = TSTBIT ( SDWodd , 14 ) ; SDW1 . EB = SDWodd & 037777 ; } else { word36 SDWeven , SDWodd ; core_read2 ( ( cpu . DSBR . ADDR + 2 * segno ) & PAMASK , & SDWeven , & SDWodd , __func__ ) ; SDW1 . ADDR = ( SDWeven >> 12 ) & 077777777 ; SDW1 . R1 = ( SDWeven >> 9 ) & 7 ; SDW1 . R2 = ( SDWeven >> 6 ) & 7 ; SDW1 . R3 = ( SDWeven >> 3 ) & 7 ; SDW1 . DF = TSTBIT ( SDWeven , 2 ) ; SDW1 . FC = SDWeven & 3 ; SDW1 . BOUND = ( SDWodd >> 21 ) & 037777 ; SDW1 . R = TSTBIT ( SDWodd , 20 ) ; SDW1 . E = TSTBIT ( SDWodd , 19 ) ; SDW1 . W = TSTBIT ( SDWodd , 18 ) ; SDW1 . P = TSTBIT ( SDWodd , 17 ) ; SDW1 . U = TSTBIT ( SDWodd , 16 ) ; SDW1 . G = TSTBIT ( SDWodd , 15 ) ; SDW1 . C = TSTBIT ( SDWodd , 14 ) ; SDW1 . EB = SDWodd & 037777 ; } if ( SDW1 . DF == 0 ) { if ( msg ) * msg = " " ; return 3 ; } if ( ( ( offset >> 4 ) & 037777 ) > SDW1 . BOUND ) { if ( msg ) * msg = " " ; return 4 ; } if ( SDW1 . U ) { * finalAddress = ( SDW1 . ADDR + offset ) & PAMASK ; } else { word24 y2 = offset % 1024 ; word24 x2 = ( offset ) / 1024 ; word36 PTWx2 ; core_read ( ( SDW1 . ADDR + x2 ) & PAMASK , & PTWx2 , __func__ ) ; PTW1 . ADDR = GETHI ( PTWx2 ) ; PTW1 . U = TSTBIT ( PTWx2 , 9 ) ; PTW1 . M = TSTBIT ( PTWx2 , 6 ) ; PTW1 . DF = TSTBIT ( PTWx2 , 2 ) ; PTW1 . FC = PTWx2 & 3 ; if ( ! PTW1 . DF ) { if ( msg ) * msg = " " ; return 5 ; } y2 = offset % 1024 ; * finalAddress = ( ( ( ( word24 ) PTW1 . ADDR & 0777760 ) << 6 ) + y2 ) & PAMASK ; } if ( msg ) * msg = " " ; return 0 ; }
Translate a segno:offset to a absolute address.
Translate a segno : offset to a absolute address .
// Local copies so we don't disturb machine state // fetchDSPTW // floor // fetchPSDW // even word // odd word // ! DSBR . U // fetchNSDW // even word // odd word // is segment C(TPR.TSR) paged? // fetchPTW // floor