assembly code help

Discussion in 'Assembly Language Programming (ALP) Forum' started by emaney, Jun 13, 2007.

  1. emaney

    emaney New Member

    Jun 13, 2007
    Likes Received:
    Trophy Points:
    Assembly language
    i realy need somones help with this pic16f84a question
    A de-multiplexer has an input line, pinRB0, and four output
    lines, output0 to output3, which are, respectively, the pins RA0-RA3. the
    demultiplexer copies the digital signal appearing on the input line on to one of
    the four output lines. The output line is selected by a two bit
    selection code input on the pins RB1 and RB2.
    end of question

    i have done the code,the following is the code, but its not right please can u help me fix it
    #DEFINE PAGE0 BCF 0x03,5
    #DEFINE PAGE1 BSF 0x03,5
    PCL: EQU 0x02
    STATUS: EQU 0x03
    PORTA: EQU 0x05
    TRISA: EQU 0x05
    PORTB: EQU 0x06
    TRISB: EQU 0x06
    W: EQU 0
    F: EQU 1
    ORG 0x0
    goto MAIN
    org 5
    clrf PORTA
    clrf PORTNB
    movlw B'00000111'
    iorwf TRISA,F ;RA0-RA2 as input
    clrf TRISB ;Port B0-B7 as output
      ;get the output selector
      movf PORTB,w
      rrf WREG
      andlw B'00000011'
      ;convert 0-3 to bit-mask
      call table
      movwf Mask
      ;switch all zeroes to ones in mask and vice versa
      xorlw B'11111111',w
      ;read all the bits of PORTA but the selected one (leave it clear)
      andwf PORTA,w
      ;if PORTB.0 is set, set also selected output in PORTA
      btfsc PORTB,0
      orwf Mask,w
      ;write modified value back to PORTA
      movwf PORTA
      goto loop  
      addwf PCL,F
      retlw B'00000001'
      retlw B'00000010'
      retlw B'00000100'
      retlw B'00001000'
    Last edited by a moderator: Jun 13, 2007

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice