Ich hab den Fehler schon selber gefunden:

1. Ich habe den Speicher mit einem Array auf 500 Byte aufgepumpt
2. Außerdem hab ich die if B = 0 Überprüfung entfernt.

Hier mal der funktionierende Code:
Code:
'----------------------------------------------------------------------
'                         serin_out.bas
'                    (c) 2002-2005 MCS Electronics
' demonstration of DYNAMIC software UART
'----------------------------------------------------------------------

'tip : Also look at OPEN and CLOSE

$regfile = "m168def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 9600

'some variables we will use
Dim S As String * 10
'buffer to save data
Dim B(512) As Byte
'B(0) = 0

S = Chr(13) + Chr(13) + "Im ready" + Chr(13)
Print S

'DISABLE HW UART
Ucsr0b = 0

Do
   'first get some data via JP1
   Serin B(1) , 511 , D , 2 , 38400 , 0 , 8 , 1
   'now send it
   Serout B(1) , 511 , D , 1 , 9600 , 0 , 8 , 1
        '                                      ^ 1 stop bit
        '                                  ^---- 8 data bits
        '                              ^-------- even parity (0=N, 1 = E, 2=O)
        '                         ^------------- baud rate
        '                   ^------------------- pin number
        '               ^----------------------- port so PORTA.0 and PORTA.1 are used
        '           ^--------------------------- for strings pass 0
        '      ^-------------------------------- variable
Loop
End

'because the baud rate is passed with a variable in theis example, you could change it under user control
'for example check some DIP switches and change the variable mybaud