;@ ins k k k k
;@ outs k k
opcode sw41, 0, kkkkkk
  kSel, kin1,kin2,kin3,kin4, kout, kctrl xin
  kSw[][] init 4,4
  kSw fillarray 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1
  kIn1 zkr kin1
  kIn2 zkr kin2
  kIn3 zkr kin3
  kIn4 zkr kin4

  kOut = kIn1*kSw[kSel][0]+kIn2*kSw[kSel][1]+kIn3*kSw[kSel][2]+kIn4*kSw[kSel][3]
  zkw kOut, kout
  zkw kSel/4,  kctrl
endop

;@ ins a a a a
;@ outs a k
opcode sw41, 0, kkkkkk
  kSel, kin1,kin2,kin3,kin4, kout, kctrl xin
  kSw[][] init 4,4
  kSw fillarray 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1
  aIn1 zar kin1
  aIn2 zar kin2
  aIn3 zar kin3
  aIn4 zar kin4

  aOut = aIn1*kSw[kSel][0]+aIn2*kSw[kSel][1]+aIn3*kSw[kSel][2]+aIn4*kSw[kSel][3]
  zaw aOut, kout
  zkw kSel/4,  kctrl
endop
