📄 mcode.cpp
字号:
// MCODE.cpp: implementation of the MCODE class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "AM.h"
#include "MCODE.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/*
MCODE::MCODE()
{
for(int i=0;i<8;i++)section[i]=0;
}
MCODE& MCODE::operator=(char* word)
{
int i,j,k;
}
void MCODE::cvrt(char ch,char* string)
{
int num=(int)ch;
int temp;
int low=128;
int hight=256;
int i=0;
while(1){
temp=(num%hight)/low;
if(temp<=9)string[i]=temp+'0';
else string[i]=temp-10+'A';
if((++i)==2)break;
hight=low;
low/=16;
}
string[i]=0;
}
void MCODE::get(CString& word)
{
char temp[3];
cvrt(section[0],temp);
word=temp;
cvrt(section[1],temp);
word+=temp;
for(int i=2;i<8;i+=2){
word+=" ";
cvrt(section[i],temp);
word+=temp;
cvrt(section[i+1],temp);
word+=temp;
}
}
*/
void MCODE::Set(CString number)
{
char c;
//--获得下地址------------------------------------------------
int addr = 0;
for ( int i = 0; i < 2; i++ ){
c = number.GetAt(i);
if ( c <= '9' && c >= '0' ){
c -= '0';
addr *= 16;
addr += c;
}
else {
if ( c >= 'a' && c <= 'f' )
c -= 0x20;
c =c - 'A' + 10;
addr *= 16;
addr += c;
}
}
c = number.GetAt(3);
if ( c <= '9' && c >= '0' ){
c -= '0';
c/=4;
addr *= 4;
addr += c;
}
else {
if ( c >= 'a' && c <= 'f' )
c -= 0x20;
c =c - 'A' + 10;
c/=4;
addr *= 4;
addr += c;
}
m_naddr=addr;
//--获得CI3-0--------------------------------------------------
c = number.GetAt(4);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
m_ci = c;
//--获得SCC----------------------------------------------------
c = number.GetAt(5);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c /= 2;
m_scc = c;
//--获得SC-----------------------------------------------------
c = number.GetAt(5);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 1;
m_sc = c;
//--获得SST----------------------------------------------------
c = number.GetAt(6);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 7;
m_sst = c;
//--获得MRW----------------------------------------------------
int mrw = 0;
for ( i = 8; i <= 10; i++ ){
c = number.GetAt(i);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c /= 8;
mrw *= 2;
mrw += c;
}
m_mrw = mrw;
//--获得I86----------------------------------------------------
c = number.GetAt(8);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 7;
m_i86 = c;
//--获得I53-----------------------------------------------------
c = number.GetAt(9);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 7;
m_i53 = c;
//--获得I20-----------------------------------------------------
c = number.GetAt(10);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 7;
m_i20 = c;
//--获得A口地址-----------------------------------------------------
c = number.GetAt(11);
if ( c >= 48 && c <= 57 )
m_a = c - 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
m_a = c;
}
//--获得B口地址-----------------------------------------------------
c = number.GetAt(13);
if ( c >= 48 && c <= 57 )
m_b = c - 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
m_b = c;
}
//--获得SCI-----------------------------------------------------
c = number.GetAt(14);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c /= 4;
m_sci = c;
//--获得SSH-----------------------------------------------------
c = number.GetAt(14);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 3;
m_ssh = c;
//--获得SA-----------------------------------------------------
c = number.GetAt(15);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c /= 8;
m_sa = c;
//--获得DC1-----------------------------------------------------
c = number.GetAt(15);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 7;
m_dc1 = c;
//--获得SB-----------------------------------------------------
c = number.GetAt(16);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c /= 8;
m_sb = c;
//--获得DC2-----------------------------------------------------
c = number.GetAt(16);
if ( c <= 57 && c >= 48 )
c -= 48;
else {
if ( c >= 97 && c <= 102 )
c -= 32;
c -= 55;
}
c &= 7;
m_dc2 = c;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -