@@ -619,6 +619,7 @@ void MainWindow::close_source() {
619
619
if (idx >= 0 )
620
620
central_window->removeTab (idx);
621
621
delete editor;
622
+ update_open_file_list ();
622
623
}
623
624
624
625
class SymbolTableDb : public fixmatheval ::FmeSymbolDb {
@@ -701,8 +702,22 @@ void MainWindow::compile_source() {
701
702
}
702
703
if (line.isEmpty ())
703
704
continue ;
704
- QString op = line.split (" " ).at (0 ).toUpper ();
705
- if ((op == " .DATA" ) || (op == " .CODE" )) {
705
+ int k = 0 , l;
706
+ while (k < line.count ()) {
707
+ if (!line.at (k).isSpace ())
708
+ break ;
709
+ k++;
710
+ }
711
+ l = k;
712
+ while (l < line.count ()) {
713
+ if (!line.at (l).isLetterOrNumber () && !(line.at (l) == ' .' ))
714
+ break ;
715
+ l++;
716
+ }
717
+ QString op = line.mid (k, l - k).toUpper ();
718
+ if ((op == " .DATA" ) || (op == " .TEXT" ) ||
719
+ (op == " .GLOBL" ) || (op == " .END" ) ||
720
+ (op == " .ENT" )) {
706
721
continue ;
707
722
}
708
723
if (op == " .ORG" ) {
@@ -723,6 +738,38 @@ void MainWindow::compile_source() {
723
738
address = value;
724
739
continue ;
725
740
}
741
+ if ((op == " .EQU" ) || (op == " .SET" )) {
742
+ QStringList operands = line.mid (op.size ()).split (" ," );
743
+ if ((operands.count () > 2 ) || (operands.count () < 1 )) {
744
+ error_line = ln;
745
+ editor->setCursorToLine (error_line);
746
+ QMessageBox::critical (this , " QtMips Error" ,
747
+ tr (" line %1 .set or .equ incorrect arguments number." )
748
+ .arg (QString::number (ln)));
749
+ break ;
750
+ }
751
+ QString name = operands.at (0 ).trimmed ();
752
+ if ((name == " noat" ) || (name == " noreored" ))
753
+ continue ;
754
+ bool ok;
755
+ fixmatheval::FmeValue value = 1 ;
756
+ if (operands.count () > 1 ) {
757
+ fixmatheval::FmeExpression expression;
758
+ ok = expression.parse (operands.at (1 ), error);
759
+ if (ok)
760
+ ok = expression.eval (value, &symtab, error);
761
+ if (!ok) {
762
+ error_line = ln;
763
+ editor->setCursorToLine (error_line);
764
+ QMessageBox::critical (this , " QtMips Error" ,
765
+ tr (" line %1 .set or .equ %2 parse error." )
766
+ .arg (QString::number (ln), operands.at (1 )));
767
+ break ;
768
+ }
769
+ }
770
+ machine->set_symbol (name, value, 0 );
771
+ continue ;
772
+ }
726
773
if (op == " .WORD" ) {
727
774
foreach (QString s, line.mid (op.size ()).split (" ," )) {
728
775
s = s.simplified ();
@@ -788,8 +835,8 @@ void MainWindow::compile_source() {
788
835
error_line = r->line ;
789
836
editor->setCursorToLine (error_line);
790
837
QMessageBox::critical (this , " QtMips Error" ,
791
- tr (" instruction update error %1 at line %2, expression %3." )
792
- .arg (error, QString::number (r->line ), expression.dump ()));
838
+ tr (" instruction update error %1 at line %2, expression %3 -> value %4 ." )
839
+ .arg (error, QString::number (r->line ), expression.dump (), QString::number (value) ));
793
840
}
794
841
}
795
842
mem->write_word (r->location , inst.data ());
0 commit comments