Expression Operator::operator*( const Expression & arg ) const{ return Expression(*this)*arg; }
ConstraintComponent NonsmoothOperator::operator==( const VariablesGrid& b ) const{ return Expression(*this) == b; }
/* // DotCommand // // Dot command processor // // This is the function where users add their assembler commands // // ps - Pointer to source file record // TermCnt - Number of terms (including the command) // pTerms - Pointer to the terms // Src - Buffer to write any resulting assembly line // MaxSrc - Size of assembly line buffer // // Returns: // >=0 : Success - Length of assemby line (0 to MaxSrc) // <0 : Illegal command */ int DotCommand( SOURCEFILE *ps, int TermCnt, char **pTerms, char *Src, int MaxSrc ) { int i; for(i=0; i<=DOTCMD_MAX; i++) { if( !stricmp( pTerms[0], DotCmds[i] ) ) break; } if( i>DOTCMD_MAX ) { Report(ps,REP_ERROR,"Unrecognized dot command"); return(-1); } if( i==DOTCMD_MAIN ) { char c,cs; int quote=0; int idx=0,nameidx=0; /* // .main command // // Just print a warning - its only here for compatibility */ if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } /* If the string is in quotes, skip the first charater */ if( pTerms[1][0]=='"' ) { quote++; idx++; } c = pTerms[1][idx++]; cs = ps->SourceName[nameidx++]; while( c && c!='"' ) { if( toupper(c) != toupper(cs) ) { NO_MATCH: Report(ps,REP_WARN1,".main name '%s' doesn't match '%s'", pTerms[1],ps->SourceName); return(0); } c = pTerms[1][idx++]; cs = ps->SourceName[nameidx++]; } if( cs && cs!='.' ) goto NO_MATCH; if( c=='"' ) { quote--; c = pTerms[1][idx++]; } if( c ) { Report(ps,REP_ERROR,"Trailing characters on name"); return(-1); } if( quote ) { Report(ps,REP_ERROR,"Unbalanced quotes on name"); return(-1); } return(0); } else if( i==DOTCMD_END ) { /* // .end command // // Do nothing - its only here for compatibility */ if( TermCnt != 1 ) { Report(ps,REP_ERROR,"Expected no operands"); return(-1); } return(0); } else if( i==DOTCMD_PROC ) { /* // .proc command // // Create a label from the proc name, with a leading '.' // (this is for compatibility) */ if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } sprintf( Src, ".%s:", pTerms[1] ); return(strlen(Src)); } else if( i==DOTCMD_RET ) { /* // .ret command // // Generate the line "jmp r30.w0" // This makes us compatible with "CALL", although inexplicably, // the CALL command is not a "dot" command. // */ if( TermCnt != 1 ) { Report(ps,REP_ERROR,"Expected no operands"); return(-1); } if( Options & OPTION_RETREGSET ) { Report(ps,REP_ERROR,".ret incompatible with .setcallreg, use ret"); return(-1); } if( Core > CORE_V1 ) { Report(ps,REP_ERROR,".ret illegal with specified core version, use ret"); return(-1); } strcpy( Src, "jmp r30.w0" ); return(strlen(Src)); } else if( i==DOTCMD_ORIGIN ) { int val,tmp; char tstr[TOKEN_MAX_LEN]; /* // .origin command // // Alter the origin for writing code */ if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } strcpy( tstr, pTerms[1] ); if( Expression(ps, tstr, (uint *)&val, &tmp)<0 ) { Report(ps,REP_ERROR,"Error in processing .origin value"); return(-1); } if( Core == CORE_V0 ) { Report(ps,REP_ERROR,".origin illegal with specified core version"); return(-1); } if( val<CodeOffset ) { Report(ps,REP_ERROR,".origin value is less than current offset"); return(-1); } if( CodeOffset>=0 ) Report(ps,REP_WARN1,"Resetting .origin value after use"); if( EntryPoint<0 ) EntryPoint = val; CodeOffset = val; return(0); } else if( i==DOTCMD_ENTRYPOINT ) { int val,tmp; char tstr[TOKEN_MAX_LEN]; /* // .entrypoint command // // Alter the origin for writing code */ if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } strcpy( tstr, pTerms[1] ); if( Expression(ps, tstr, (uint *)&val, &tmp)<0 ) { Report(ps,REP_ERROR,"Error in processing .entrypoint value"); return(-1); } if( Core == CORE_V0 ) { Report(ps,REP_ERROR,".entrypoint illegal with specified core version"); return(-1); } if( HaveEntry ) { Report(ps,REP_ERROR,"Multiple .entrypoint declarations"); return(-1); } EntryPoint = val; HaveEntry = 1; return(0); } else if( i==DOTCMD_STRUCT ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( StructNew(ps,pTerms[1]) ); } else if( i==DOTCMD_ENDS ) { if( TermCnt != 1 ) { Report(ps,REP_ERROR,"Expected no operands"); return(-1); } return( StructEnd(ps) ); } else if( i==DOTCMD_U32 ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( StructAddElement( ps, pTerms[1], 4 ) ); } else if( i==DOTCMD_U16 ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( StructAddElement( ps, pTerms[1], 2 ) ); } else if( i==DOTCMD_U8 ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( StructAddElement( ps, pTerms[1], 1 ) ); } else if( i==DOTCMD_ASSIGN ) { if( TermCnt != 5 ) { Report(ps,REP_ERROR,"Expected 4 operands"); return(-1); } return( StructAssign(ps, pTerms[1], pTerms[2], pTerms[3], pTerms[4]) ); } else if( i==DOTCMD_SETCALLREG ) { PRU_ARG r; if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } if( Core == CORE_V0 ) { Report(ps,REP_ERROR,".setcallreg illegal with specified core version"); return(-1); } if( Pass==1 && (Options & OPTION_RETREGSET) ) { Report(ps,REP_ERROR,".setcallreg redefinition"); return(-1); } if( CodeOffset>=0 ) { Report(ps,REP_ERROR,"Can not use .setcallreg after code generation"); return(-1); } if( !GetRegister( ps, 1, pTerms[1], &r, 0, 0 ) ) return -1; switch( r.Field ) { case FIELDTYPE_15_0: case FIELDTYPE_23_8: case FIELDTYPE_31_16: if( r.Value<31 ) { RetRegValue = r.Value; RetRegField = r.Field; Options |= OPTION_RETREGSET; return 0; } } Report(ps,REP_ERROR,"Register field must be r0 to r30 and 16 bits wide"); return(-1); } else if( i==DOTCMD_ENTER ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( ScopeEnter(ps, pTerms[1]) ); } else if( i==DOTCMD_LEAVE ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( ScopeLeave(ps, pTerms[1]) ); } else if( i==DOTCMD_USING ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( ScopeUsing(ps, pTerms[1]) ); } else if( i==DOTCMD_MACRO ) { if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } return( MacroEnter(ps, pTerms[1]) ); } else if( i==DOTCMD_MPARAM || i==DOTCMD_ENDM ) { Report(ps,REP_ERROR,"%s can not be used outside of macro",pTerms[0]); return(-1); } else if( i==DOTCMD_CODEWORD ) { uint opcode; int tmp; char tstr[TOKEN_MAX_LEN]; /* // .codeword command */ if( TermCnt != 2 ) { Report(ps,REP_ERROR,"Expected 1 operand"); return(-1); } strcpy( tstr, pTerms[1] ); if( Expression(ps, tstr, &opcode, &tmp)<0 ) { Report(ps,REP_ERROR,"Error in processing .codeword value"); return(-1); } GenOp( ps, TermCnt, pTerms, opcode ); return(0); } Report(ps,REP_ERROR,"Dot command - Internal Error"); return(-1); }
Expression NonsmoothOperator::operator/( const Expression & arg ) const{ return Expression(*this)/arg; }
ConstraintComponent NonsmoothOperator::operator>=( const Vector& lb ) const{ return Expression(*this) >= lb; }
Expression NonsmoothOperator::operator-( const Operator& arg ) const{ return Expression(*this)-arg; }
Expression NonsmoothOperator::operator*( const double & arg ) const{ return Expression(*this)*arg; }
ConstraintComponent Operator::operator>=( const double& lb ) const{ return Expression(*this) >= lb; }
ConstraintComponent Operator::operator==( const double& b ) const{ return Expression(*this) == b; }
Expression operator/( const Matrix & arg1, const Operator& arg2 ){ return arg1 / Expression(arg2); }
ConstraintComponent Operator::operator<=( const double& ub ) const{ return Expression(*this) <= ub; }
Expression operator/( const double & arg1, const Operator& arg2 ){ return arg1 / Expression(arg2); }
Expression Operator::operator/( const Operator& arg ) const{ return Expression(*this)/arg; }
Expression operator*( const Vector & arg1, const Operator& arg2 ){ return arg1 * Expression(arg2); }
ConstraintComponent operator>=( VariablesGrid ub, const Operator &arg ){ return ub >= Expression(arg); }
ConstraintComponent Operator::operator<=( const VariablesGrid& ub ) const{ return Expression(*this) <= ub; }
Expression NonsmoothOperator::operator+( const Vector & arg ) const{ return Expression(*this)+arg; }
ConstraintComponent Operator::operator>=( const VariablesGrid& lb ) const{ return Expression(*this) >= lb; }
Expression NonsmoothOperator::operator-( ) const{ return -Expression(*this); }
ConstraintComponent operator<=( Vector lb, const Operator &arg ){ return lb <= Expression(arg); }
Expression NonsmoothOperator::operator*( const Matrix & arg ) const{ return Expression(*this)*arg; }
ConstraintComponent operator==( Vector b, const Operator &arg ){ return b == Expression(arg); }
ConstraintComponent NonsmoothOperator::operator<=( const Vector& ub ) const{ return Expression(*this) <= ub; }
ConstraintComponent operator>=( Vector ub, const Operator &arg ){ return ub >= Expression(arg); }
ConstraintComponent NonsmoothOperator::operator==( const Vector& b ) const{ return Expression(*this) == b; }
ConstraintComponent operator<=( VariablesGrid lb, const Operator &arg ){ return lb <= Expression(arg); }
LongInt EngineBase::get_next_value(const String &seq_name) { return select1(Expression(get_dialect()->select_next_value(seq_name)), Expression(get_dialect()->dual_name()), Expression()).as_longint(); }
ConstraintComponent operator==( VariablesGrid b, const Operator &arg ){ return b == Expression(arg); }
void GetEA (EffAddr* A) /* Parse an effective address, return the result in A */ { unsigned long Restrictions; token_t IndirectEnter; token_t IndirectLeave; const char* IndirectExpect; /* Choose syntax for indirection */ if (BracketAsIndirect) { IndirectEnter = TOK_LBRACK; IndirectLeave = TOK_RBRACK; IndirectExpect = "']' expected"; } else { IndirectEnter = TOK_LPAREN; IndirectLeave = TOK_RPAREN; IndirectExpect = "')' expected"; } /* Clear the output struct */ A->AddrModeSet = 0; A->Expr = 0; /* Handle an addressing size override */ switch (CurTok.Tok) { case TOK_OVERRIDE_ZP: Restrictions = AM65_DIR | AM65_DIR_X | AM65_DIR_Y; NextTok (); break; case TOK_OVERRIDE_ABS: Restrictions = AM65_ABS | AM65_ABS_X | AM65_ABS_Y; NextTok (); break; case TOK_OVERRIDE_FAR: Restrictions = AM65_ABS_LONG | AM65_ABS_LONG_X; NextTok (); break; default: Restrictions = ~0UL; /* None */ break; } /* Parse the effective address */ if (TokIsSep (CurTok.Tok)) { A->AddrModeSet = AM65_IMPLICIT; } else if (CurTok.Tok == TOK_HASH) { /* #val */ NextTok (); A->Expr = Expression (); A->AddrModeSet = AM65_ALL_IMM; } else if (CurTok.Tok == TOK_A) { NextTok (); A->AddrModeSet = AM65_ACCU; } else if (CurTok.Tok == IndirectEnter) { /* One of the indirect modes */ NextTok (); A->Expr = Expression (); if (CurTok.Tok == TOK_COMMA) { /* (expr,X) or (rel,S),y */ NextTok (); if (CurTok.Tok == TOK_X) { /* (adr,x) */ NextTok (); A->AddrModeSet = AM65_ABS_X_IND | AM65_DIR_X_IND; Consume (IndirectLeave, IndirectExpect); } else if (CurTok.Tok == TOK_S) { /* (rel,s),y */ NextTok (); A->AddrModeSet = AM65_STACK_REL_IND_Y; Consume (IndirectLeave, IndirectExpect); ConsumeComma (); Consume (TOK_Y, "`Y' expected"); } else { Error ("Syntax error"); } } else { /* (adr), (adr),y or (adr),z */ Consume (IndirectLeave, IndirectExpect); if (CurTok.Tok == TOK_COMMA) { /* (adr),y */ NextTok (); switch (CurTok.Tok) { case TOK_Z: /* only set by scanner.c if in 4510-mode */ NextTok (); A->AddrModeSet = AM65_DIR_IND; break; default: Consume (TOK_Y, "`Y' expected"); A->AddrModeSet = AM65_DIR_IND_Y; break; } } else { /* (adr) */ A->AddrModeSet = (CPU == CPU_4510) ? AM65_ABS_IND : AM65_ABS_IND | AM65_ABS_IND_LONG | AM65_DIR_IND; } } } else if (CurTok.Tok == TOK_LBRACK) { /* Never executed if BracketAsIndirect feature is enabled. */ /* [dir] or [dir],y */ NextTok (); A->Expr = Expression (); Consume (TOK_RBRACK, "']' expected"); if (CurTok.Tok == TOK_COMMA) { /* [dir],y */ NextTok (); Consume (TOK_Y, "`Y' expected"); A->AddrModeSet = AM65_DIR_IND_LONG_Y; } else { /* [dir] */ A->AddrModeSet = AM65_DIR_IND_LONG | AM65_ABS_IND_LONG; } } else { /* Remaining stuff: ** ** adr ** adr,x ** adr,y ** adr,s */ A->Expr = Expression (); if (CurTok.Tok == TOK_COMMA) { NextTok (); switch (CurTok.Tok) { case TOK_X: A->AddrModeSet = AM65_ABS_LONG_X | AM65_ABS_X | AM65_DIR_X; NextTok (); break; case TOK_Y: A->AddrModeSet = AM65_ABS_Y | AM65_DIR_Y; NextTok (); break; case TOK_S: A->AddrModeSet = AM65_STACK_REL; NextTok (); break; default: Error ("Syntax error"); } } else { A->AddrModeSet = AM65_ABS_LONG | AM65_ABS | AM65_DIR; } } /* Apply addressing mode overrides */ A->AddrModeSet &= Restrictions; }
Expression Operator::operator-( ) const{ return -Expression(*this); }