&& (and) fuction in assembly language

Discussion in 'Embedded Systems and Microcontrollers' started by BANnY, Dec 16, 2008.

  1. BANnY

    Thread Starter New Member

    Dec 16, 2008
    1
    0
    Hi all,

    I am using PIC16F877A , Assembly language, MPLAB v8.1, how should i write the && function in assembly language??? thank you
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    The && operator is associated with a comparison in which one binary value is ANDed with another binary value often referred to as a mask. The original value being compared is unaltered.

    hgmjr
     
  3. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    4
    There is a bitwise and (andwf) in PIC assembler. There is no straight && that works with whole registers. It is wasteful on resources to use one whole register for boolean logic. Most things can be done with andwf, instead of whole logical &&. Elaborate more on what you are trying to do, then we'd try to figure out on how to do it.
     
  4. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    Logical AND (&&) is simply a convention used by C (and perhaps other languages). The micros I've come across only have a bitwise AND. Using the C TRUE/FALSE convention (0 is FALSE, everything else is true) allows the logical AND effect.
    Code ( (Unknown Language)):
    1.  
    2. ;if( Monday && Noon)
    3.     LD    A,MONDAY
    4.     AND  A,NOON
    5.     IFEQ A,@00
    6.      JP    ELSE_1
    7.  
    8. ;if(Monday & Noon)
    9.     LD    A,MONDAY
    10.     AND  A,NOON
    11.     IFEQ A,@00
    12.      JP    ELSE_2
    13.  
    --Rich
     
Loading...