[quote=“fish”]right…
could you please give an example bit of code please for when input1 is on, output1 is on…
thankyou…[/quote]
Here is an example (in Pascal) for the PIC 16F627 that continously copies PortA (configured as input) to PortB (configured as output).
[code]program Test2;
begin
CMCON := 7; // Disable Comparator module’s
OPTION_REG := $D7; //Write the OPTION register.
INTCON := 0; //Disable interrupts
TRISA := $FF; // configure pins of portA as input
TRISB := 0; // configure pins of portb as output
while true do // beginning of a repeat loop
PortB := PortA;
end.[/code]
The corresponding assembly program (as delivered by the compiler, see “p.s.”):
[color=indigo]; ADDRESS OPCODE ASM
; ----------------------------------------------
$0000 $2804 GOTO _main
$0004 $ _main:
;Test2.ppas,2 :: begin
;Test2.ppas,4 :: CMCON := 7; // Disable Comparator module’s
$0004 $3007 MOVLW 7
$0005 $1303 BCF STATUS, RP1
$0006 $1283 BCF STATUS, RP0
$0007 $009F MOVWF CMCON
;Test2.ppas,6 :: OPTION_REG := $D7 ; // Write the OPTION register.
$0008 $30D7 MOVLW 215
$0009 $1683 BSF STATUS, RP0
$000A $0081 MOVWF OPTION_REG
;Test2.ppas,8 :: INTCON := 0; //Disable interrupts
$000B $018B CLRF INTCON
;Test2.ppas,10 :: TRISA := $FF; // configure pins of portA as input
$000C $30FF MOVLW 255
$000D $0085 MOVWF TRISA
;Test2.ppas,11 :: TRISB := 0; // configure pins of portb as output
$000E $0186 CLRF TRISB
;Test2.ppas,13 :: while true do // beginning of a repeat loop
$000F $ Test2_L_2:
;Test2.ppas,14 :: PortB := PortA;
$000F $1283 BCF STATUS, RP0
$0010 $0805 MOVF PORTA, 0
$0011 $0086 MOVWF PORTB
$0012 $280F GOTO Test2_L_2
;Test2.ppas,15 :: end.
$0013 $2813 GOTO $[/color]
I indicated in bold what would be the statements that you will have to write if you do it in assembler.
As you can see, the assembler statements (called “mnemonics”) are a lot more complicated than the pascal statements.
p.s.
a. The above assembly code does not show all issues, only those related to the actual “programming” of the PIC.
b. The above assembly language mnemonics are not those accepted by the assembler delivered with the programming kit. They are shown here as outputted by the pascal compiler but they give a good idea about what they looks like.
To undestand the meaning of the PIC registers like e.g. “STATUS” and “TRISA”, you will have to look into the datasheet of the PIC at hand (in these examples it is the 16F627).
I hope this helps a little. 