Current location: Hot Scripts Forums » Programming Languages » Other Languages » assembly code help


assembly code help

Reply
  #1 (permalink)  
Old 06-16-07, 04:09 AM
emaney emaney is offline
New Member
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
assembly code help

The following code does this
;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.

PLEASE LOOK AT THE CODE BECAUSE ITS NOT EXACTLY DOING WHA IT IS MENTIONED ABOVE ANYONE CAN HELP ME FIX THIS..............PLEASE


#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

MAIN:
clrf PORTA
clrf PORTNB
PAGE1
movlw B'00000111'
iorwf TRISA,F ;RA0-RA2 as input
clrf TRISB ;Port B0-B7 as output
PAGE0
loop:

;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
xorwf Mask,w

;write modified value back to PORTA
movwf PORTA
goto loop

table:

addwf PCL,F
retlw B'00000001'
retlw B'00000010'
retlw B'00000100'
retlw B'00001000'
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Explanation of Code... Please davidk19380 Perl 1 02-26-06 01:50 PM
Zip Code search range errors Merovingian PHP 2 02-09-06 03:33 PM
Have a look at my JSP code which is not giving me the desired output j.gohel Everything Java 1 04-07-05 03:55 AM
Can anyone help me ? (problem using php variables in html db insert code) chronic_ PHP 2 06-13-04 11:19 AM
How to sale php code to customer without giving him code pradeep_soft PHP 4 03-12-04 12:10 PM


All times are GMT -5. The time now is 03:41 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.