News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords

Started by frktons, November 25, 2012, 02:48:06 AM

Previous topic - Next topic

hutch--

Gabriel,

I tried to use the 3 algos to see what they did but I could not get it working, would it be possible for you to put the algos in a test piece ?

GabrielRavier

#106
I think I did basically what the original post asked for, which was to convert an array of 4096 dwords to an array of 4096 bytes (src is the 4096 dword array and dst the 4096 byte array)

I'll try making a more flexible algorithm that doesn't assume size nor alignment I guess lol.

The different functions do the same thing, just with different extensions (progressing through them)
My github profile
https://github.com/GabrielRavier

GabrielRavier

So I made a few new revised ones (attached), which should probably be a lot easier to test.

Basically they do what the original post asked to do, which is to move sz dwords from the array pointed to by src, transform them into bytes, and then put them into the array pointed to by dst.
My github profile
https://github.com/GabrielRavier

hutch--

What have you built this with ? I downloaded the latest version of ML.EXE but it throws an error on "movd".

Microsoft (R) Macro Assembler Version 14.15.26730.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Assembling: K:\asm32\gabriel\2\dwordToByte.asm
K:\asm32\gabriel\2\dwordToByte.asm(90) : error A2070:invalid instruction operands
K:\asm32\gabriel\2\dwordToByte.asm(91) : error A2070:invalid instruction operands
K:\asm32\gabriel\2\dwordToByte.asm(182) : error A2070:invalid instruction operands

OK, that was easy to fix, just added DWORD PTR to the three lines and it builds into an object module with no problems.

I prototyped the three procedures so it should be callable using normal MASM "invoke".

    dwordToByte      PROTO dst:dword, src:dword, sz:dword
    dwordToByteSSE2  PROTO dst:dword, src:dword, sz:dword
    dwordToByteSSSE3 PROTO dst:dword, src:dword, sz:dword

Now all I need is the data format that calls the three procedures.

GabrielRavier

I used JWasm, I guess it's more flexible and knows that movd always uses dword ptr for memory operands

Also, I used dword instead of ptr for dst and src lel.

But um dst is a pointer to an array of sz bytes (so its size is sz), src is a pointer to an array of sz dwords (so its size is sz * 4), and sz is the size.

Also I attached a version that should work with MASM. I also just found Uasm, so I'll prolly be able to make versions for AVX2 and later.
My github profile
https://github.com/GabrielRavier

hutch--

You will certainly do better with UASM as John has done some very good work there, JWASM was rough around the edges and was not properly MASM compatible. Don't be afraid to have a look at nidud's ASMC either as he has done a lot of good work as well. It is pretty much the case that ML.EXE is the only 32 bit MASM compatible assembler as it is the reference.

aw27

On the Intel 64 and IA-32 Architectures Optimization Reference Manual there is a chapter on Data Gather and Scatter which is actually what we are talking about here.