Hi Klaas,
thats not exactly the point, but you will regognize the difference when you start to play with the code. The first example doesn’t need a branch with the IFNEQ macro (If-Not-Equal), since simply the pot number and the pot value will be sent out. Pot #0 will send: B0 00 <value>, Pot #1: B0 01 <value>, Pot #2: B0 02 <value>, …
Your modification for the second example will work. And you see that this method will lead to a lot of code (and therefore to a high danger that anything will not work due to a copy&paste error or similar). But fortunately there are two more advanced solutions: array and jumptables.
An array can be accessed by the “table read” instruction on this way (I don’t write the complete code here, because can be found in the examples later):
(Note: the functions with capitalized letters are predefined macros which simplifies the programming - they contain some additional instructions)
 ;; get 7-bit value of pot, result in working register Â
  call   MIOS_AIN_Pin7bitGet  Â
  ;; save value in MIOS_PARAMETER1 Â
  movwf  MIOS_PARAMETER1 Â
 ;; preload table pointer with first entry of MyCCTable
 TABLE_ADDR   MyCCTable
 ;; get pot number
 movf   SAVED_POT_NUMBER, W
 ;; add pot number in WREG to table pointer
 TABLE_ADD_W
 ;; read table entry
 tblrd*
 ;; get table entry, it has been stored in TABLAT
 movf   TABLAT, W
 ;; this is our CC number. now set the CC parameter
 call   SID_CCSet  ; (value in MIOS_PARAMETER1) Â
an example for the table:
MyCCTable
    ;; define CC values for Pot #0 - #16
    db    44, 46, 48, 52, 56, 60, 61, 62, 01, 02, 03, 04, 05, 06, 07, 08
This reduces the code a lot and different banks can be defined on this way. Another advantage: for users who don’t like programming, a GUI could be provided which allows to edit such tables. The second method are jumptables. It’s like a “case” function in C. Here an example for the buttons:
;; this routine will be called when a DIN pin has been toggled.
;; DIN pin number in WREG and MIOS_PARAMETER1,
;; DIN pin value (0 or 1) in MIOS_PARAMETER2
USER_DIN_NotifyToggle
 ;; branch depending on pin number (which is in WREG)
 JUMPTABLE_2BYTES 4  ;; 2-byte instructions, 4 entries
 rgoto   DIN0_MIDIChannelDown
 rgoto   DIN1_MIDIChannelUp
 rgoto   DIN2_DeviceNumberDown
 rgoto   DIN3_DeviceNumberUp
DIN0_MIDIChannelDown
 ;; only continue if button has been pressed (value = 0)
movlw 0
IFNEQ MIOS_PARAMETER2, ACCESS, return
 call   SID_MIDIChannelGet
 addlw  -1
 call   SID_MIDIChannelSet
 return
DIN1_MIDIChannelUp
 ;; only continue if button has been pressed (value = 0)
movlw 0
IFNEQ MIOS_PARAMETER2, ACCESS, return
 call   SID_MIDIChannelGet
 addlw  1
 call   SID_MIDIChannelSet
 return
;; ...
Best Regards, Thorsten.