Author Topic: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords  (Read 47799 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7817
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords
« Reply #105 on: October 27, 2018, 10:22:17 PM »
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 ?
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

GabrielRavier

  • Regular Member
  • *
  • Posts: 18
Re: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords
« Reply #106 on: October 28, 2018, 05:16:05 AM »
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)
« Last Edit: October 28, 2018, 09:49:02 PM by GabrielRavier »

GabrielRavier

  • Regular Member
  • *
  • Posts: 18
Re: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords
« Reply #107 on: October 28, 2018, 11:57:00 PM »
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.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7817
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords
« Reply #108 on: October 29, 2018, 06:26:26 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

GabrielRavier

  • Regular Member
  • *
  • Posts: 18
Re: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords
« Reply #109 on: October 29, 2018, 11:15:41 PM »
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.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7817
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords
« Reply #110 on: November 01, 2018, 09:31:56 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2583
  • Let's Make ASM Great Again!
Re: MASM FOR FUN - REBORN - #0 Extract low order bytes from dwords
« Reply #111 on: November 01, 2018, 09:39:21 PM »
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.