Exemple #1
0
void parse_msr( void )
{
	while ( 1 ) {
		int f;
		char *p = gettoken( &f );
		//char a;
		if ( !p ) break;
		//a = *p;
		if ( f & TT_LABEL ) {
			int n = strlen(p);
			if ( p[n-1] == ':' ) p[n-1] = 0;
			RegLabel( p );
		}
		else if ( f & TT_NUMBER ) {
			cgout1( getnum( p ) );
		}
		else if ( f & TT_STRING ) {
			int i, n = strlen( p );
			if ( n > 2 && p[0] == p[n-1] ) n--;
			for ( i = 1; i < n; i++ ) cgout1( p[i] );
		}
		else if ( f & TT_OTHER ) {
			HASHDATA *phd = SearchHash( p );
			if ( phd ) {
				if ( phd->type == TYPE_RESERVED )
					switch ( phd->value ) {
						case RSV_ADRS:
							adrs();
							break;
						case RSV_ADRSM:
							adrsm();
							break;
						case RSV_ADRSD:
							adrsd();
							break;
						case RSV_INCLUDE:
							include();
							break;
						case RSV_GOTO:
							_goto();
							break;
						case RSV_TEMPO:
							tempo();
							break;
						case RSV_PARTN:
							partn();
							break;
						case RSV_PHRASE:
							phrase();
							break;
				}
				else if ( phd->type & TYPE_DIRECTCODE ) {
					cgout1( phd->value );
				}
			}
			else {
				error( "Unkown commands '%s'.", p );
			}
		}
		else if ( f & TT_MML ) {
			parse_mml_line( -1, p );
		}
	}
}
Exemple #2
0
	void Imm2asm::_translateLine( TokenList& tokenList )
	{
		std::string code;

		SetRegBaseNum(tokenList);		

		if ( tokenList[ 0 ] == "if" )
		{
			code = _if(tokenList);
		}
		else if ( tokenList[ 0 ] == "iffalse" )
		{
			code = _iffalse(tokenList );
		}
		else if ( tokenList[ 0 ] == "goto" )
		{
			code = _goto( tokenList );
		}
		else if ( tokenList[ 0 ] == "Lineno" )
		{
			code = "mov d0, " + tokenList[ 1 ];
			m_bNewStmt = true;
		}
		else if ( tokenList[ 0 ] == "Label" )
		{
			m_label = combinationToInt( tokenList[ 1 ] );
		}
		else if ( tokenList[ 0 ] == "entry" )
		{
			//code = tokenList[ 0 ] + " " + tokenList[ 1 ];
			m_pCurTable = m_pTables->GetTable( tokenList[ 1 ] );
		}
		else if ( tokenList[ 0 ] == "arg" )
		{
			code = tokenList[ 0 ] + " " + temp2reg( tokenList[ 1 ] );
		}
		else if ( tokenList[ 0 ] == "call" )
		{
			code = tokenList[ 0 ] + " " + itoa( m_entryMap[ tokenList[ 1 ] ] );
		}
		else if ( tokenList[ 0 ] == "halt" )
		{
			code = tokenList[ 0 ];
		}
		else if ( tokenList[ 0 ] == "push" )
		{
			code = tokenList[ 0 ] + " " + tokenList[ 1 ];
		}
		else if ( tokenList[ 0 ] == "pop" )
		{
			code = tokenList[ 0 ] + " " + temp2reg( tokenList[ 1 ] );
		}
		else if ( tokenList[ 0 ] == "mov") 
		{
			code = tokenList[ 0 ] + " " + tokenList[ 1 ] + ", " + tokenList[ 2 ];
		}
		else if ( tokenList[ 0 ] == "read" )
		{
			code = "in " + temp2reg( tokenList[ 1 ] );
		}
		else if ( tokenList[ 0 ] == "write" )
		{
			code = "out " + temp2reg( tokenList[ 1 ] );
		}
		else if ( tokenList.size() >= 3 && tokenList[ 1 ] == "=" )
		{
			code = GenAssign( tokenList );
		}
		else
		{
			//std::cout << "error!!!!!!!!!\n";
			for ( auto iter = tokenList.begin(); iter != tokenList.end(); iter++ )
			{
				code += *iter + " ";
			}
		}

		if ( code != "" )	
		{
			AddToASM(code);
		}
	}
Exemple #3
0
// shitty benannt: el als neues item des list entries mit index idx
void l_insert_at(list *l, void *el, int idx){
    node *element = _goto(l, idx);
    element->item = el;
}
Exemple #4
0
void* l_prev(list *l, int pos){
    assert((pos - 1) >= 0);
    return _goto(l, pos - 1);
}
Exemple #5
0
void* l_next(list *l, int pos){
assert((pos + 1) <= l->len);
    return _goto(l, pos + 1);
}
Exemple #6
0
void* l_retrieve(list *l, int idx){
    assert(idx < l->len && idx >= 0);

    node *n = _goto(l, idx);
    return n->item;
}