Thread: asm AND operator

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743

    asm AND operator

    I have a question about the AND operator in assembler. What is its limit on how much you can AND at one time?

    A normal statement would be like:

    Code:
    asm {
        and dx, bx 
    }
    if you were ANDing registers, or:

    Code:
    asm {
        and myInt, dx
    }

    if you were ANDing an int with a register, etc...

    But lets say I have two arrays and want to AND them together:

    Code:
    int array[10];
    int arrayB[10];
    
    ...code to fill arrays goes here....
    
    asm {
        and array, arrayB
    }
    Am I allowed to do what I just did?

    Or what if I made them pointers:

    Code:
    int *array = new int[10];
    int *arrayB = new int[10];
    
    ...code...
    
    asm {
        and array, arrayB
    }
    Is that legal?

  2. #2
    No, those last two are not legal. You can only logically AND two variables and no more. If you want to do anything else you'll have to use a loop. Also, the variable on the right cannot be bigger than the variable on the left. It is illegal to AND mem, mem. It is only:

    and mem, reg
    and reg, mem
    and reg, const

    I do believe
    Last edited by InFeStEd-ArCh0n; 05-06-2002 at 12:29 PM.
    -Mike
    {InFeStEd-ArCh0n}

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    The registers are mostly 32bit - much less than the arrays you have declared......and so 32Bit what modern CPUs likes to play with per "and" instruction.......Not too difficult to iterate through these 2 arrays and do it that way......

  4. #4
    They are only 32 bit if you use the extended version (I.E.: edx, ecx, ebx, eax)
    -Mike
    {InFeStEd-ArCh0n}

  5. #5
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    What?

    You can do ASM in VC++?

  6. #6
    Yes you can use assembly in VC++, like this:

    Code:
    __asm
    {
    (ASM code here)
    }
    -Mike
    {InFeStEd-ArCh0n}

  7. #7
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    HOly ****!

    OMG! Yay! Yay! ASM! So sweet!

  8. #8
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    Ha....I figured it out, you can AND two arrays together...you just have to pass the memory addresses instead:

    so you do this:

    asm {
    and [array], [arrayB]
    }

    instead of this:

    asm {
    and array, arrayB
    }

    mwaha...

  9. #9
    Wow that really works? The [] around it would make sense, but how is it possible? How does it know where to end and whatnot? Where is the logic behind it?
    -Mike
    {InFeStEd-ArCh0n}

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    SEE...

    See how great is C++...$$$$

    but make sure it is les than 32 bit as what one of the BOSSES said before....
    C++
    The best

Popular pages Recent additions subscribe to a feed