Results 1 to 4 of 4

Thread: TASM command to checking even or odd number?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Some where on Earth
    Posts
    98

    TASM command to checking even or odd number?

    Hi guys. I was just wondering if there is a command in TASM to check if the register (16 or 8 bit registers) value is in odd or even number? I'm suppose to do this project where i will add 2 array value into the register. If it check it is odd value it will add 1 into a specific location in an array. If it is even then it will add 0 into a specific array as well. If this command doesn't exist, what other method can i use to check if it is even or odd? Hope you could help me guys. Thanks!
    Anime is what i LIVE for, BREATH for, and DIE for!

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: TASM command to checking even or odd number?

    I'm not sure in TASM - but the concept of checking for ODD or EVEN involves seeing if BIT 0 (value 1) is set in the integer. If 1 is set, then the value is odd - otherwise it's even.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: TASM command to checking even or odd number?

    let say ax (8 bits) is 3F,
    so,
    3F is 63 is odd
    ax strcuture
    0011 1111
    and
    0000 0001
    so u got
    1 and that is odd
    Code:
    0AE6:0100 B83F00        MOV     AX,003F
    0AE6:0103 250100        AND     AX,0001
    so, the ax after third trace would contained 1 and u know that is odd, if zero, that mean it is even.
    if u felt my post make u happy ,
    then u could make me happy too by rating my post

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: TASM command to checking even or odd number?

    Or just use the BitTest instruction (bt) that doesn't disrupt the contents of ex...

    Code:
    mov ax, 3fh
    bt ax, 0
    jnc EVEN
    
    ODD:
    ; blah
    jmp DONE
    
    EVEN:
    ; blah
    
    DONE:
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width