CTAsm icon indicating copy to clipboard operation
CTAsm copied to clipboard

Will it continue to be updated to C++20?

Open w4454962 opened this issue 5 months ago • 17 comments

C++20 supports using string literals in templates and offers more compile-time processing, which can further optimize these codes and processes

Also, I have a question - how to allocate placeholders so memory addresses can be input during runtime?

w4454962 avatar Jul 31 '25 14:07 w4454962

After reviewing your code implementation, I really like this project and hope it continues to be updated. Regarding placeholders, I was thinking we could use {} for placeholders like std::format does, then input address parameters at runtime, and have the template calculate and write based on the generated offsets - that should work, right?

w4454962 avatar Jul 31 '25 15:07 w4454962

With C++20 this project will be meaningless, c++20 implement mechanisms for passing string literals in a template, I'm not even talking about compile time functions. It will better to be updated to C++20 because compilers such as clang and msvc have a template layout limit of 1024 or smth You can delete this part with string literals, i added that because of debugging things. About calculating offsets - that what i was thinking about when i wrote this =) Of course i want to implement this feature and this should works, but you need first implement function to access assembled array with your offset I've given up on this project because have a problem with health and radiation, as I get better, I'm increasingly inspired to take on this project

garc0 avatar Aug 01 '25 10:08 garc0

Thank you for your reply, I hope you get better soon.

If possible, could you share the generation tool for the "ctasm_emit.hpp" file?

w4454962 avatar Aug 01 '25 11:08 w4454962

sure if I can find it, but it was a very ugly nodejs script based on asmjit db

garc0 avatar Aug 01 '25 11:08 garc0

i wrote everything 4 years ago, i changed ssd, notebook eheheh

garc0 avatar Aug 01 '25 11:08 garc0

Alright :) While testing short jump instructions, I found the generated offset was wrong. It's a bit hard to read in the template metaprogramming code. No worries, I'm currently slowly breaking down and reading your nested code - it'll take some time.

w4454962 avatar Aug 01 '25 11:08 w4454962

there a lot of wrong things i wrote, everything was on my mind and nasm 2.14 documentation. Ofc it's hard to read)) But it's a simple project because there a lot of small functions that you can test without debugging, there a simple logic Dunno maybe i'll create a new repo for a new project with C++2b meta To be honest you're the first person that got interested in this)

garc0 avatar Aug 01 '25 20:08 garc0

When we discovered your project, my friend and I were genuinely amazed. If it works as intended, many "external preprocessor assemblers" and "runtime assemblers" could potentially be replaced with native compile-time alternatives, which got us really excited.

Regarding this project, I feel that since C++20, the capabilities of constexpr have improved significantly. Many computations can now be handled by constexpr functions. While they might not be as versatile as template metaprogramming, they allow for more straightforward and readable code, making context handling for labels much more convenient.

While studying your code, I've also attempted to recreate it. After two days, I managed to implement a compile-time lexical parser function. The syntax parsing part is quite complex, and I haven't fully grasped it yet. If you're interested in refactoring, I'd suggest exploring this direction further.

lexer.zip

w4454962 avatar Aug 02 '25 01:08 w4454962

thanks, i love your code, its cool but are you sure you need to use std::variant std::pair and std::string_view here? Is it compile time? Do you use MSVC? I think FixedString will not work there, i heard that is GNU feature

garc0 avatar Aug 02 '25 11:08 garc0

Yes, they are all compile-time features, written and run in MSVC. Some constexpr capabilities may come from C++23 enhancements. In the future, C++ should see more improvements in compile-time function capabilities.

Image

w4454962 avatar Aug 02 '25 15:08 w4454962

ah it's all about c++23 well ok. If you want to use c++23 you should avoid using templates, compiler lets you do all magic in constexpr function. Ahaha i saw what compiler do with one byte copy. I made an ugly solve to manipulate size of mov that compiler will paste, it was about casting

garc0 avatar Aug 02 '25 16:08 garc0

I tested it and found that changing the compiler standard to C++20 still compiles correctly. C++20 is more powerful than we imagined.

w4454962 avatar Aug 02 '25 16:08 w4454962

So, would you be interested in collaborating to refactor this project in this direction? Template metaprogramming is quite hard to read, and I'm finding it a bit challenging to recreate it alone...

w4454962 avatar Aug 02 '25 16:08 w4454962

Sure i want. You want start a new project or just commit to this one?(This project should be c++11-14 supported so std:: libs will not work) Share me your contacts so we can massage more conveniently. Or you can write to me. Which messenger is more convenient? you have telegram?

garc0 avatar Aug 02 '25 16:08 garc0

Let's start a new project. Based on constexpr, reducing the use of template metaprogramming (though it might still be needed in some cases).

Our local laws don't permit using Telegram - could you switch to Discord instead?

Or alternatively, an email address would also work

w4454962 avatar Aug 02 '25 17:08 w4454962

wait you have no access to telegram with shadowsocks(did you tried - its free like Tor project) but you can login to discord??? In russia opposite anyway discord garco4002

garc0 avatar Aug 02 '25 17:08 garc0

It's not that it won't open—it's that I can't register. I've added you on Discord, please accept. My username is still this one: w4454962.

w4454962 avatar Aug 02 '25 17:08 w4454962