| x64asm by Dadatel | ||||||||
|---|---|---|---|---|---|---|---|---|
|
|
|||||||
|
popularity : 48% |
|||||||
alltime top: #87943 |
|
|||||||
| added on the 2026-05-30 03:46:05 by dadatel |
||||||||
popularity helper
comments
Putting this right there: what makes it differentiate between Xbyak and its ARM equivalent Fujitsu commissioned?
didn't really understanded you correctly i think, so uhh if you're saying why doing this when Xbyak and it's other analogs exists im gonna say, this solution is more optimized and X64 MSVC only and you don't need to do a lot of manipulations with IDE or any other stuff, just include x64_asm.h and done
if shortly this solution with less abstractions than any other(well or that i know) other solutions
if shortly this solution with less abstractions than any other(well or that i know) other solutions
update is soon(and it will support C and CPP)
here's a little example of some code
this code will changed anyways
x64asm still stays as Header only library without CRT
full documentation will release after the main release(bcuz im lazy and i didn't documented everything along the way, but still comments are good for understanding what's and why is happening)
here's a little example of some code
Code:
static inline void NoCRT_memset_nt(void* ptr, int value, size_t num) {
// for lil buffers NT instructions are bad( (bcuz of cache sheesh)
// REP STOSB (ERMS) on lil and medium blocks will work fine
if (num < 4096) {
__stosb((unsigned char*)ptr, (unsigned char)value, num);
return;
}
NoCRT_init_cpu_features();
unsigned char* p = (unsigned char*)ptr;
unsigned char val8 = (unsigned char)value;
// AVX-512
if (NoCRT_cpu_avx512) {
// align to 64 bytes to prevent hardware errors and #GP
while (((uintptr_t)p & 63) != 0 && num > 0) {
*p++ = val8;
num--;
}
// do shit after aligning, i am a dumbass
size_t n512 = num >> 9; // how many blocks with 512 byte(8amount*64byte)
size_t rem = num & 511; //what remains after da big blocks
if (n512) {
__m512i v = _mm512_set1_epi8((char)value);
for (size_t i = 0; i < n512; i++) {
_mm512_stream_si512((__m512i*)(p + 0), v);
_mm512_stream_si512((__m512i*)(p + 64), v);
_mm512_stream_si512((__m512i*)(p + 128), v);
_mm512_stream_si512((__m512i*)(p + 192), v);
_mm512_stream_si512((__m512i*)(p + 256), v);
_mm512_stream_si512((__m512i*)(p + 320), v);
_mm512_stream_si512((__m512i*)(p + 384), v);
_mm512_stream_si512((__m512i*)(p + 448), v);
p += 512;
}
}
//fill what remains with blocks to 64bytes
size_t n64 = rem >> 6;
if (n64) {
__m512i v = _mm512_set1_epi8((char)value);
for (size_t i = 0; i < n64; i++) {
_mm512_stream_si512((__m512i*)p, v);
p += 64;
}
}
// give tail to stosb
size_t tail = rem & 63;
if (tail) {
__stosb(p, val8, tail);
}
}
//AVX2
else if (NoCRT_cpu_avx2) {
//aling to 32bytes
while (((uintptr_t)p & 31) != 0 && num > 0) {
*p++ = val8;
num--;
}
// count after align fuck
size_t n256 = num >> 8; //blocks to 256 bytes(8amount * 32bytes)
size_t rem = num & 255;
if (n256) {
__m256i v = _mm256_set1_epi8((char)value);
for (size_t i = 0; i < n256; i++) {
_mm256_stream_si256((__m256i*)(p + 0), v);
_mm256_stream_si256((__m256i*)(p + 32), v);
_mm256_stream_si256((__m256i*)(p + 64), v);
_mm256_stream_si256((__m256i*)(p + 96), v);
_mm256_stream_si256((__m256i*)(p + 128), v);
_mm256_stream_si256((__m256i*)(p + 160), v);
_mm256_stream_si256((__m256i*)(p + 192), v);
_mm256_stream_si256((__m256i*)(p + 224), v);
p += 256;
}
}
// blocks to 32bytes
size_t n32 = rem >> 5;
if (n32) {
__m256i v = _mm256_set1_epi8((char)value);
for (size_t i = 0; i < n32; i++) {
_mm256_stream_si256((__m256i*)p, v);
p += 32;
}
}
// well tail duh
size_t tail = rem & 31;
if (tail) {
__stosb(p, val8, tail);
}
}
// SSE2
else if (NoCRT_cpu_sse2) {
// align to 16bytes
while (((uintptr_t)p & 15) != 0 && num > 0) {
*p++ = val8;
num--;
}
// do this after aligning damn it
size_t n256 = num >> 8; // blocks to 256bytes(16amount * 16byte)
size_t rem = num & 255;
if (n256) {
__m128i v = _mm_set1_epi8((char)value);
for (size_t i = 0; i < n256; i++) {
_mm_stream_si128((__m128i*)(p + 0), v); _mm_stream_si128((__m128i*)(p + 16), v);
_mm_stream_si128((__m128i*)(p + 32), v); _mm_stream_si128((__m128i*)(p + 48), v);
_mm_stream_si128((__m128i*)(p + 64), v); _mm_stream_si128((__m128i*)(p + 80), v);
_mm_stream_si128((__m128i*)(p + 96), v); _mm_stream_si128((__m128i*)(p + 112), v);
_mm_stream_si128((__m128i*)(p + 128), v); _mm_stream_si128((__m128i*)(p + 144), v);
_mm_stream_si128((__m128i*)(p + 160), v); _mm_stream_si128((__m128i*)(p + 176), v);
_mm_stream_si128((__m128i*)(p + 192), v); _mm_stream_si128((__m128i*)(p + 208), v);
_mm_stream_si128((__m128i*)(p + 224), v); _mm_stream_si128((__m128i*)(p + 240), v);
p += 256;
}
}
//blocks to 16byte
size_t n16 = rem >> 4;
if (n16) {
__m128i v = _mm_set1_epi8((char)value);
for (size_t i = 0; i < n16; i++) {
_mm_stream_si128((__m128i*)p, v);
p += 16;
}
}
//well ye tail
size_t tail = rem & 15;
if (tail) {
__stosb(p, val8, tail);
}
}
// old CPU fallback
else {
__stosb(p, val8, num);
}
// finalize well make sure that shit goes to RAM
_mm_sfence();
}this code will changed anyways
x64asm still stays as Header only library without CRT
full documentation will release after the main release(bcuz im lazy and i didn't documented everything along the way, but still comments are good for understanding what's and why is happening)
submit changes
if this prod is a fake, some info is false or the download link is broken,
do not post about it in the comments, it will get lost.
instead, click here !

so, this is a highly optimized x64 assembler library featuring an ultra-fast JIT compiler engine tailored for MSVC.
the project is currently a Work In Progress (WIP), so the library is not 100% finished yet, but the core engine is fully working. released it early to get some initial feedback from low-level optimization geeks and intro coders(and other dudes).
check out the repository and feel free to test or benchmark it
feedback and bug reports are highly appreciated.