News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

AsciiHextoDword (SSE2 version)

Started by guga, March 08, 2025, 11:29:50 AM

Previous topic - Next topic

guga

Quote from: zedd151 on March 11, 2025, 07:40:38 AMfor several instructions such as

"movdqu  xmm0, qword ptr [eax]"
"movdqu  qword ptr [edi+1], xmm0"

guga2.asm(67) : error A2022:instruction operands must be the same size
You might need some additional help here. My knowledge of SSE is very, very limited. Practically zero.  :tongue:


Hi Zedd

Use the version i assembled with JJ´s app. I don´t remember what are the necessary configuration to assemble it in masm. For such routines in SSE i normally use JJ´s Masm basic benchmark routine.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

zedd151

Quote from: guga on March 11, 2025, 08:01:37 AM
Quote from: zedd151 on March 11, 2025, 07:40:38 AMfor several instructions such as

"movdqu  xmm0, qword ptr [eax]"
"movdqu  qword ptr [edi+1], xmm0"

guga2.asm(67) : error A2022:instruction operands must be the same size
You might need some additional help here. My knowledge of SSE is very, very limited. Practically zero.  :tongue:


Hi Zedd

Use the version i assembled with JJ´s app. I don´t remember what are the necessary configuration to assemble it in masm. For such routines in SSE i normally use JJ´s Masm basic benchmark routine.
Okay, if I can untangle that mess.  :tongue:
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

zedd151

Quote from: ognil on March 11, 2025, 07:59:12 AMI want to ask a stupid question to everyone:
1. Which masochist would write such a long string as szTest db "6543210F2A45B7", 0, to get the same result, instead of
Do you mean this?
Quote from: guga on March 10, 2025, 05:55:21 AMFor example, say the input is this string:
[SzInputHex:  B$ "6543210F2A45B7", 0 ]
Play nice, ognil.

He is working on converting ascii hex ---> qword (but as 2 dwords)

¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

guga

Quote from: ognil on March 11, 2025, 07:59:12 AMHi Guga,

Yesterday I saw your last version of algo. Congratulations! :thumbsup:

I want to ask a stupid question to everyone:
1. Which masochist would write such a long string as szTest db "6543210F2A45B7", 0, to get the same result, instead of leaving only the numbers and putting an "h" at the end?
Who, when, where and for what would practically use such a large QWORD number?
Please give an example! :badgrin:

Ognil .... Lingo ? Is that u ?  :biggrin:  :biggrin:  :biggrin:

Tks, lingo.

About your question, well..i can think a few tools, such as apps that uses pattern recognition, for example. Idapro uses a system where such functions can be useful. On Ida, for example, there's a tool called Flirt which is basically a pattern recognition system for files. Some signatures used in ida also comes in the form of text and it may contains hexadecimal strings larger than 50, 100 bytes etc etc
Me and René started a similar system 20 years ago, but never finished those things. Other old tools uses pattern recognition as text files, if i remember Peid used that too. But, such functions can be useful for someone who needs a faster way to convert those text files for their databases or something.

I don´t know if in games it do uses such text files containing hexadecimal values to be converted internally, but it may also exists.

Nobody knows when this could be useful until it is needed, so ...why don't we take the 1st step and write some functions that maybe useful for others and yet be really fast?


Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

ognil

Zedd151,
you didn't answer my question :undecided:


Quote"movdqu  xmm0, qword ptr [eax]"
"movdqu  qword ptr [edi+1], xmm0"

try:
"movdqu  xmm0, oword ptr [RAX]"
"movdqu  oword ptr [RDI+1], xmm0"

"Not keeping emotions under control is another type of mental distortion."

zedd151

Quote from: guga on March 11, 2025, 08:01:37 AMUse the version i assembled with JJ´s app.

attached...
I am not seeing both dwords as result.  :sad:

Check if I missed something copying over the code and data
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

zedd151

Quote from: ognil on March 11, 2025, 08:27:09 AMyou didn't answer my question :undecided:
What question was addressed to me?
If it was concerning such large qwords, I believe guga covered that. This is not MY project, but gugas.

Quote from: ognil on March 11, 2025, 08:27:09 AMtry:
"movdqu  xmm0, oword ptr [RAX]"
"movdqu  oword ptr [RDI+1], xmm0"

In 32 bit???  :eusa_naughty:
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

NoCforMe

Ognil/Lingo, I have to wholeheartedly agree with you here.
I can't really see the utility of this function either. When in real life would someone need such a conversion?
And if needed, who would care how fast it is? Not like anyone's going to be converting millions of such fields from a database, eh?
Interesting mental exercise, but that's about it.
Assembly language programming should be fun. That's why I do it.

guga

Quote from: zedd151 on March 11, 2025, 08:32:15 AM
Quote from: guga on March 11, 2025, 08:01:37 AMUse the version i assembled with JJ´s app.

attached...
I am not seeing both dwords as result.  :sad:

Check if I missed something copying over the code and data

It´s not showing both results, because i dont know exactly how make the output for them in masmbasic. JJ can help, because he knows where and how use his benchmark tool in a way to export (show) the results.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

zedd151

Quote from: guga on March 11, 2025, 08:56:17 AMIt´s not showing both results, because i dont know exactly how make the output for them in masmbasic.
The code I attached in post #65 is pure Masm32.
Just your function and its data, and a Message Box to display the results.

From your comments, I thought Output would be for two dwords, one after the other... ?? unless I am missing some detail.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

ognil

zedd151,

If you are really translating from 32bit to 64bit
you will know that there is no such register in RAX and RDI in MACM32. :sad:
I missed Guga's answer because he mentions the name of IDA without having the source code of IDA or IDA64. :smiley:

NoCforMe,

Thanks for the correct answer. :thumbsup:
Now take a break and go for a walk in nature :badgrin:
"Not keeping emotions under control is another type of mental distortion."

zedd151

Quote from: ognil on March 11, 2025, 09:16:59 AMIf you are really translating from 32bit to 64bit
No! I assembled YOUR 64 bit version  to test the results. I did no such conversions here in this topic. guga had wanted you to port your version to 32 bit so that he can test the results. I did the next best thing, and assembled your 64 bit code (thank you, btw) to test it for guga, to see if the results matched the results from his version.   :badgrin:

And yes I know the difference between 32 bit and 64 bit maximum sized registers.  :rolleyes:
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

guga

Quote from: ognil on March 11, 2025, 09:16:59 AMzedd151,

If you are really translating from 32bit to 64bit
you will know that there is no such register in RAX and RDI in MACM32. :sad:
I missed Guga's answer because he mentions the name of IDA without having the source code of IDA or IDA64. :smiley:

NoCforMe,

Thanks for the correct answer. :thumbsup:
Now take a break and go for a walk in nature :badgrin:

IdaPro is not OpenSource. The flirt system is well known since they started a long time ago. I just gave an example of a tool i know that uses (Import and export) such text formats (not only in Binary data).

Btw...about the results...here is a new version of the simple benchmark i made for RosAsm that can displays the results until the asc file is fixed (From JJ or others that are used with masmbasic syntax).

Since i´ll use the tool inside RosAsm and also on a dll, i´ll write the necessary error flags and also see how much performance can be delayed if i include the routines to convert the inputted string to make the function works case insensitive.

Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

zedd151

0 cycles -> StrLenW_Guga ANSI,  Return in EAX: 0
14 cycles -> StrLenW_Lingo ANSI,  Return in EAX: 100
28 cycles -> StrLenW_Guga No SAR,  Return in EAX: 200
20 cycles -> StrLenW_Lingo No SAR,  Return in EAX: 200
16 cycles -> StrLenW_Guga with SAR,  Return in EAX: 34
14 cycles -> StrLenW_Lingo with SAR,  Return in EAX: 34




17 cycles -> Ascii Hex to Dw by Guga (new version. variable lenght),  Input: 0F2A45B7 . Return in EAX: F2A45B7

17 cycles -> Ascii Hex to Dw by Guga (new version. variable lenght),  Input: A45B7 . Return in EAX: A45B7

15 cycles -> Ascii Hex to Dw by Guga (Old version - fixed Lenght),  Input: 0F2A45B7 . Return in EAX: F2A45B7



52 cycles -> Ascii Hex to Qword by Guga (Variable Lenght),  Input: 543210F2A45B7 . Return in EAX: 13 (Bytes)
Output:
D$ 54321
D$ F2A45B7

52 cycles -> Ascii Hex to Qword by Guga (Variable Lenght),  Input: 18F2A45B7 . Return in EAX: 9 (Bytes)
Output:
D$ 1
D$ 8F2A45B7

52 cycles -> Ascii Hex to Qword by Guga (Variable Lenght),  Input: 76543210F2A45B7 . Return in EAX: 15 (Bytes)
Output:
D$ 7654321
D$ F2A45B7

52 cycles -> Ascii Hex to Qword by Guga (Variable Lenght),  Input: 76543210F2A45B7 . Return in EAX: 15 (Bytes)
Output:
D$ 7654321
D$ F2A45B7

25 cycles -> Ascii Hex to Qword by Guga (Variable Lenght),  Input: 876543210F2A45B7 . Return in EAX: 16 (Bytes)
Output:
D$ 87654321
D$ F2A45B7

:azn:  Looks good so far. Unless you might want to print the leading zeroes for the rightmost 8 bytes so that the two dwords printed in sequence appears like a qword.
¯\_(ツ)_/¯   :azn:

'As we don't do "requests", show us your code first.'  -  hutch—

guga

The leading zeroes ? Ok...it´s not part of the function itself it was only a way i made on sprintf to see if the results were as expected.

Lingo usage of bswap was a good tip. Although the code needed to be fixed to work with any odd and even sizes. Which explains why it is a bit slower when dealing with odd strings on input, since i had to create a workaround and use jmps there.

Next step is creating the case insensitive and make the necessary flags to return in eax and it´s ok to go :)
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com