Hi experienced All:
I am trying to check advantages and disadvantages
of Three PICs Architecture.
I appreciate any comments and thoughts how to improve
program below that will serve output functions
in Output PIC.
Thank you for your time.
Best Regards,
Leonid
P.C.PICBasic Pro Compiler tell: success: 995 word used
My inner filling tell me that is possabilities to improve
this program.

'PIC16F84A
'This program only example that I will test
'in Three PICs Architecture: Input PIC,Output PIC, and Control PIC.
'This program serve output PIC.
'Program used combination pins PortA.0 - PortA.4 for input
'to change state of pins PortB.0 - PortB.5 and 6,7 for output
'Input cominations come from second PIC
'Order
'1. PortA.4=0 Halt program
'2. change code PortA.0-PortA.2 and result code from 1 to 7
'will choose program from 1 to 7
'3. PortA.3=0 set program
'4. PortA.4=1 preset
'5. PortA.3=1 run choosen program
DEFINE OSC 20
DEFINE _CP_OFF $3FFF
DEFINE _PWRTE_OFF $3FFF
DEFINE _WDT_OFF $3FFB
DEFINE _XT_OSC $3FFD
DEFINE _HS_OSC $3FFE
OPTION_REG = %10000000
INTCON = %00000000
c var byte
d var byte
e var byte
b16 var BYTE
w9 var WORD
'set constant
b0 con %00000000
b1 con %00000001
b2 con %00000010
b3 con %00000100
b4 con %00001000
b5 con %00010000
b6 con %00100000
b7 con %00001001
b8 con %00010010
b9 con %00100100
b10 con %00011011
b11 con %00110110
b12 con %00101101
b13 con %00010010
b14 con %00111111
b15 con %00010101
'Set Ports
poke TRISA, 255 '31
poke TRISB, b0
'Initialize variable
w9 = $2710
Halt:
poke PORTB, b0
peek PORTA, b16
IF PortA.3 = 0 Then Switch
IF PortA.4 = 0 Then Halt
goto Halt
Switch:
poke PORTB, b0
peek PORTA, b16
IF PortA.0 = 1 Then c = $1
c=0
IF PortA.1 = 1 Then d = $2
d=0
IF PortA.2 = 1 Then e = $4
e=0
Let b16=c+d+e
IF b16=$1 Then PROG1
IF b16=$2 Then PROG2
IF b16=$3 Then PROG3
IF b16=$4 Then PROG4
IF b16=$5 Then PROG5
IF b16=$6 Then PROG6
IF b16=$7 Then PROG7
goto Switch
PROG1: '------------Program #1
peek PORTA, b16
IF PortA.4=0 Then Halt
IF PortA.2=0 Then RL1
gOTO ROR1
Goto PROG1
RL1: '------------Block Rotate Left 1
poke PORTB, b6
pulsout 6, w9
poke PORTB, b5
pulsout 6, w9
poke PORTB, b4
pulsout 6, w9
poke PORTB, b3
pulsout 6, w9
poke PORTB, b2
pulsout 6, w9
poke PORTB, b1
pulsout 7, w9
call M1
goto PROG1
M1:
If PORTA.0 = 1 Then P1
w9 = w9 - 1
If w9 < $100 Then Lm1
goto PROG1
P1:
If PORTA.1 = 1 Then PROG1
w9 = w9 + 1
If w9 > $5000 Then Lp1
w9 = $5000
Goto PROG1
Lm1:
w9 = $100
Goto PROG1
Lp1:
w9 = $5000
Goto PROG1
ROR1:
poke PORTB, b1
pulsout 6, w9
poke PORTB, b2
pulsout 6, w9
poke PORTB, b3
pulsout 6, w9
poke PORTB, b4
pulsout 6, w9
poke PORTB, b5
pulsout 6, w9
poke PORTB, b6
pulsout 7, w9
call M1
goto PROG1
PROG2: '------------Program #2
peek PORTA, b16
IF PortA.4= 0 Then Halt
IF PortA.2= 0 Then RL2
IF PortA.2= 1 Then ROR2
Goto PROG2
RL2: '------------Block Rotate Left 2
poke PORTB, b9
pulsout 6, w9
poke PORTB, b8
pulsout 6, w9
poke PORTB, b7
pulsout 7, w9
call M2
goto PROG2
M2:
If PORTA.0 = 1 Then P2
w9 = w9 - 1
If w9 < $100 Then Lm2
goto PROG2
P2:
If PORTA.1 = 1 Then PROG2
w9 = w9 + 1
If w9 > $5000 Then Lp2
w9 = $5000
Goto PROG2
Lm2:
w9 = $100
Goto PROG2
Lp2:
w9 = $5000
Goto PROG2
ROR2: '------------Block Rotate Right 2
poke PORTB, b7
pulsout 6, w9
poke PORTB, b8
pulsout 6, w9
poke PORTB, b9
pulsout 7, w9
call M2
goto PROG2
PROG3: '------------Program #3
peek PORTA, b16
IF PortA.4= 0 Then Halt
IF PortA.2= 0 Then RL3
IF PortA.2= 1 Then RR3
Goto PROG3
RL3: '------------Block Rotate Left 3
poke PORTB, b12
pulsout 6, w9
poke PORTB, b9
pulsout 6, w9
poke PORTB, b11
pulsout 6, w9
poke PORTB, b8
pulsout 6, w9
poke PORTB, b10
pulsout 6, w9
poke PORTB, b7
pulsout 7, w9
call M3
goto PROG3
M3:
If PORTA.0 = 1 Then P3
w9 = w9 - 1
If w9 < $100 Then Lm3
goto PROG3
P3:
If PORTA.1 = 1 Then PROG3
w9 = w9 + 1
If w9 > $5000 Then Lp3
w9 = $5000
Goto PROG3
Lm3:
w9 = $100
Goto PROG3
Lp3:
w9 = $5000
Goto PROG3
RR3: '------------Block Rotate Right 3
poke PORTB, b7
pulsout 6, w9
poke PORTB, b10
pulsout 6, w9
poke PORTB, b8
pulsout 6, w9
poke PORTB, b11
pulsout 6, w9
poke PORTB, b9
pulsout 6, w9
poke PORTB, b12
pulsout 7, w9
call M3
goto PROG3
PROG4: '------------Program #4
IF PortA.4= 0 Then Halt
IF PortA.2= 0 Then RL4
IF PortA.2= 1 Then RR4
Goto PROG4
RL4: '------------Block Rotate Left 4
poke PORTB, b14
pulsout 6, w9
poke PORTB, b15
pulsout 6, w9
poke PORTB, b14
pulsout 6, w9
poke PORTB, b13
pulsout 7, w9
call M4
goto PROG4
M4:
If PORTA.0 = 1 Then P4
w9 = w9 - 1
If w9 < $100 Then Lm4
goto PROG4
P4:
If PORTA.1 = 1 Then PROG4
w9 = w9 + 1
If w9 > $5000 Then Lp4
w9 = $5000
Goto PROG4
Lm4:
w9 = $100
Goto PROG4
Lp4:
w9 = $5000
Goto PROG4
RR4: '------------Block Rotate Right 4
poke PORTB, b13
pulsout 6, w9
poke PORTB, 14
pulsout 6, w9
poke PORTB, 15
pulsout 6, w9
poke PORTB, b14
pulsout 7, w9
call M4
goto PROG4
PROG5: '------------Program #5
IF PortA.4= 0 Then Halt
GOTO RR5
Goto PROG5
M5:
If PORTA.0 = 1 Then P5
w9 = w9 - 1
If w9 < $100 Then Lm5
goto PROG5
P5:
If PORTA.1 = 1 Then PROG5
w9 = w9 + 1
If w9 > $5000 Then Lp5
w9 = $5000
Goto PROG5
Lm5:
w9 = $100
Goto PROG5
Lp5:
w9 = $5000
Goto PROG5
RR5: '------------Block Rotate Right 5
poke PORTB, b10
pulsout 6, w9
poke PORTB, b14
pulsout 6, w9
poke PORTB, b11
pulsout 6, w9
poke PORTB, b14
pulsout 6, w9
poke PORTB, b12
pulsout 6, w9
poke PORTB, b14
pulsout 7, w9
call M5
goto PROG5
PROG6: '------------Program #6
IF PortA.4= 0 Then Halt
IF PortA.2= 0 Then RL6
IF PortA.2= 1 Then RR6
Goto PROG6
RL6: '------------Block Rotate Left 6
poke PORTB, b13
pulsout 6, w9
poke PORTB, b15
pulsout 7, w9
call M1
goto PROG6
M6:
If PORTA.0 = 1 Then P6
w9 = w9 - 1
If w9 < $100 Then Lm6
goto PROG6
P6:
If PORTA.1 = 1 Then PROG6
w9 = w9 + 1
If w9 > $5000 Then Lp6
w9 = $5000
Goto PROG6
Lm6:
w9 = $100
Goto PROG6
Lp6:
w9 = $5000
Goto PROG6
RR6: '------------Block Rotate Right 6
poke PORTB, b15
pulsout 6, w9
poke PORTB, b13
pulsout 7, w9
call M6
goto PROG6
PROG7: '------------Program #7
IF PortA.4= 0 Then Halt
GOTO RL7
Goto PROG7
RL7: '------------Block nO RotateD 7
poke PORTB, b0
pulsout 6, w9
poke PORTB, b14
pulsout 7, w9
call M7
goto PROG7
M7:
If PORTA.0 = 1 Then P7
w9 = w9 - 1
If w9 < $100 Then Lm7
goto PROG7
P7:
If PORTA.1 = 1 Then PROG7
w9 = w9 + 1
If w9 > $5000 Then Lp7
w9 = $5000
Goto PROG7
Lm7:
w9 = $100
Goto PROG7
Lp7:
w9 = $5000
Goto PROG7
End