Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 623317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:04:47+00:00 2026-05-13T19:04:47+00:00

This is very simple, but I haven’t been able to figure it out yet.

  • 0

This is very simple, but I haven’t been able to figure it out yet.

This question is regarding a assembly mmx, but it’s pure logic.

Imagine the following scenario:

MM0: 04 03 02 01 04 03 02 01  <-- input  
MM1: 02 02 02 02 02 02 02 02  
MM2: 04 03 02 01 04 03 02 01  <-- copy of input

after pcmpgtw MM0, MM1

MM0: FF FF 00 00 FF FF 00 00  <-- words where MM0 is greater than MM1 (comparing words)  
MM1: 02 02 02 02 02 02 02 02  
MM2: 04 03 02 01 04 03 02 01

after pand MM0, MM2  

MM0: 04 03 00 00 04 03 00 00  <-- almost there...
MM1: 02 02 02 02 02 02 02 02  
MM2: 04 03 02 01 04 03 02 01  

What I want is to know fill the zeros of MM0 with 02. I suppose I would have to invert MM0 register in step2, changing the FF’s to 00’s and the 00’s to FF’s and then do a and to MM1 and finally a or to merge the two.

If I was able to get:

MM3: 00 00 FF FF 00 00 FF FF

then, pand MM2, MM3

MM1: 04 03 00 00 04 03 00 00  
MM2: 00 00 02 02 00 00 02 02

finally por MM0, MM1 would give me the desired outcome:

MM0: 04 03 02 02 04 03 02 02  <-- Aha!

Summing up, how can I get that MM3 register as 00 00 FF FF 00 00 FF ? How can I invert the bits, proving I only have AND, OR, XOR and NAND instructions available in MMX registers?

Any answer is greatly appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:04:48+00:00Added an answer on May 13, 2026 at 7:04 pm

    You can also generate the mask using pcmpgtw and swap the order of the arguments. That way you can save a register:

    MM0: 04 03 02 01 04 03 02 01  <-- input  
    MM1: 02 02 02 02 02 02 02 02  
    MM2: 04 03 02 01 04 03 02 01  <-- copy of input
    
    
    pcmpgtw MM0, MM1    ; MM0 = FF FF 00 00 FF FF 00 00 
    pcmpgtw MM1, MM2    ; MM1 = 00 00 FF FF 00 00 FF FF
    

    You may have to make a copy of the MM1 argument because it will get destroyed during mask generation, but this is often faster than loading/generating a 64 bit constant.

    A alternative way would be to use PNAND:

    pcmpgtw MM0, MM1    ; MM0 = FF FF 00 00 FF FF 00 00 
    
    pand    MM2, MM0    ; leave bytes with FF intact 
    pnand   MM1, MM0    ; leave bytes with 00 intact 
    por     MM1, MM2    ; combine the results.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is another probably very simple question, but I haven't been able to find
This is a very simple question, but I haven't seem to be able to
This question might appear very simple, but i haven't found an answer yet, so
This is a very basic question - but I haven't been able to find
I've been stuck on this likely very simple problem, but haven't gotten anywhere with
This may be a very simple question, but I haven't found an answer to
This may look like a very simple question, but I haven't found the answer
This may be very simple question,But please help me. i wanted to know what
This is probably a very simple question but I'm a little confused how this
This looked like a very simple question but I couldn't find the answer. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.