chiark / gitweb /
wip print meaning in serial_transmit
authorian <ian>
Sat, 4 Jun 2005 11:12:52 +0000 (11:12 +0000)
committerian <ian>
Sat, 4 Jun 2005 11:12:52 +0000 (11:12 +0000)
hostside/client.c
hostside/output.c
hostside/parse-proto-spec
hostside/skelproto-pic.c
hostside/skelproto-pic.h

index d7bdbfbdaf5fb2c77c8f7204fc4808d7cc749c5c..22784ed25b94bce2eb23018a3fbb3373cb18fc1f 100644 (file)
@@ -205,5 +205,5 @@ static void stdin_error(OutBufferChain *ch, const char *e1, const char *e2) {
 }
 
 void stdin_client(void) {
-  new_client(0, stdin_error, (char*)"stdin", "p");
+  new_client(0, stdin_error, (char*)"stdin", "pP");
 }
index 3081c0c9c7745d14f9134147f65242002618930a..e6d8bd3c7c53e226b6ec3831290991694f3af903 100644 (file)
@@ -6,6 +6,7 @@
 #include <stdarg.h>
 
 #include "hostside.h"
+#include "auproto-pic.h"
 
 #define FOR_OOS(s) do{                                         \
     Client *cl, *next_cl;                                      \
@@ -41,6 +42,12 @@ void output_hex(Selector sel, const char *word,
 }
 
 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);
 }
index 0ed738128b4c113d798a675540d55c9fce8dfe05..5865e425aa0d64dcc2659aeeca970c04bf64735f 100755 (executable)
@@ -35,6 +35,11 @@ sub expand_and_write () {
     pln($templl);
 }
 
+sub b2xh ($$) {
+    my ($bin,$orin) = @_;
+    return sprintf "0x%02x", (oct("0b$bin") | $orin);
+}
+
 sub process_line () {
     chomp;
     $origprotoline= $_;
@@ -58,6 +63,7 @@ sub process_line () {
     $msg =~ s/ //g;
     if ($msg =~ m/^0[01]{7}$/) {
        $opcode= $&;
+       $opcodemask= '11111111';
        $arglen= 0;
        $ybit= 0;
     } else {
@@ -73,6 +79,8 @@ sub process_line () {
            $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;
@@ -85,8 +93,10 @@ sub process_line () {
        $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();
index 651dd85232baeff12f2c1e2f4cc4cba51ce43165..5e2339c18de704a40c0df23fadc4e2a1a1ffc6f6 100644 (file)
@@ -24,12 +24,28 @@ extern void enco_pic_anyinsn(PicInsn *out, const PicInsnInfo *pii,
   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 }
 };
index 5d1762b09973e5a72587f03a23a88a8ec71e2317..e42b48c747ecd2ae0a646d9153a2724f847dd963 100644 (file)
@@ -24,9 +24,11 @@ extern void on_pic_debug(int ch);
 
 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;
 };