Hi all,

thanks for your valuable help. Following your advices, my code can look like :

TRISB = %11111111
TRISA = %00000
SWVAR VAR BYTE
SWVAR1 VAR BYTE
SWVAR2 VAR BYTE

SWVAR = PORTB
SWVAR1 = SWVAR >> 4 'Right shift myPortB 4 bits, (moves bits 7:4 to bits 3:0 and then set bits 7:4 to 0)
SWVAR2 = SWVAR & %00001111 'Mask off bits 7:4 to 0, Only get bits 3:0

IF SWVAR1 <>0 THEN GOTO SUITE

if SWVAR2 = 1 then GOTO sound1
if SWVAR2 = 2 then GOTO sound2
if SWVAR2 = 3 then GOTO sound3
...
ENDIF

SUITE:
if SWVAR1 = 1 then GOTO sound1
if SWVAR1 = 2 then GOTO sound2
if SWVAR1 = 3 then GOTO sound3
...

sound1:
FREQOUT PORTA.0,4000,500

sound2:
FREQOUT PORTA.0,4000,1000

sound3:
FREQOUT PORTA.0,4000,1500

sound4:
FREQOUT PORTA.0,4000,2000

Have a nice day.
Oleg