Thank you KermMartian for the hint.This is the final code and it works...
Code:
.ORG 3000H
SCAN .EQU 05FEH
TONE .EQU 05E4H
TONE2 .EQU 05DEH ;generate sound at 1khz
TONE3 .EQU 05E2H ;generate sound at 2 khz
main:
CALL SCAN
CP 01h
JP Z,key1
CP 02h
JP Z,key2
CP 03h
JP Z,key3
CP 04h
JP Z,key4
CP 05h
JP Z,key5
CP 06h
JP Z,key6
CP 07h
JP Z,key7
CP 08h
JP Z,key8
CP 09h
JP Z,key9
CP 0h
JP Z,key0
jp nz, main
key1:
LD C,80H
LD HL,0C0H
CALL TONE; Generate sound.Input: C controls the frequency of the sound. The period is about (44 + C x 13) x 1.12 µs. The frequency is 200 / (10 + 3 x C) Hz.
jp main ; HL contains the number of cycles. Maximum value is 34768.
key2:
LD C,80H
LD HL,0C0H
CALL TONE2;
jp main
key3:
LD C,80H
LD HL,0C0H
CALL TONE3
jp main ;
key4:
LD C,50H
LD HL,5BC
CALL TONE
jp main
key5:
LD C,3H
LD HL,5BC
CALL TONE
jp main
key6:
LD C,0FH
LD HL,0C0H
CALL TONE
jp main
key7:
LD C,1AH
LD HL,2BC
CALL TONE
jp main
key8:
LD C,0C2H
LD HL,2BC
CALL TONE
jp main
key9:
LD C,0B2H
LD HL,0C0H
CALL TONE3
jp main
key0:
LD C,1EH
LD HL,2BC
CALL TONE
jp main
.END