Пример #1
0
void DefForward (const char* Name, const char* Comment, unsigned Offs)
/* Define a label as "* + x", where x is the offset relative to the
** current PC.
*/
{
    if (Pass == PassCount) {
        /* Flush existing output if necessary */
        if (Col > 1) {
            LineFeed ();
        }

        /* Output the forward definition */
        Output ("%s", Name);
        Indent (ACol);
        if (UseHexOffs) {
            Output (":= * + $%04X", Offs);
        } else {
            Output (":= * + %u", Offs);
        }
        if (Comment) {
            Indent (CCol);
            Output ("; %s", Comment);
        }
        LineFeed ();
    }
}
Пример #2
0
Файл: output.c Проект: cc65/cc65
void EndSegment (void)
/* End a segment */
{
    LineFeed ();
    Output ("; End of \"%s\" segment", SegmentName);
    LineFeed ();
    SeparatorLine ();
    Output (".code");
    LineFeed ();
    LineFeed ();
}
Пример #3
0
void OutputSettings (void)
/* Output CPU and other settings */
{
    LineFeed ();
    Indent (MCol);
    Output (".setcpu");
    Indent (ACol);
    Output ("\"%s\"", CPUNames[CPU]);
    LineFeed ();
    LineFeed ();
}
Пример #4
0
Файл: output.c Проект: cc65/cc65
void StartSegment (const char* Name, unsigned AddrSize)
/* Start a segment */
{
    if (Pass == PassCount) {
        LineFeed ();
        Output (".segment");
        Indent (ACol);
        SegmentName = Name;
        Output ("\"%s\"", Name);
        if (AddrSize != ADDR_SIZE_DEFAULT) {
            Output (": %s", AddrSizeToStr (AddrSize));
        }
        LineFeed ();
        LineFeed ();
    }
}
Пример #5
0
void CPrime95View::RealOutputStr (
	char	*str)
{
	char	*p;

	gwmutex_lock (&VIEW_LINES_MUTEX);
	p = Lines[0] + strlen (Lines[0]);
	for ( ; *str; str++) {
		if (*str == '\r') continue;

// When we output the first character of a line start displaying that line.
// We do this by incrementing the count of lines and scrolling the window
// We cannot scroll the screen here because the OnUpdate method calls
// SendMessage which must be processed in the main thread.  If the
// main thread has called OutputStr a deadlock will occur awaiting
// the OutputStr mutex.

		if (p == Lines[0]) {
			if (NumLines++)
				PostMessage (WM_COMMAND, USR_SCROLL, 0);
		}

// Shift the lines in memory when a newline is seen.  Otherwise, copy
// the character to the line.

		if (*str == '\n') *p = 0, LineFeed (), p = Lines[0];
		else if (p - Lines[0] < 159) *p++ = *str;
	}
	*p = 0;
	gwmutex_unlock (&VIEW_LINES_MUTEX);

// Call base class routine to refresh screen

	OnUpdate (NULL, 0, NULL);
}
Пример #6
0
void SeparatorLine (void)
/* Print a separator line */
{
    if (Pass == PassCount && Comments >= 1) {
        Output ("; ----------------------------------------------------------------------------");
        LineFeed ();
    }
}
Пример #7
0
void DefLabel (const char* Name)
/* Define a label with the given name */
{
    Output ("%s:", Name);
    /* If the label is longer than the configured maximum, or if it runs into
    ** the opcode column, start a new line.
    */
    if (Col > LBreak+2 || Col > MCol) {
        LineFeed ();
    }
}
Пример #8
0
void DefConst (const char* Name, const char* Comment, unsigned Addr)
/* Define an address constant */
{
    if (Pass == PassCount) {
        Output ("%s", Name);
        Indent (ACol);
        Output (":= $%04X", Addr);
        if (Comment) {
            Indent (CCol);
            Output ("; %s", Comment);
        }
        LineFeed ();
    }
}
Пример #9
0
void DataByteLine (unsigned ByteCount)
/* Output a line with bytes */
{
    unsigned I;

    Indent (MCol);
    Output (".byte");
    Indent (ACol);
    for (I = 0; I < ByteCount; ++I) {
        if (I > 0) {
            Output (",$%02X", CodeBuf[PC+I]);
        } else {
            Output ("$%02X", CodeBuf[PC+I]);
        }
    }
    LineComment (PC, ByteCount);
    LineFeed ();
}
Пример #10
0
void DataDByteLine (unsigned ByteCount)
/* Output a line with dbytes */
{
    unsigned I;

    Indent (MCol);
    Output (".dbyt");
    Indent (ACol);
    for (I = 0; I < ByteCount; I += 2) {
        if (I > 0) {
            Output (",$%04X", GetCodeDByte (PC+I));
        } else {
            Output ("$%04X", GetCodeDByte (PC+I));
        }
    }
    LineComment (PC, ByteCount);
    LineFeed ();
}
Пример #11
0
void DataDWordLine (unsigned ByteCount)
/* Output a line with dwords */
{
    unsigned I;

    Indent (MCol);
    Output (".dword");
    Indent (ACol);
    for (I = 0; I < ByteCount; I += 4) {
        if (I > 0) {
            Output (",$%08lX", GetCodeDWord (PC+I));
        } else {
            Output ("$%08lX", GetCodeDWord (PC+I));
        }
    }
    LineComment (PC, ByteCount);
    LineFeed ();
}
Пример #12
0
// renders inline chain, stops at first non-inline tag and returns this tag
static document_tag_t * RenderInlineChain(document_rendering_context_t *cx, document_tag_t *tag)
{
    char *text = Q_strdup("");

    while (tag && !IsBlockElement(tag))
    {
        text = Add_Inline_Tag(cx, text, tag);

        tag = tag->next;
    }

    text = StripInlineSpaces(text, cx->inline_links);
    Render_String(cx, text);
    LineFeed(cx);

    Q_free(text);

    return tag;
}
Пример #13
0
// render HR tag
static void Render_Hr(document_rendering_context_t *cx, document_tag_hr_t *hr)
{
    int i;

    document_align_t old_align = cx->align;
    cx->align = align_center;

    AddBlankLine(cx);

    cx->line_buf[cx->line_pos++] = 29;
    for (i=0; i < (cx->width - cx->l_margin - cx->r_margin) / 2; i++)
        cx->line_buf[cx->line_pos++] = 30;
    cx->line_buf[cx->line_pos++] = 31;

    LineFeed(cx);

    AddBlankLine(cx);

    cx->align = old_align;
}
Пример #14
0
static void OneLine (const OpcDesc* D, const char* Arg, ...)
/* Output one line with the given mnemonic and argument */
{
    char Buf [256];
    va_list ap;

    /* Mnemonic */
    Mnemonic (D->Mnemo);

    /* Argument */
    va_start (ap, Arg);
    xvsprintf (Buf, sizeof (Buf), Arg, ap);
    va_end (ap);
    Indent (ACol);
    Output ("%s", Buf);

    /* Add the code stuff as comment */
    LineComment (PC, D->Size);

    /* End the line */
    LineFeed ();
}
Пример #15
0
/**************************************************************************
   GeoLib-Method: GEOReadVolume
   Task: Read volume data from file
   Programing:
   07/2003 OK Implementation
**************************************************************************/
int CGLDomain::Read(char* data,FILE* f)
{
	int pos = 0,pos_s = 0;
	int p = 0;
	char* sub;
	int begin;
	int ok = 1;
	int p_sub = 0;
	char name[80];
	double ddummy;

	LineFeed(f);
	FilePrintString(f,"; ------------------------------------------");
	LineFeed(f);
	FilePrintString(f,"; GeoLib - Domain");
	LineFeed(f);

	//---------------------------------------------------------------------
	// Loop over all volumes
	while (StrTestHash(&data[p += pos],&pos))
	{
		CGLDomain* m_domain = NULL;
		m_domain = new CGLDomain;
		/* Write keyword */
		LineFeed(f);
		FilePrintString(f,"#DOMAIN");
		LineFeed(f);
		//-------------------------------------------------------------------
		// Check sub keywords
		sub = new char[(int)strlen(data) + 2];
		while (StrReadSubKeyword(sub, data, p += pos, &begin, &p))
		{
			ok = StrReadStr(name, sub, f, /*TFString,*/ &p_sub) && ok;
			pos = 0;
			//-----------------------------------------------------------------
			if (!strcmp(name, "$NAME"))
			{
				ok = (StrReadStr(name,&sub[p_sub],f,/*TFString,*/ &pos) && ok);
				LineFeed(f);
				m_domain->name = name;
			}
			//-----------------------------------------------------------------
			if (!strcmp(name, "$COORDINATES"))
			{
				pos_s = 0;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->x_min = ddummy;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->x_max = ddummy;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->y_min = ddummy;
				ok = (StrReadDouble(&ddummy,&sub[p_sub += pos_s],f,&pos_s) && ok);
				m_domain->y_max = ddummy;
				LineFeed(f);
			}
			pos = 0;
		} // sub-keyword
		delete (sub);
		// insert into list
		Insert(m_domain);
	}

	return 1;
}
Пример #16
0
void CScript_FM1232::CreateEFS( string strDDF /*= ""*/, string strADF /*= "" */ )
{
	stringstream strsRecords;
	string strLen,strTmp,strDDFFID,strEFType;
	S_ADFINFO struADFInfo;

	transform( strDDF.begin(), strDDF.end(), strDDF.begin(), toupper );
	transform( strADF.begin(), strADF.end(), strADF.begin(), toupper );
	if ( strDDF == "" )
		strDDF = "DDF0";

	vector<S_DDFINFO>::const_iterator iterSDDF = m_vecMFStruct.begin();
	while ( iterSDDF != m_vecMFStruct.end() )//遍历DDF
	{
		strTmp = (*iterSDDF).m_strDDFName;//应用环境简称
		transform(  strTmp.begin(), strTmp.end(), strTmp.begin(), toupper );
		if ( strTmp != strDDF )//不为应用环境简称时继续遍历
		{
			++iterSDDF;
			continue;
		}

		vector<S_ADFINFO>::const_iterator iterSADF = (*iterSDDF).m_vecADFInfo.begin();
		while ( iterSADF!=(*iterSDDF).m_vecADFInfo.end() )//遍历ADF
		{
			strTmp = (*iterSADF).m_strFID;
			transform(  strTmp.begin(), strTmp.end(), strTmp.begin(), toupper );
			if ( strTmp != strADF )//不为ADF文件标识符的话继续遍历(读取的数据中DF00的FID为"")
			{
				++iterSADF;
				continue;
			}

			if ( strDDF == "DDF0" && strADF == "" )//表示建MF下的所有直属EF文件
			{
				LvTwo_Annotations( "创建MF下的EF文件" );
				LvOne_Annotations( "选择MF" );
				cInst->Select_File( "MF", (*iterSDDF).m_strFID, (*iterSADF).m_strFID, "", m_bRefreshFlag );
			}
			else if ( strDDF != "DDF0" && strADF == "" )//表示建MF/DDF下的所有直属EF文件
			{
				m_strTemp = "创建 MF-"+(*iterSDDF).m_strDDFName+" 下的EF文件";
				LvTwo_Annotations( m_strTemp );
				m_strTemp = "选择"+(*iterSDDF).m_strDDFName;
				LvOne_Annotations( m_strTemp );
				cInst->Select_File( "MF", (*iterSDDF).m_strFID, (*iterSADF).m_strFID, "", m_bRefreshFlag );
			}
			else//表示建MF/ADF下的所有直属EF文件 或者 建MF/DDF/ADF下的所有直属EF文件
			{
				if ( (*iterSDDF).m_strFID == "" )
					m_strTemp = "创建 MF-"+(*iterSADF).m_strFID+" 下的EF文件";
				else
					m_strTemp = "创建 MF-"+(*iterSDDF).m_strDDFName+"-"+(*iterSADF).m_strFID+" 下的EF文件";
				LvTwo_Annotations( m_strTemp );
				m_strTemp = "选择"+(*iterSADF).m_strFID;
				LvOne_Annotations( m_strTemp );
				cInst->Select_File( "MF", (*iterSDDF).m_strFID, (*iterSADF).m_strFID, "", m_bRefreshFlag );

				//创建安全文件
				LvOne_Annotations( "创建安全文件" );
				strLen = LoadKeys( (*iterSDDF).m_strDDFName, (*iterSADF).m_strFID, strsRecords );//获取装载密钥的记录和密钥文件空间
				cInst->Create_Internal_EF( "SF", strLen, m_bRefreshFlag  );
				cInfo->Append_Script( strsRecords.str() );//添加所有的装载密钥脚本数据

				//外部认证ADF的主控密钥
				m_strTemp = "外部认证"+(*iterSADF).m_strFID+"的主控密钥";
				LvOne_Annotations( m_strTemp, m_bRefreshFlag );
				cParameter->GetADFInfo( (*iterSDDF).m_strFID, (*iterSADF).m_strFID,  struADFInfo );//获取ADF信息
				cCmd->VAR( struADFInfo.m_strMKvalue, _KEY, m_bRefreshFlag );//将ADF的MK保存到_KEY
				cInst->Get_Challenge( 8, m_bRefreshFlag );
				cCmd->RESP( 0, 8, _VAR10, m_bRefreshFlag );
				cCmd->TDES( VAR_Name(_VAR10), VAR_Name(_KEY), _VAR11, m_bRefreshFlag );
				cCmd->DES( VAR_Name(_VAR10), VAR_Name(_VAR11), _VAR12, m_bRefreshFlag );
				cInst->External_Authenticate( "00", VAR_Name(_VAR12), VAR_Name(_VAR10), 0, m_bRefreshFlag );//MK的密钥标识为00
				//引用全局PIN

				LineFeed(1);
			}

			vector<S_EFINFO>::const_iterator iterEF = (*iterSADF).m_vecEFInfo.begin();
			while ( iterEF!=(*iterSADF).m_vecEFInfo.end() )//遍历EF,建EF文件并初始化文件
			{
				//文件类型
				if ( "1" == (*iterEF).m_strEFType )
					strEFType = "定长文件";
				if ( "2" == (*iterEF).m_strEFType )
					strEFType = "变长文件";
				if ( "3" == (*iterEF).m_strEFType )
					strEFType = "透明文件";
				if ( "4" == (*iterEF).m_strEFType )
					strEFType = "循环文件";
				if ( "5" == (*iterEF).m_strEFType )
					strEFType = "内部文件";
				m_strTemp = "建立基本文件"+(*iterEF).m_strSFI+" 读:"+(*iterEF).m_strReadControl+" 写:"+(*iterEF).m_strWriteControl+" 文件类型:"+strEFType;
				LvOne_Annotations( m_strTemp, m_bRefreshFlag );
				cInst->Create_File( "MF", (*iterSDDF).m_strDDFName, (*iterSADF).m_strFID, (*iterEF).m_strSFI, m_bRefreshFlag );//建EF文件
				cInst->Select_File( "MF", (*iterSDDF).m_strFID, (*iterSADF).m_strFID, (*iterEF).m_strSFI, m_bRefreshFlag );//选当前建的EF文件
				//调用初始化文件接口写记录
				InitFile( (*iterSDDF).m_strFID, (*iterSADF).m_strFID, (*iterEF).m_strSFI );
				LineFeed(1);

				++iterEF;
			}

			break;
		}	

		break;
	}
}
Пример #17
0
unsigned TextTable (void)
/* Output a table of text messages */
{
    /* Count how many bytes may be output. */
    unsigned ByteCount = GetSpan (atTextTab);

    /* Output as many data bytes lines as needed. */
    unsigned BytesLeft = ByteCount;
    while (BytesLeft > 0) {

        unsigned I;

        /* Count the number of characters that can be output as such */
        unsigned Count = 0;
        while (Count < BytesLeft && Count < BytesPerLine*4-1) {
            unsigned char C = GetCodeByte (PC + Count);
            if (C >= 0x20 && C <= 0x7E && C != '\"') {
                ++Count;
            } else {
                break;
            }
        }

        /* If we have text, output it */
        if (Count > 0) {
            unsigned CBytes;
            Indent (MCol);
            Output (".byte");
            Indent (ACol);
            Output ("\"");
            for (I = 0; I < Count; ++I) {
                Output ("%c", GetCodeByte (PC+I));
            }
            Output ("\"");
            CBytes = Count;
            while (CBytes > 0) {
                unsigned Chunk = CBytes;
                if (Chunk > BytesPerLine) {
                    Chunk = BytesPerLine;
                }
                LineComment (PC, Chunk);
                LineFeed ();
                CBytes -= Chunk;
                PC += Chunk;
            }
            BytesLeft -= Count;
        }

        /* Count the number of bytes that must be output as bytes */
        Count = 0;
        while (Count < BytesLeft && Count < BytesPerLine) {
            unsigned char C = GetCodeByte (PC + Count);
            if (C < 0x20 || C > 0x7E || C == '\"') {
                ++Count;
            } else {
                break;
            }
        }

        /* If we have raw output bytes, print them */
        if (Count > 0) {
            DataByteLine (Count);
            PC += Count;
            BytesLeft -= Count;
        }

    }

    /* If the next line is not a byte table line, add a separator */
    if (CodeLeft() && GetStyleAttr (PC) != atTextTab) {
        SeparatorLine ();
    }

    /* Return the number of bytes output */
    return ByteCount;
}
Пример #18
0
unsigned RtsTable (void)
/* Output a table of RTS addresses (address - 1) */
{
    unsigned long BytesLeft = GetRemainingBytes ();
    unsigned long Start = PC;

    /* Loop while table bytes left and we don't need to create a label at the
    ** current position.
    */
    while (BytesLeft && GetStyleAttr (PC) == atRtsTab) {

        unsigned Addr;

        /* If just one byte is left, define it and bail out */
        if (BytesLeft == 1 || GetStyleAttr (PC+1) != atRtsTab) {
            DataByteLine (1);
            ++PC;
            break;
        }

        /* More than one byte left. Define a forward label if necessary */
        ForwardLabel (1);

        /* Now get the address from the PC */
        Addr = (GetCodeWord (PC) + 1) & 0xFFFF;

        /* In pass 1, define a label, in pass 2 output the line */
        if (Pass == 1) {
            if (!HaveLabel (Addr)) {
                AddIntLabel (Addr);
            }
        } else {
            const char* Label = GetLabel (Addr, PC);
            if (Label == 0) {
                /* OOPS! Should not happen */
                Internal ("OOPS - Label for address 0x%06X disappeard!", Addr);
            }
            Indent (MCol);
            Output (".word");
            Indent (ACol);
            Output ("%s-1", Label);
            LineComment (PC, 2);
            LineFeed ();
        }

        /* Next table entry */
        PC        += 2;
        BytesLeft -= 2;

        /* If we must define a label here, bail out */
        if (BytesLeft && MustDefLabel (PC)) {
            break;
        }
    }

    /* If the next line is not a return address table line, add a separator */
    if (CodeLeft() && GetStyleAttr (PC) != atRtsTab) {
        SeparatorLine ();
    }

    /* Return the number of bytes output */
    return PC - Start;
}
Пример #19
0
void UserComment (const char* Comment)
/* Output a comment line */
{
    Output ("; %s", Comment);
    LineFeed ();
}
Пример #20
0
static void Render_String(document_rendering_context_t *cx, char *text)
{
    int l;
    signed char c;
    document_rendered_link_t *link;

    char *txt = text;
    int t_width = cx->width - cx->l_margin - cx->r_margin;

    if (t_width < 8)    // witdth of text
        return;

    if (txt == NULL)
        return;

    // make links negative
    link = cx->inline_links;
    while (link)
    {
        link->start *= -1;
        link->end *= -1;
        link = link->next;
    }

    while ((c = *txt))
    {
        // count word length
        for (l=0 ; l < t_width; l++)
            if (isspace2(txt[l]) || txt[l]=='\n'+(char)128  ||  !txt[l])
                break;

        // word wrap
        if (l != t_width && (cx->line_pos + l > cx->width - cx->r_margin) )
            LineFeed(cx);

        // recalculate links indexes to absolute
        link = cx->inline_links;
        while (link)
        {
            int i = txt - text;

            if (link->start <= 0  &&  i >= -link->start)
                link->start = cx->line*cx->width + cx->line_pos;
            if (link->end <= 0  &&  i >= -link->end)
                link->end = cx->line*cx->width + cx->line_pos;
            link = link->next;
        }
        
        txt++;

        switch (c)
        {
        case (signed char)('\n' | 128):
            LineFeed(cx);
            break;

        case (signed char)(' ' | 128):
            cx->line_buf[cx->line_pos++] = ' ';
            break;

        default:
            cx->line_buf[cx->line_pos++] = c;
        }

        if (cx->line_pos >= cx->width - cx->r_margin)
        {
            LineFeed(cx);

            // we linefeed because of no space, so skip spaces which are next
            while (isspace2(*txt))
                txt++;
        }
    }
    LineFeed(cx);

    // add inline links to document links
    if (cx->links == NULL)
        cx->links = cx->inline_links;
    else
    {
        link = cx->links;
        while (link->next)
            link = link->next;
        link->next = cx->inline_links;
    }
    cx->inline_links = NULL;
}