1 /* @skeleton@ @1@ @L@ */
7 * and related functions
13 #include "auproto-pic.h"
15 extern void enco_pic_any(PicInsn *out, int opcode, int argbits, int objnum) {
16 unsigned long as= objnum;
19 assert(!(as & (~0UL << argbits)));
20 out->l= 1 + argbits/7;
24 out->d[i]= (as & 0x07fUL) | 0x080UL;
25 out->d[out->l - 1] &= ~0x080UL;
30 #define ENCO(w, xa, opcode, argbits, objnum) \
31 extern void enco_pic_##w(PicInsn *out xa) { \
32 return enco_pic_any(out, opcode, argbits, objnum); \
35 ENCO(pii, C const PicInsnInfo *pii C int objn,pii->opcode,pii->argbits,objn)
36 ENCO(@cnameyn@, , @opcodeyn@, 0,0) @h2p@ @arglentf=0@
37 ENCO(@cnameyn@, C int objnum, @opcodeyn@, @arglen@,objnum) @h2p@ @arglentf=1@
39 const PicInsnInfo *lookup_byopcode(Byte byte0, const PicInsnInfo *table) {
40 const PicInsnInfo *pi;
44 if ((byte0 & pi->mask) == pi->opcode)
49 void picinsn_decode(const PicInsn *pi, const PicInsnInfo *table,
50 const PicInsnInfo **pii_r, int *objnum_r) {
51 const PicInsnInfo *pii;
54 pii= pi->l > 0 ? lookup_byopcode(pi->d[0], table) : 0;
58 if (pii->argbits <= 6) {
59 if (pi->l != 1) pii= 0;
61 if (pi->l == 2 && !(pi->d[1] & 0x80u)) { val <<= 7; val |= pi->d[1]; }
66 if (objnum_r && pii) *objnum_r= val & ((1u << pii->argbits) - 1);
70 const PicInsnInfo pic_command_infos[]= {
71 { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, @noiselevel@, 0 }, @h2p@
75 const PicInsnInfo pic_reply_infos[]= {
76 { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, @noiselevel@, on_pic_@cnameyn@ },@p2h@