Puh - Du hast ja Probleme

Ich hab´ das gerade mal am Simulator durchgespielt - und so kann auch das klappen:

(Für dieses Beispiel :Alle 8 Bits von Port A sowie Bit 0-3 von Port B als Eingänge)

Code:
Dim Gray as Word '(Endvariable mit 16 Bit Breite)
Dim LoByte as Word '(Untere 8 Bit)
Dim HiByte as Word  '(obere 4 Bit)

LoByte = PinA
HiByte = PinB
HiByte = HiByte AND &B0000000000001111 '(Das kennen wir ja schon...)

Rotate HiByte, left, 8 '(Verschiebt die Bits von PortB um 8 Stellen nach links!)

Gray = LoByte + HiByte '(zusammenzählen...)

Gray = Gray2Min(Gray) '(...und in Binärformat umwandeln!!)
Sowas kann man übrigens PEFEKT im Simulator durchspielen. Da kannst Du alle Variablen im Dezimal-und Binärfomat sehen. Erste Gehversuche lohnen sich!!

Gruß,

Daniel

P.S.: Vielleicht geht´s auch eleganter - keine Ahnung. Bin auch noch nicht soooo der Bascom-Checker