int main(int argc, char *argv[]) { E_RT_init(argc, argv); JMP(begin); Label0: R005=ADD(R000,2); STI(R001, R000); R000=SUB(R000,1); MOVI(R000, R001); LDI(R005, R008); R005=ADD(R005,1); LDF(R005, F001); R005=ADD(R005,1); MOVIF(R008, F003); MOVIF(R008, F006); F005=FADD(F006,F001); MOVF(F005, F008); R010=ADD(R008,1); MOVI(R010, R011); MOVI(R010, R012); MOVIF(R008, F010); MOVF(F005, F011); while_1_start: JMPC(GT(1000, R008), while_1_begin); JMP(while_1_end); while_1_begin: MOVIF(R008, F013); MOVIF(R008, F014); F008=FADD(F014,F001); F001=FMUL(F001,2.0); R008=ADD(R008,100); JMP(while_1_start); while_1_end: PRTF(F008); PRTS(R007); MOVI(R008, R002); JMP(Label1); Label1: MOVI(R001, R000); R000=ADD(R000,1); LDI(R000, R001); R000=ADD(R000,1); LDI(R000, R004); R000=ADD(R000,2); JMPI(R004); eventLabel_a: INI(R010); INF(F013); STI(R010, R000); R000=SUB(R000,1); STF(F013, R000); R000=SUB(R000,1); STF(F013, R000); R000=SUB(R000,1); STI(R010, R000); R000=SUB(R000,1); MOVL(Label2, R004); STI(R004, R000); R000=SUB(R000,1); JMP(Label0); Label2: MOVI(R002, R006); R000=ADD(R000,1); LDF(R000, F013); R000=ADD(R000,1); LDI(R000, R010); JMP(EventMStart); begin: MOVI(10000, R000); MOVI(0, R006); MOVS("\n", R007); IN(R010); IN(R010); IN(R010); EventMStart: IN(R010); JMPC(GT(64, R010), EventMOut); JMPC(EQ(97, R010), eventLabel_a); JMP(EventMStart); EventMOut: PRTS("\nDone\n"); E_RT_exit(); return 0; }
void PIC::decodeCmd(int pc) { // { qDebug() << "CMDLIST" <<m_CmdList[pc]; //qDebug() << pc << "PC"; k_long=m_CmdList[pc] & 0x7FF; //qDebug() << k_long << "klong"; k=m_CmdList[pc] & 0xFF; qDebug() << k << "k"; f=m_CmdList[pc] & 0x7F; //qDebug() << f <<"f"; d=m_CmdList[pc] & 0x80; d=(d>>7); //Test l=d; b=m_CmdList[pc] & 0x380; b = b / 128; //qDebug() << b << "b"; qDebug() << PreScalerWert << "PreScalerWert"; PIC::getPreScaler(); PIC::SetBank(); PIC::ChkIndirect(); CheckIndirect(); int ByteCmd=m_CmdList[pc] & 0x3F00; //qDebug() << ByteCmd << "byteCMD"; int BitCmd=m_CmdList[pc] & 0x3C00; //qDebug() << BitCmd << "BitCMD"; int ShrtCmd=m_CmdList[pc] & 0x3800; //qDebug() << ShrtCmd << "ShrtCMD"; if(ByteCmd == 0x0700 ) ADDWF(); else if(ByteCmd == 0x0500) ANDWF(); else if((m_CmdList[pc] & 0x03F80) == 0x0180) CLRF(); else if(ByteCmd == 0x0100) CLRW(); else if(ByteCmd == 0x0900) COMF(); else if(ByteCmd == 0x0300) DECF(); else if(ByteCmd == 0x0B00) DECFSZ(); else if(ByteCmd == 0x0A00) INCF(); else if(ByteCmd == 0x0F00) INCFSZ(); else if(ByteCmd == 0x0400) IORWF(); else if(ByteCmd == 0x0800) MOVF(); else if((m_CmdList[pc] & 0x3F80) == 0x0080) MOVWF(); else if((m_CmdList[pc] & 0x3F9F) == 0x0000) NOP(); else if(ByteCmd == 0x0D00) RLF(); else if(ByteCmd == 0x0C00) RRF(); else if(ByteCmd == 0x0200) SUBWF(); else if(ByteCmd == 0x0E00) SWAPF(); else if(ByteCmd == 0x0600) XORWF(); else if(BitCmd == 0x1000) BCF(); else if(BitCmd == 0x1400) BSF(); else if(BitCmd == 0x1800) BTFSC(); else if(BitCmd == 0x1C00) BTFSS(); //ADDLW kann durch don't care Bit 3E bzw. 3F sein else if((m_CmdList[pc] & 0x3E00 ) == 0x3E00) ADDLW(); else if((m_CmdList[pc] & 0x3F00 ) == 0x3F00) ADDLW(); else if(ByteCmd == 0x3900) ANDLW(); else if(ShrtCmd == 0x2000) CALL(); else if((m_CmdList[pc]& 0XFFFF) == 0x0064) CLRWDT(); else if(ShrtCmd == 0x2800) GOTO(); else if((ByteCmd) == 0x3A00) XORLW(); else if((m_CmdList[pc] & 0x3E00 ) == 0x3C00) SUBLW(); else if((m_CmdList[pc] & 0xFFFF ) == 0x0063) SLEEP(); else if((m_CmdList[pc] & 0xFFFF ) == 0x0008) RETURN(); else if((BitCmd) == 0x3400) RETURNLW(); else if((m_CmdList[pc] & 0xFFFF ) == 0x0009) RETURNFIE(); else if((ByteCmd) == 0x3000) MOVLW(); else if((ByteCmd) == 0x3100) MOVLW(); else if((ByteCmd) == 0x3200) MOVLW(); else if((ByteCmd) == 0x3300) MOVLW(); else if((ShrtCmd) == 0x3800) IORLW(); //zählt nach jeder Befehlsabarbeitung einen Programmzyklus hoch, bizyklische Befehle zählen zusätzlich während des Befehls rauf PIC::ExtClock(); PIC::IncrementCycles(); PIC::setTmr0(); PIC::LaufZeit(); //PreScalerCounter++; PIC::SyncSpecialReg(); PIC::RBPeakAnalyzer(); PIC::InterruptAnalyzer(); //Diagnoseausgaben qDebug() << "---------------------------------"; //qDebug() << regModel->reg[bank][PORTB] << "PortB"; qDebug() << regModel->reg[bank][INDIRECT] << "INDIRECT"; qDebug() << regModel->reg[bank][FSR] << "FSR"; //qDebug() << regModel->reg[bank][0x15] << "15h"; qDebug() << cycles << "Programmzyklen"; qDebug() << "---------------------------------"; }