NO

Recent Posts

Pages: 1 ... 5 6 [7] 8 9 10
62
Beginner questions / Re: Declared variables ordering
« Last post by HellOfMice on October 28, 2024, 10:07:38 AM »
John, you can use "alignas" too, like this


#include <stdalign.h>

   alignas(HANDLE)   HANDLE    _hThread ;
   alignas(int)           int            _iIndex ;
   alignas(DWORD)   DWORD    _dwThreadId ;
63
Beginner questions / Re: sizeof operator
« Last post by HellOfMice on October 28, 2024, 10:01:24 AM »
Vortex you are an expert, not me


What we said can be applied to memset, memcpy...
64
Beginner questions / Re: sizeof operator
« Last post by Vortex on October 28, 2024, 09:56:53 AM »
Hi HellOfMice,

It works as you described, here is a quick example :

Code: [Select]
#include <stdio.h>
#include <intrin.h>

int main(void)
{
char p[]={0,1,2,3,4,5,6,7,0,8,9};
__stosq((unsigned long long *)p, 0x4141414141414141,1);
printf("%s\n",p);
return 0;

}

Examining the assembly code :

Code: [Select]
    lea     rdi,[rsp+25H]
    mov     rax,4141414141414141H
    mov     ecx,1               
    rep     stosq
65
Beginner questions / Re: sizeof operator
« Last post by HellOfMice on October 28, 2024, 07:30:23 AM »
Vortex, I know that but what I read was that in the form the macro RtlZeroMemory is created the compiler cannot remove or replace it as it can do with memset. If I find the link I post it. memset with its stosb is not very efficient and could be easily replaced with __stosXX macro family


memset(b,63,80) can be replace __stosq((unsigned long long *) b, (unsigned long long) 0x3f3f3f3f, sizeof(b) / sizeof(__int64)) ; just 10 loops rather than 80the compiler sets rcx to 80 / 8, sets 0x3f3f3f3f to rax and creates rep stosq instruction


[0000000140001CDB] 31C0                         xor               eax,eax
[0000000140001CDD] B907000000              mov               ecx,7
[0000000140001CE2] F348AB                      rep stosq         


__stosq((unsigned long long *) &_Lvc,0,sizeof(LVCOLUMN) / 8


66
Beginner questions / Re: sizeof operator
« Last post by TimoVJL on October 28, 2024, 07:08:55 AM »
optimizer can also replace memset to rep stosb
Code: [Select]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int __cdecl main(void)
{
//char b[80] = {0};
char b[80];
memset(b, 63, 80);
b[5] = 0;
printf("size: %d %s\n", sizeof(b), b);
return 0;
}
67
Beginner questions / Re: sizeof operator
« Last post by Vortex on October 27, 2024, 09:44:26 PM »
Reading \PellesC\Include\win\winnt.h :

Code: [Select]
#define RtlZeroMemory(Destination,Length) (void)memset((Destination),0,(Length))
68
Beginner questions / Re: sizeof operator
« Last post by HellOfMice on October 27, 2024, 08:40:15 PM »
I have read that using memset is not always generated by the compiler prefer to use RtlZeroMemory


From Pelle's
Code: [Select]
Fills an object with a value. 
 Syntax: void __stosb(unsigned char *dst, unsigned char val, size_t num);
void __stosw(unsigned short *dst, unsigned short val, size_t num);
void __stosd(unsigned long *dst, unsigned long val, size_t num);
void __stosq(unsigned long long *dst, unsigned long long val, size_t num);  (X64 only)
 
 Declared in: <intrin.h>
 
The __stosb, __stosw, __stosd and __stosq function fills the object at dst with num byte, word, double-word, or quad-word values from val using the X86/X64 instruction REP STOSB, REP STOSW, REP STOSD, or REP STOSQ, respectively.
 
The __stosb, __stosw, __stosd and __stosq functions are only available as intrinsics.
 
 Returns: Nothing
 #code
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlzeromemory
https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlfillmemory

69
Beginner questions / Re: Free Image library
« Last post by HellOfMice on October 27, 2024, 07:39:53 PM »
Thanks Vortex I already add it, but it is not complete: Resize...
You made de 64bits version for me a long time ago
I had many pseudo Jokaste, Grincheux, Grumpy...
70
Beginner questions / Re: Free Image library
« Last post by Vortex on October 27, 2024, 07:11:41 PM »
Hello,

Library based on OLE image functions :

https://forum.pellesc.de/index.php?topic=7237.0
Pages: 1 ... 5 6 [7] 8 9 10