}
void stdin_client(void) {
- new_client(0, stdin_error, (char*)"stdin", "p");
+ new_client(0, stdin_error, (char*)"stdin", "pP");
}
#include <stdarg.h>
#include "hostside.h"
+#include "auproto-pic.h"
#define FOR_OOS(s) do{ \
Client *cl, *next_cl; \
}
void serial_transmit(const PicInsn *pi) {
- output_hex('p', "pic-out", pi->d, pi->l);
+ const PicInsnInfo *pii;
+ pii= lookup_byopcode(pi->d[0], pic_command_infos);
+ if (!pii) {
+ ooprintf('p', "pic-out unknown\n");
+ } else {
+ }
+ output_hex('P', "pic-out-h", pi->d, pi->l);
serial_transmit_now(pi->d, pi->l);
}
pln($templl);
}
+sub b2xh ($$) {
+ my ($bin,$orin) = @_;
+ return sprintf "0x%02x", (oct("0b$bin") | $orin);
+}
+
sub process_line () {
chomp;
$origprotoline= $_;
$msg =~ s/ //g;
if ($msg =~ m/^0[01]{7}$/) {
$opcode= $&;
+ $opcodemask= '11111111';
$arglen= 0;
$ybit= 0;
} else {
$msg =~ m/^(0[01][01_]{6})$/;
$opcode= $1;
die if $opcode =~ m/_[01]/;
+ $opcodemask= $opcode;
+ $opcodemask =~ y/01_/110/;
$opcode =~ s/_/0/g;
$arglen= $msg;
$arglen =~ s/[01]//g;
$v{dname}= $dname;
$v{cname}= $cname;
$v{cnameyn}= $cname.$yval;
- $v{opcode}= sprintf "0x%02x", oct("0b$opcode");
- $v{opcodeyn}= sprintf "0x%02x", (oct("0b$opcode") | $ybit * $yval);
+ $v{opcode}= b2xh($opcode, 0);
+ $v{opcodeyn}= b2xh($opcode, $ybit * $yval);
+ $v{opcodemask}= b2xh($opcodemask, 0);
+ $v{opcodemaskyn}= b2xh($opcodemask, $ybit);
$v{arglen}= $arglen;
$v{arglentf}= sprintf "%d", !!$arglen;
expand_and_write();
out->d[0] |= pii->opcode;
}
+#if 0
+const char *pi_getarg(const PicInsn *pi, const PicInsnInfo *pi, long *a_r) {
+
+const PicInsn *pi, long *arg_o,
+#endif
+
+const PicInsnInfo *lookup_byopcode(Byte byte0, const PicInsnInfo *table) {
+ const PicInsnInfo *pi;
+ for (pi= table;
+ pi->name;
+ pi++)
+ if ((byte0 & pi->mask) == pi->opcode)
+ return pi;
+ return 0;
+}
+
const PicInsnInfo pic_command_infos[]= {
- { "@cnameyn@", @opcodeyn@, @arglen@ }, @h2p@
+ { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@ }, @h2p@
{ 0 }
};
const PicInsnInfo pic_reply_infos[]= {
- { "@cnameyn@", @opcodeyn@, @arglen@ }, @p2h@
+ { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@ }, @p2h@
{ 0 }
};
extern void enco_pic_anyinsn(PicInsn *out, const PicInsnInfo *pii, int objnum);
+const PicInsnInfo *lookup_byopcode(Byte byte0, const PicInsnInfo *table);
+
struct PicInsnInfo {
const char *name;
- Byte opcode;
+ Byte opcode, mask;
int argbits;
};