One thing you could do is use the RETLW instruction: Call SetPortLookup Iorwf portimage,f Movf portimage,w Movwf portb . . . SetPortLookup: Andlw 7 ; bit #s from 0 to 7 only Addwf PCL,F Retlw 1 Retlw 2 Retlw 4 Retlw 8 Retlw .16 Retlw .32 Retlw .64 Retlw .128 A few notes: .64 is decimal no matter what radix you are using by default. I modified a variable rather than the port directly because of possible problems with using read modify write instructions with a port. I try to always write to a fake port register and then output the register directly. Otherwise you could have said: Iorwf portb,f You can read more about this problem in the data sheet. Also, you might enjoy http://www.al-williams.com/pictutor Good luck! Al Williams AWC * Easy RS-232 Prototyping http://www.al-williams.com/awce/rs1.htm > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Daryl Sayers > Sent: Wednesday, January 16, 2002 3:17 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: Beginners 16C84 programming question > > > Sorry for not explaining my question correctly. What I REALLY > wanted was to express the data between 0-7 as bit location to turn on. > > eg: if the data was 0x03 then I would turn on bit 3 of port B. > > The code snippet I gave showed this but my question was > incorrect. I have since tried a few ideas and have come up > with the following. I hope its not too repulsive. > > ... > CALL Setport > RETURN > > Setport > BCF STATUS, C > RLF DataByte, w > ANDLW 0fh > addwf PCL,f > bsf PORTB,0 > RETURN > bsf PORTB,1 > RETURN > bsf PORTB,2 > RETURN > bsf PORTB,3 > RETURN > bsf PORTB,4 > RETURN > bsf PORTB,5 > RETURN > bsf PORTB,6 > RETURN > bsf PORTB,7 > RETURN > > > > Do you mean: > > movf TmpByte,w > > movwf PORTB > > > Al Williams > > AWC > > * Floating point math for the Stamp, PIC, SX, or any > microcontroller > > http://www.al-williams.com/awce/pak1.htm > > > > >> -----Original Message----- > >> From: pic microcontroller discussion list > >> [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of Daryl Sayers > >> Sent: Monday, January 14, 2002 5:50 PM > >> To: PICLIST@MITVMA.MIT.EDU > >> Subject: Beginners 16C84 programming question > >> > >> > >> I had a play with a 16C84 several years ago and I now need > to make it > >> do something. I am a real PIC beginner. My simple programming > >> question is how do I represent a byte out to the RB port. > It seems my > >> restriction is using a variable in the bsf op code. I > manually did it > >> by doing each bit but I am sure there is a more elegant > way of doing > >> it through a loop. I am using gpasm-0.9.14 alpha to assemble code. > >> > >> movlw 0x01 > >> subwf TmpByte,w > >> btfsc STATUS, Z > >> bsf PORTB,0 > >> > >> movlw 0x02 > >> subwf TmpByte,w > >> btfsc STATUS, Z > >> bsf PORTB,1 > >> > >> ...... > >> > >> movlw 0x80 > >> subwf TmpByte,w > >> btfsc STATUS, Z > >> bsf PORTB,7 > >> > > -- > http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu