thanks all my friends

I have this subroutine for display decimal number on 7 segement 4 digit
for examlpe when I try to display 1230 in proteuse simulation is not work properly
I have tow problem:
1-correct subroutine for displaying decimal number
2-and how I can include this subroutine with commands Serout serin in tow pic when first pic (transemetre) send decimal number the second pic (receiver) must receive it and display it on 7 segment 4 digit
and thank you very much for your help


subroutine to display decimal number
w1 var word
b0 var byte
TRISA=%00000000
TRISB=%00000000

loop:
w1=1230
gosub disp
goto loop
disp:

B0 = W1 / 1000 ' Find number of thousands
W1 = W1 // 1000 ' Remove thousands from W1
Gosub bin2seg ' Convert number to segments
Poke PortB, B0 ' Send segments to LED
Poke PortA, $17 ' Turn on fourth digit
Pause 1 ' Leave it on 1 ms
Poke PortA, $1F ' Turn off digit to prevent ghosting
B0 = W1 / 100 ' Find number of hundreds
W1 = W1 // 100 ' Remove hundreds from W1
Gosub bin2seg ' Convert number to segments
Poke PortB, B0 ' Send segments to LED
Poke PortA, $1B ' Turn on third digit
Pause 1 ' Leave it on 1 ms
Poke PortA, $1F ' Turn off digit to prevent ghosting
B0 = W1 / 10 ' Find number of tens
W1 = W1 // 10 ' Remove tens from W1
Gosub bin2seg ' Convert number to segments
Poke PortB, B0 ' Send segments to LED
Poke PortA, $1D ' Turn on second digit
Pause 1 ' Leave it on 1 ms
Poke PortA, $1F ' Turn off digit to prevent ghosting
B0 = W1 ' Get number of ones
Gosub bin2seg ' Convert number to segments
Poke PortB, B0 ' Send segments to LED
Poke PortA, $1E ' Turn on first digit
Pause 1 ' Leave it on 1 ms
Poke PortA, $1F ' Turn off digit to prevent ghosting
Return ' Go back to caller

' Convert binary number in B0 to segments for LED
bin2seg: Lookup B0,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18],B0
Return