Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ Makefile
ehthumbs.db
Thumbs.db

# clangd
.cache/

doc/*
.qmake.stash
sasm.app

*.o
sasm
ui_settings.h
moc_predefs.h
moc_predefs.h
9 changes: 4 additions & 5 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ On Windows:
For building:
C++ compiler (e.g. gcc from MinGW)
make (e.g. mingw32-make from MinGW)
Qt 5 (>= 5.11)
Qt6
For running:
Everything needed is included.

On Linux:
For building:
build-essential
qtbase5-dev
qtbase5-dev-tools
qt5-qmake
qtchooser
qt6-base-dev
qt6-base-dev-tools
qt6-5compat-dev
For running:
gcc-multilib (x64 OS) or gcc (x86 OS)
gdb
Expand Down
4 changes: 1 addition & 3 deletions SASM.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += core gui core5compat widgets

TARGET = sasm
TEMPLATE = app
Expand Down
2 changes: 1 addition & 1 deletion assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Assembler : public QObject
quint64 numInCode;
//! Address of instruction on this line in memory
quint64 numInMem;
bool operator ==(const LineNum& ln)
bool operator ==(const LineNum& ln) const
{
return ln.numInCode == numInCode;
}
Expand Down
3 changes: 2 additions & 1 deletion codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
**
****************************************************************************/

#include <QRegExp>
#include "codeeditor.h"

/**
Expand Down Expand Up @@ -455,7 +456,7 @@ bool CodeEditor::isMacroOnCurrentDebugLine()
"\\bGET_STRING\\b" << "\\bCMAIN\\b" << "\\bCEXTERN\\b";
foreach (const QString &pattern, macrosPatterns) {
QRegExp regExp(pattern, Qt::CaseSensitive);
if (text.indexOf(regExp) != -1)
if (regExp.indexIn(text) != -1)
return true;
}
}
Expand Down
20 changes: 10 additions & 10 deletions debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ void Debugger::processMessage(QString output, QString error)

if (!pid) {
QRegExp r("Num +Description +(Connection +)?Executable");
int index = output.indexOf(r);
int index = r.indexIn(output);
if (index != -1) {
QString processString("process ");
r = QRegExp(processString + "[0-9]+");
index = output.indexOf(r);
index = r.indexIn(output);
output = output.mid(index + processString.length());
output = output.split(QChar(' ')).at(0);
pid = output.toULongLong(0, 10);
Expand All @@ -314,12 +314,12 @@ void Debugger::processMessage(QString output, QString error)

void Debugger::processAction(QString output, QString error)
{
bool backtrace = (output.indexOf(QRegExp("#\\d+ 0x[0-9a-fA-F]{8,16} in .* ()")) != -1);
bool backtrace = (QRegExp("#\\d+ 0x[0-9a-fA-F]{8,16} in .* ()").indexIn(output) != -1);
if (output.indexOf(exitMessage) != -1 && !backtrace) {
doInput("c\n", none);
return;
}
if (output.indexOf(QRegExp(cExitMessage)) != -1) { //if debug finished
if (QRegExp(cExitMessage).indexIn(output) != -1) { //if debug finished
//print output - message like bottom
/*Breakpoint 1, 0x08048510 in sasmStartL ()
"
Expand Down Expand Up @@ -385,15 +385,15 @@ void Debugger::processAction(QString output, QString error)
QRegExp breakpointMsg("\r?\nBreakpoint \\d+, ");
QRegExp threadMsg("\\[Switching to Thread [^\\]]*\\]\r?\n");
QRegExp signalMsg("\r?\n(Program received signal.*)");
msg.remove(continuingMsg);
msg.remove(breakpointMsg);
msg.remove(threadMsg);
msg = continuingMsg.removeIn(msg);
msg = breakpointMsg.removeIn(msg);
msg = threadMsg.removeIn(msg);
if (signalMsg.indexIn(msg) != -1) {
QString recievedSignal = signalMsg.cap(1);
if (QRegExp("SIG(TRAP|INT)").indexIn(recievedSignal) == -1) {
emit printLog(recievedSignal, Qt::red);
}
msg.remove(signalMsg);
msg = signalMsg.removeIn(msg);
}
emit printOutput(msg);
}
Expand Down Expand Up @@ -436,7 +436,7 @@ void Debugger::processAction(QString output, QString error)
if (output[output.length() - 1] != '\n')
output += QChar('\n');
//process as ni or si
if (output.indexOf(QRegExp("0x[0-9a-fA-F]{8,16} in ")) != -1
if (QRegExp("0x[0-9a-fA-F]{8,16} in ").indexIn(output) != -1
&& !backtrace) {
actionTypeQueue.enqueue(showLine);
processAction(output);
Expand All @@ -455,7 +455,7 @@ void Debugger::processAction(QString output, QString error)
output.indexOf(QString("no debug info")) == -1 && output != QString(" ")) {
//if variable exists (isValid = true)
isValid = true;
int index = output.indexOf(QRegExp("\\$\\d+ = .*"));
int index = QRegExp("\\$\\d+ = .*").indexIn(output);
if (index == -1)
isValid = false;
else {
Expand Down
1 change: 0 additions & 1 deletion debugtablewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define DEBUGTABLEWIDGET_H

#include <QTableWidget>
#include <QDesktopWidget>
#include <QHeaderView>
#include <QMouseEvent>
#include <QAction>
Expand Down
10 changes: 4 additions & 6 deletions fasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ quint64 FASM::getMainOffset(QFile &lstOut, QString entryLabel)
lst.close();
return line.toULongLong(0, 16);
} else {
if (line.indexOf(mainLabel) != -1)
if (mainLabel.indexIn(line) != -1)
flag = true;
}
}
Expand Down Expand Up @@ -171,20 +171,18 @@ QString FASM::getStartText()
void FASM::putDebugString(CodeEditor *code)
{
//add : mov ebp, esp for making frame for correct debugging if this code has not been added yet
int index = code->toPlainText().indexOf(QRegExp("main:"));
int index = QRegExp("main:").indexIn(code->toPlainText());
if (index != -1) {
index = code->toPlainText().indexOf(QChar(':'), index);
if (isx86()) {
if (code->toPlainText().indexOf(
QRegExp("\\s+([Pp][Uu][Ss][Hh] +[Ee][Bb][Pp]\\s+)?[Mm][Oo][Vv] +[Ee][Bb][Pp] *, *[Ee][Ss][Pp]"), index + 1) != index + 1) {
if (QRegExp("\\s+([Pp][Uu][Ss][Hh] +[Ee][Bb][Pp]\\s+)?[Mm][Oo][Vv] +[Ee][Bb][Pp] *, *[Ee][Ss][Pp]").indexIn(code->toPlainText(), index + 1) != index + 1) {
QTextCursor cursor = code->textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, index + 1);
cursor.insertText(QString("\n mov ebp, esp; for correct debugging"));
}
} else {
if (code->toPlainText().indexOf(
QRegExp("\\s+([Pp][Uu][Ss][Hh] +[Rr][Bb][Pp]\\s+)?[Mm][Oo][Vv] +[Rr][Bb][Pp] *, *[Rr][Ss][Pp]"), index + 1) != index + 1) {
if (QRegExp("\\s+([Pp][Uu][Ss][Hh] +[Rr][Bb][Pp]\\s+)?[Mm][Oo][Vv] +[Rr][Bb][Pp] *, *[Rr][Ss][Pp]").indexIn(code->toPlainText(), index + 1) != index + 1) {
QTextCursor cursor = code->textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, index + 1);
Expand Down
20 changes: 8 additions & 12 deletions gas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ quint64 GAS::getMainOffset(QFile &lst, QString entryLabel)
}
}
} else {
if (line.indexOf(mainLabel) != -1)
if (mainLabel.indexIn(line) != -1)
flag = true;
}
}
Expand All @@ -103,9 +103,9 @@ void GAS::parseLstFile(QFile &lst, QVector<Assembler::LineNum> &lines, quint64 o
QTextStream lstStream(&lst);
while (!lstStream.atEnd()) {
QString line = lstStream.readLine();
if (line.indexOf(sectionTextRegExp) != -1) {
if (sectionTextRegExp.indexIn(line) != -1) {
inTextSection = true;
} else if (line.indexOf(sectionDataRegExp) != -1 || line.indexOf(sectionBssRegExp) != -1) {
} else if (sectionDataRegExp.indexIn(line) != -1 || sectionBssRegExp.indexIn(line) != -1) {
inTextSection = false;
}
if (line.length() <= 19) { //omit strings with data only
Expand Down Expand Up @@ -145,23 +145,21 @@ QString GAS::getStartText()
void GAS::putDebugString(CodeEditor *code)
{
//add : mov ebp, esp for making frame for correct debugging if this code has not been added yet
int index = code->toPlainText().indexOf(QRegExp("CMAIN:|main:"));
int index = QRegExp("CMAIN:|main:").indexIn(code->toPlainText());
if (index != -1) {
index = code->toPlainText().indexOf(QChar(':'), index);
int intelIndex = code->toPlainText().lastIndexOf("intel_syntax", index + 1);
int attIndex = code->toPlainText().lastIndexOf("att_syntax", index + 1);
if (intelIndex == -1 || attIndex > intelIndex) { //AT&T syntax
if (isx86()) {
if (code->toPlainText().indexOf(
QRegExp("\\s+([Pp][Uu][Ss][Hh][Ll]? +%?[Ee][Bb][Pp]\\s+)?[Mm][Oo][Vv][Ll] +%?[Ee][Ss][Pp] *, *%?[Ee][Bb][Pp]"), index + 1) != index + 1) {
if (QRegExp("\\s+([Pp][Uu][Ss][Hh][Ll]? +%?[Ee][Bb][Pp]\\s+)?[Mm][Oo][Vv][Ll] +%?[Ee][Ss][Pp] *, *%?[Ee][Bb][Pp]").indexIn(code->toPlainText() , index + 1) != index + 1) {
QTextCursor cursor = code->textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, index + 1);
cursor.insertText(QString("\n movl %esp, %ebp #for correct debugging"));
}
} else {
if (code->toPlainText().indexOf(
QRegExp("\\s+([Pp][Uu][Ss][Hh][Qq]? +%?[Rr][Bb][Pp]\\s+)?[Mm][Oo][Vv][Qq] +%?[Rr][Ss][Pp] *, *%?[Rr][Bb][Pp]"), index + 1) != index + 1) {
if (QRegExp("\\s+([Pp][Uu][Ss][Hh][Qq]? +%?[Rr][Bb][Pp]\\s+)?[Mm][Oo][Vv][Qq] +%?[Rr][Ss][Pp] *, *%?[Rr][Bb][Pp]").indexIn(code->toPlainText(), index + 1) != index + 1) {
QTextCursor cursor = code->textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, index + 1);
Expand All @@ -170,16 +168,14 @@ void GAS::putDebugString(CodeEditor *code)
}
} else { //Intel syntax
if (isx86()) {
if (code->toPlainText().indexOf(
QRegExp("\\s+([Pp][Uu][Ss][Hh][Ll]? +%?[Ee][Bb][Pp]\\s+)?[Mm][Oo][Vv] +%?[Ee][Bb][Pp] *, *%?[Ee][Ss][Pp]"), index + 1) != index + 1) {
if (QRegExp("\\s+([Pp][Uu][Ss][Hh][Ll]? +%?[Ee][Bb][Pp]\\s+)?[Mm][Oo][Vv] +%?[Ee][Bb][Pp] *, *%?[Ee][Ss][Pp]").indexIn(code->toPlainText(), index + 1) != index + 1) {
QTextCursor cursor = code->textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, index + 1);
cursor.insertText(QString("\n mov %ebp, %esp #for correct debugging"));
}
} else {
if (code->toPlainText().indexOf(
QRegExp("\\s+([Pp][Uu][Ss][Hh][Qq]? +%?[Rr][Bb][Pp]\\s+)?[Mm][Oo][Vv] +%?[Rr][Bb][Pp] *, *%?[Rr][Ss][Pp]"), index + 1) != index + 1) {
if (QRegExp("\\s+([Pp][Uu][Ss][Hh][Qq]? +%?[Rr][Bb][Pp]\\s+)?[Mm][Oo][Vv] +%?[Rr][Bb][Pp] *, *%?[Rr][Ss][Pp]").indexIn(code->toPlainText(), index + 1) != index + 1) {
QTextCursor cursor = code->textCursor();
cursor.movePosition(QTextCursor::Start);
cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, index + 1);
Expand Down
8 changes: 0 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@

int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
QtSingleApplication a(argc, argv);
QSettings settings("SASM Project", "SASM");
QPalette palette;
Expand Down Expand Up @@ -89,10 +85,6 @@ int main(int argc, char *argv[])
return 0;
}
QTranslator translator, qtTranslator, addTranslator;
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForCStrings(codec);
#endif
if (!settings.contains("language")) { //language choosing
QStringList items;
items << QString("Русский") << QString("English") << QString("Türk") <<
Expand Down
11 changes: 5 additions & 6 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void MainWindow::initUi()
splitter->setOrientation(Qt::Vertical);
workLayout = new QVBoxLayout;
workLayout->addWidget(splitter);
workLayout->setMargin(0);
workLayout->setContentsMargins(QMargins());
workLayout->setSpacing(0);
workWidget = new QWidget;
workWidget->setLayout(workLayout);
Expand Down Expand Up @@ -947,7 +947,7 @@ void MainWindow::buildProgram(bool debugMode)
QTextStream log(&logFile);
QString logText = log.readAll();
if (settings.value("assembler", QString("NASM")).toString() == "FASM" && logText.count(QChar('\n')) == 2
&& logText.contains(QRegExp(" bytes\\.")))
&& QRegExp(" bytes\\.").indexIn(logText) != -1)
logText.clear();
if (settings.value("assembler", QString("NASM")).toString() == "MASM") {
if (logText.count(QChar('\n')) == 1 && logText.startsWith(" Assembling:"))
Expand Down Expand Up @@ -1577,7 +1577,7 @@ void MainWindow::findNext(const QString &pattern, Qt::CaseSensitivity cs, bool a
if (cs == Qt::CaseSensitive)
newCursor = document->find(pattern, newCursor, QTextDocument::FindCaseSensitively);
else
newCursor = document->find(pattern, newCursor, 0);
newCursor = document->find(pattern, newCursor);
//! Replace mode
if (replace && i == tabs->currentIndex()) {
newCursor.removeSelectedText();
Expand Down Expand Up @@ -1609,13 +1609,13 @@ void MainWindow::findNext(const QString &pattern, Qt::CaseSensitivity cs, bool a
if (cs == Qt::CaseSensitive)
newCursor = document->find(pattern, newCursor, QTextDocument::FindCaseSensitively);
else
newCursor = document->find(pattern, newCursor, 0);
newCursor = document->find(pattern, newCursor);
//! Continue from start
if (newCursor.isNull()) {
if (cs == Qt::CaseSensitive)
newCursor = document->find(pattern, newCursor, QTextDocument::FindCaseSensitively);
else
newCursor = document->find(pattern, newCursor, 0);
newCursor = document->find(pattern, newCursor);
}
if (!newCursor.isNull()) {
selection.cursor = newCursor;
Expand Down Expand Up @@ -2291,7 +2291,6 @@ void MainWindow::openHelp()

helpFile.open(QFile::ReadOnly);
QTextStream helpText(&helpFile);
helpText.setCodec("utf-8");
help->setHtml(helpText.readAll());
helpFile.close();
help->setWindowState(Qt::WindowMaximized);
Expand Down
10 changes: 5 additions & 5 deletions masm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ void MASM::parseLstFile(QFile &lst, QVector<Assembler::LineNum> &lines, quint64
continue;
if (empty2.exactMatch(line))
continue;
if (line.indexOf(sectionTextRegExp) != -1) {
if (sectionTextRegExp.indexIn(line)!= -1) {
inTextSection = true;
} else if (line.indexOf(sectionDataRegExp) != -1) {
} else if (sectionDataRegExp.indexIn(line) != -1) {
inTextSection = false;
}
if (inTextSection) {
Expand All @@ -139,7 +139,7 @@ void MASM::parseLstFile(QFile &lst, QVector<Assembler::LineNum> &lines, quint64
macroInstruction.remove(0, k);
if (macroInstruction[0] == '=')
continue;
macroInstruction.remove(QRegExp("^[0-9a-fA-F]{8,16}[ \t]+")); //if label
macroInstruction = QRegExp("^[0-9a-fA-F]{8,16}[ \t]+").removeIn(macroInstruction); //if label
while (!stringWithAddress.exactMatch(line) && !lstStream.atEnd())
line = lstStream.readLine();
lineArr = line.toLocal8Bit();
Expand All @@ -160,7 +160,7 @@ void MASM::parseLstFile(QFile &lst, QVector<Assembler::LineNum> &lines, quint64
while (k < macroInstruction.length() && macroInstruction[k].isSpace())
k++;
macroInstruction.remove(0, k);
macroInstruction.remove(QRegExp("^[0-9a-fA-F]{8,16}[ \t]+")); //if label
macroInstruction = QRegExp("^[0-9a-fA-F]{8,16}[ \t]+").removeIn(macroInstruction); //if label
while (!stringWithAddress.exactMatch(line) && !lstStream.atEnd())
line = lstStream.readLine();
lineArr = line.toLocal8Bit();
Expand Down Expand Up @@ -200,7 +200,7 @@ void MASM::parseLstFile(QFile &lst, QVector<Assembler::LineNum> &lines, quint64
//! Check if instruction
if (!stringWithCode.exactMatch(line) || macro.exactMatch(line) || sscanf(s, "%llx", &a) != 1)
continue;
int index = line.indexOf(QRegExp("[RE\t]\t"));
int index = QRegExp("[RE\t]\t").indexIn(line);
if (index == -1)
continue;
line = line.mid(index + 2);
Expand Down
Loading