Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » How to link assembler compiled file
How to link assembler compiled file [message #61685] Sun, 18 May 2025 11:51 Go to previous message
frederik.dumarey is currently offline  frederik.dumarey
Messages: 30
Registered: December 2021
Location: Belgium
Member
Hello,

I added a assembler file named my_strlen.S to my package, the contents of this file are below:

	.global _my_strlen			# Export the symbol _my_strlen
	.text						# code section

_my_strlen:
	
	#function prologue
	pushq %rbp
	movq %rsp, %rbp
	movq %rdi, %rsi 			# copy the string pointer to %rsi
	xorq %rax, %rax				# zero %rax to use as a counter

strlen_loop:
	cmpb $0, (%rsi)				# compare byte at %rsi with 0 (null terminator)
	je strlen_end				# if zero, end of string reached
	incq %rax					# increment counter
	incq %rsi					# move to next character
	jmp strlen_loop				# repeat loop

strlen_end:
	
	#function epilogue
	popq %rbp
	ret


Since this is AT&T assembler code, it compiled without any problem to a object file using right_click, build and compile option in TheIDE GUI. So far so good.

I then added a C++ file, which has the following content:
#include <iostream>

//declare the assembler function
extern "C" size_t my_strlen(const char* str);

int main(int argc, const char *argv[])
{
	const char* message = "Hello from Assembler";
	size_t length = my_strlen(message);
	std::cout << "Message: " << message << std::endl;
	std::cout << "Length: " << length << std::endl;
	return 0;
}


which can also be compiled using the same method as stated before.

Now my question: how do I link those two object files in the GUI? I suppose I have to go to Project menu item, then Custom build steps, but what do I enter in all these fields?

Thanks.


Regards,

Frederik Dumarey
Belgium
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Using COM object
Goto Forum:
  


Current Time: Tue Jun 10 17:43:38 CEST 2025

Total time taken to generate the page: 0.05461 seconds