⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdatblock_c.cpp

📁 MCS51单片机的宏汇编器源程序。有需要的朋友请下载!
💻 CPP
字号:
//---------------------------------------------------------------------------
//-------- JdatBlock_C.cpp --------------------------------------------------
//---------------------------------------------------------------------------


#include "Jstring_H.h"
#include "Tokens_H.h"
#include "JsGlobal_H.h"
#include "JdatBlock_H.h"
//---------------------------------------------------------------------------


#define Debugs(str)          str


//---------------------------------------------------------------------------
bool JdatBlock::AddByte(int8u byte)
{ if(len < 255)
   { dat[len++] = byte; return true; } // endif
  else { Debugs(printf("Can not add.");) return false; } // end else
} // end AddByte
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
bool JdatBlock::AddWord(int16u word)
{ if(len < 254)
   { pool_16 pod;
     pod.pot16 = word;
     int8u* p = dat + len;
     *p = pod.highbyte; *++p = pod.lowbyte;
     len += 2;
     return true; } // endif
  else { Debugs(printf("Can not add.");) return false; } // end else
} // end AddWord
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------
bool JdatBlock::merge(const JdatBlock& obj)
{ if(len + obj.len > 255)
   { Debugs(printf("Block too large.");) return false; } // endif
  int8u* des = dat + len;
  const int8u* src = obj.dat;
  for(int8u i = 0; i < obj.len; i++) { *des++ = *src++; } // endfor
  len += obj.len;
  return true;
} // end merge
//---------------------------------------------------------------------------

//#pragma warn -8098
//---------------------------------------------------------------------------
// mode = 0  LongChar
// mode = 1, string
//---------------------------------------------------------------------------
void JdatBlock::LoadData(const Jstring& obj,int8u mode)
{ if(obj.getLen() >= 255)
   { Debugs(printf("Data too large.");) return; }
  int8u* des = dat;
  const int8u* src = (const char*)obj;
  if(mode)             // mode = string    1
   { if(obj.getLen() > 2) { ++src; } // endif
     else  // 是空串
      { *des = '\0'; len = 0; return; }  // end else
     while(*src)
      { switch(*(int16u*)src)
        { case '\"\"' : *des++ = '\"'; src += 2; break;
          default     : *des++ = *src++;
        } // end switch
      } // end while
     len = des - dat -1;
   } // endif mode = string    1
  else  // mode = LongChar  0
   { while(*src)
      { switch(*(int16u*)src)
        { case '\'\'' : *des++ = '\''; src += 2; break;
          default     : *des++ = *src++;
        } // end switch
      } // end while
     len = des - dat;
   } // end else
} // end LoadData
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void JdatBlock::show()const
{ printf("\n Block len=%d Data=[",len);
  for(register int8u i = 0; i < len; ++i )
   { printf(" %2.2x",dat[i]); } // end for
  printf(" ]");
} // end show
//---------------------------------------------------------------------------

#undef Debugs(str)
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// end JdatBlock_C.cpp
//---------------------------------------------------------------------------
//               Written by JamesyFront.    ZLGmcu Dev.Co.Ltd.  2002.
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -