Brad Mitchell wrote: > I'm taking something I wrote in Parallax 's assembler, and now just > starting to learn the Micro chip MPASM , I find something a bit > confusing. > > 1. Port direction control > 2. port reading/writing.. ie: every interface to the world.. > > The problem arises because Parallex in their manual states that > this is the instruction.. MOV #literal !RA for example sets the > direction for the register, but in the Micro chip version, they are > using the TRST command that is, according to the Micor chip test, > not to be supported in the future. Brad: You didn't say which PIC you're using, so I'll assume that it's one of the 16C5x family. Port Direction control on the '5x is accomplished via the TRIS instruction, the syntax of which is "TRIS port", where "port" is PORTA, PORTB, or (on the C55 or C57) PORTC. TRIS uses the contents of the W-register to select the direction of the port's I/O pins: 0's are outputs and 1's are inputs. Here's an example: MOVLW 00001111B ;Make RB4-7 outputs, RB0-3 inputs. TRIS PORTB To read the I/O pins, just use any instruction that reads from the port's register. Here are two examples: MOVF PORTB,W ;Copy the contents of PORTB to W. BTFSS PORTB,3 ;Skip the next instruction if RB3 is hig h. To write to the I/O pins, use any instruction that writes to the port's register. Here are another two examples: MOVWF PORTB ;Copy the contents of the W-reg to PORTB . BSF PORTB,3 ;Pull RB3 high. CLRF PORTB ;Pull all the PORTB outputs low. Use of the TRIS command in 16Cxx (NOT 16C5x) parts is, as you mentioned, discouraged by Microchip in their data books. However, they have yet to produce a 16Cxx part that doesn't include the TRIS instruction. If you're using the 16C5x parts, on the other hand, you can ignore the warning; the TRIS command is the only way to set the port direction on the 16C5x. -Andy P.S. You can probably learn a lot by comparing the Parallax "instructions" to the PIC opcodes to which Parallax's assembler translates them. Last time I looked, Parallax included a translation table in their PASM documentation. Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California http://www.geopages.com/SiliconValley/2499