PDA

View Full Version : How do I set up my project to call assembly functions



lynxx
5th July 2017, 05:26
Hello,
I've been studying a lot C++ and 64-bit Assembly during my apprenticeship and would like to get into GUI programming with Qt.
Sadly I can't figure out how to get my project properly set up to call an extern assembly function from my .s or .asm file.

This is what I have tried:
.pro


QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = test---
TEMPLATE = app

DEFINES += QT_DEPRECATED_WARNINGS


QMAKE_EXTRA_COMPILERS += nasm
# or should I use QMAKE += nasm

SOURCES += main.cpp\
mainwindow.cpp\
asm.s

HEADERS += mainwindow.h

FORMS += mainwindow.ui

LIBS += asm.s


mainwindow.cpp


//code

extern "C" __int64 assembly();

//code

void MainWindow::on_pushButton_clicked()
{
int zahl = assembly(); // for testing purposes I just want the value of rax to be returned and put into the variable zahl
}

asm.s

.code
.global
assembly proc

mov rax, 1
ret

xor rax, rax

assembly endp
end


Whenever I attempt to compile the program I get an error message stating that the symbol assembly cannot be found.
I'm really desperate and need someone help me with this problem :(
I've been browsing the internet for hours but couldn't get a decent solution