chiark / gitweb /
new bit-twiddling and pindata arrangements build
authorian <ian>
Sun, 4 Dec 2005 19:56:18 +0000 (19:56 +0000)
committerian <ian>
Sun, 4 Dec 2005 19:56:18 +0000 (19:56 +0000)
17 files changed:
cebpic/.cvsignore
cebpic/Makefile
cebpic/common.inc
cebpic/manypics.make
cebpic/pindata.inc [deleted file]
detpic/.cvsignore
detpic/Makefile
detpic/detect.asm
detpic/detect.inc
detpic/morse.messages
detpic/pindata.inc
detpic/slave.asm
detpic/test-sofar.asm
detpic/variables.asm
layout/.cvsignore
layout/Makefile
layout/data2safety

index 13f1d6283d32f5567b5e1c57d2c0bcca359bf183..1b610ece3e5dc69831e276f863341b7af1de6b49 100644 (file)
@@ -8,5 +8,5 @@ blank[0246].asm
 gpsim.log
 idlocs*.asm
 morse+auto.inc
-ours-pindata.asm
+ours+pindata.asm
 routines.lib
index 55d481a0774d62dd9566a353eb5f969ea05efe4e..e576b231a47067d2ab4eaf6683c15059025deec8 100644 (file)
@@ -12,7 +12,7 @@ PROGRAMS=     led-flash send-serial panic reply-serial        \
 ROUTINES=      routines-led
 LIBS=          routines.lib                            
 
-INCLUDES=      common.inc pindata.inc ../iwjpictest/clockvaries.inc
+INCLUDES=      common.inc ../iwjpictest/clockvaries.inc
 
 include manypics.make
 
index 8df410868ae33059fb050741b533ca5d3b3ed146..844920c1efb989eca11e49fe24484132155cd558 100644 (file)
@@ -30,26 +30,6 @@ TESTFLASH       equ     04h     ; test LED flash pattern
 morse_messages_start   equ     0x4000
 morse_messages_end     equ     0x4400
 
-;--------------------
-; Areas filled in by ../layout/ours-pindata.asm
-;  (see pindata.inc for details)
-pt_pic_data            equ     0x6000
-pt_port_data           equ     0x6100
-pt_bit_data            equ     0x6200
-
-sense_pic_data         equ     0x6400
-sense_port_data                equ     0x6500
-sense_bit_data         equ     0x6600
-
-reverse_pic_data       equ     0x6800
-reverse_port_data      equ     0x6900
-reverse_bit_data       equ     0x6a00
-
-pt_num_max             equ     256
-sense_num_max          equ     256
-reverse_num_max                equ     256
-
-
 ;----------------------------------------
 ; ifbit1(REGISTER,BITNUMBER)
 ;       executes the next instruction but only if bit BITNUMBER
index eda53a299bb231b78851960a4d186243a6ad78f3..6ad265ac3990ebfd29a6949cb00409d4409ad95b 100644 (file)
@@ -32,7 +32,8 @@ define makesubmakefile
 set -e; d=.submakefile.new; rm -f $$d; for f in "$$@";do echo "$$f" >>$$d; done
 --
 $(foreach prog, $(PROGRAMS), $(call define_prog,$(prog)))
-$(foreach da, idlocs% config %+morse blank%, $(call define_directasm,$(da)))
+$(foreach da, idlocs% config %+morse %+pindata blank%,
+   $(call define_directasm,$(da)))
 endef
 
 .submakefile:  $(CEBPIC)manypics.make Makefile
@@ -79,11 +80,11 @@ morse+auto.inc:     $(CEBPIC)morse-generator morse.messages
                ' <$< $o
 
 %+vars.fin:    %.asm $(CEBPIC)manypics.make
-               perl -ne '                                      \
+               perl -ne '                                              \
                        BEGIN { print "; autogenerated - do not edit\n"; } \
-                       next unless m/^(\w+)\s/;                \
-                       next if m/^\w+\s+equ\s+/;               \
-                       print " extern $$1\n" or die $$!;       \
+                       next unless m/^(\w+)\s/;                        \
+                       next if m/^\w+\s+(?:equ|udata|udata_acs)\s+/;   \
+                       print " extern $$1\n" or die $$!;               \
                ' <$< $o
 
 %+morse.asm:   $(CEBPIC)morse-generator morse.messages %+program.map
@@ -95,7 +96,7 @@ morse+auto.inc:       $(CEBPIC)morse-generator morse.messages
 idlocs%.asm:   $(CEBPIC)make-idlocs ../layout/ours.wiring
                ./$^ $* >$@.new && mv -f $@.new $@
 
-ours-pindata.asm: ../layout/ours-pindata.asm
+ours+pindata.asm: ../layout/ours+pindata.asm
                cp $< $@
 
 manypic-clean: pic-clean
diff --git a/cebpic/pindata.inc b/cebpic/pindata.inc
deleted file mode 100644 (file)
index 8a59d20..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-; This .inc file is included by the autogenerated ours-pindata.asm
-; and should define the things that ours-pindata.asm needs.
-
-; ours-pindata.asm contains data specifying which PIC pins correspond
-; to which points (`pt'), section reversers (`reverse') and section
-; detections (`sense').
-;
-; Objects are numbered starting at 1; object number 0 is always
-; unused/undefined.
-;
-; For each object kind KIND there are three data areas in
-; to the flash program memory, starting at
-;  KIND_pic_data
-;  KIND_port_data
-;  KIND_pin_data
-; (all of which must be defined by this file, pindata.inc,
-; or something it includes - they're in common.inc at the moment).
-;
-; Each of these data areas is an array of bytes, one per object.  The
-; first byte (at KIND_pic_data) is for object no.0, the next (at
-; KIND_pic_data+1) is for object no.1, etc.  (Object no.0 is never
-; used.)
-;
-; The byte values in each section are as follows:
-;
-;   KIND_pic_data    PIC number which controls this object (0 for the
-;                    master PIC, etc.).  0xff if this object number is
-;                    undefined/unused.  The KIND_pic_data array is
-;                    filled up to but not including KIND_pic_data +
-;                    KIND_num_max.  (KIND_num_max must be defined by
-;                    pindata.inc ie in common.inc).
-;
-;   KIND_port_data   Low byte of address of the relevant LATx for the
-;                    object.  If the object number is unused, the
-;                    value in flash is undefined (ie it may be
-;                    anything).
-;
-;   KIND_pin_data    Byte with exactly one bit, being the relevant
-;                    bit of the LATx/PORTx/TRISx.  If the object
-;                    number is unused, the value in flash is undefined
-;                    (ie it may be anything).
-
-       include common.inc
index f13daf98f3f6b7bcaa1c620752335321e45b018f..1c969ff3652f948296b978ae473b1e47dd287bf8 100644 (file)
@@ -10,5 +10,5 @@ blank[0246].asm
 gpsim.log
 idlocs*.asm
 morse+auto.inc
-ours-pindata.asm
+ours+pindata.asm
 syncwrite.asm
index 0679bc27532c2b86fb916208dce090d888587378..e3c731d8008ff6fd993c01e204d7390872fa5276 100644 (file)
@@ -7,7 +7,7 @@ OBJS_test-sofar=        vectors.o panic.o routines-led.o i2clib.o       \
                        misc.o slave.o detect.o variables.o             \
                        syncwrite.o
 XCODEN_test-sofar=     morse
-XCODE1_test-sofar=     blank2 blank6
+XCODE1_test-sofar=     blank2 ours+pindata
 
 INCLUDES=      common.inc                      \
                final.inc                       \
index 0326ff15c523c8bbb7dcd8a99c8091ddb3d92884..72cdad1200c5898754bf7e07cc9a58253e08a4e0 100644 (file)
@@ -99,7 +99,7 @@ message_buffer_end
 ; will be read).  outmsg_end points to the first byte after the
 ; message, and is used for read overrun detection.
 ;
-; During i2csu_read_start (High ISR), the actual first byte of the
+; During i2csu_read_begin (High ISR), the actual first byte of the
 ; message to be sent is calculated from buf0, and transmitted; the
 ; extra detection bytes (if any) are stored in outbuf, and any extra
 ; messages (from message_buffer) are also appended to outbuf.
@@ -109,15 +109,15 @@ message_buffer_end
 
 ;----------
 det_common_init
-       mov_lw  0b111   ; turn off comparator, or we can't use pins
+       mov_lw  b'111'  ; turn off comparator, or we can't use pins
        mov_wf  CMCON   ;   RD0-RD4 as digital inputs
-       mov_lw  0b0110  ; turn off A/D except perhaps for pin
-       or_wff  ADCON1  ;   AN0 ie SPARE ie RA0 (same reason as above)
+       mov_lw  b'0110' ; turn off A/D except perhaps for pin
+       ior_wff ADCON1  ;   AN0 ie SPARE ie RA0 (same reason as above)
        return
 
 ;----------
 det_slave_init
-       bsr     det_common_init
+       rcall   det_common_init
        set_f   scana
        set_f   scanb
        set_f   scanc
@@ -150,8 +150,8 @@ slave_add_short_message
 i2csu_read_begin
 ; called from High ISR, see i2clib.inc
        bt_f_if1 idloc1,idloc1_boarddet
-       bra     det_slave_read_start_detectors
-       bra     det_slave_read_start_reversers
+       bra     i2csu_read_begin_detectors
+       bra     i2csu_read_begin_reversers
 
 ;----------
 i2csu_read_another
@@ -282,7 +282,7 @@ i2csu_read_begin_detectors
 ;----------------------------------------------------------------------
 ; both detectors and reversers
 ;
-i2csu_read_start_either_tail
+i2csu_read_begin_either_tail
        set_f   scana
        set_f   scand
 
@@ -295,7 +295,7 @@ msg_copy_loop
        mov_wf  POSTINC2
        bra_n   msg_copy_loop
 
-       mov_ff  FSR2L, outmsg_lastbyte
+       mov_ff  FSR2L, outmsg_end
 
 reset_message_buffer
 ;  FSR1/buf0/message_buffer    any             set to empty
@@ -307,7 +307,7 @@ reset_message_buffer
 
 ;----------
 new_i2c_outmsg
-; Called from i2csu_read_start ISR to check that the whole of
+; Called from i2csu_read_begin ISR to check that the whole of
 ; the previous message was read, and to reset the FSR2 pointer
 ; to point to the start of outbuf so that we can fill the outbuf.
        mov_fw  FSR2L           ; W -> byte after the one we last sent
@@ -349,7 +349,7 @@ i2csu_read_begin_reversers
 
        rcall   new_i2c_outmsg
 
-       bra     both_startread_tail
+       bra     i2csu_read_begin_either_tail
 
 ;======================================================================
  include final.inc
index db1511bc770701f9db9dac75ff5abe513fb420bd..70f580dd5883b437de98b1825772df0b1c056306 100644 (file)
@@ -1,5 +1,3 @@
- extern det_slave_setup
- extern det_scanloop_reversers
- extern det_scanloop_detectors
- extern det_read_start_reversers
- extern det_read_start_detectors
+ extern det_slave_init
+ extern backgroundloop_reversers
+ extern backgroundloop_detectors
index b6848c9d2b1b8aca3f7bf9e21013fcff74380117..8f5cd899c66a79b7948d47910d87a4e0e04f4f5f 100644 (file)
@@ -46,8 +46,8 @@ SD    i2clib:st                       ; impr. i2cm_read_done/i2cs_read_data
 
 # Messages for slave detection/i2c
 DW                                     ; slave write (nyi)
-DQ     FSR2L,outmsg_end                ; previous slave read incomplete
-DR     FSR2L,outmsg_end                ; slave read overrun
+DQ     FSR2L,:outmsg_end               ; previous slave read incomplete
+DR     FSR2L,:outmsg_end               ; slave read overrun
 
 # Messages for specific peripherals
 PS     FSR0L                           ; POLARITY message too short
index cba20d75133a38b424e16f5bf6633fecd683e09c..2ffce54f5078767a6d61d7c1952436fea4924d71 100644 (file)
@@ -1,19 +1,9 @@
 ;======================================================================
 
-pt_pic_data            equ     0x5000
-pt_port_data           equ     0x5100
-pt_bit_data            equ     0x5200
+picno2ptmap            equ     0x6000
+bkptix2portnumbitnum   equ     0x6100
+pic2detinfo            equ     0x6200
+picno2revbits          equ     0x6300
 
-pt_num_max             equ     255
-
-sense_pic_data         equ     0x5400
-sense_port_data                equ     0x5500
-sense_bit_data         equ     0x5600
-
-sense_num_max          equ     255
-
-reverse_pic_data       equ     0x5800
-reverse_port_data      equ     0x5900
-reverse_bit_data       equ     0x5a00
-
-reverse_num_max                equ     255
+maxpic_ln2             equ     5
+maxpic                 equ     1 << maxpic_ln2
index a69174b205f0718c3466d137d355743aef872557..662797e3ba4ac011aa50c35f628091960d66fe65 100644 (file)
@@ -13,7 +13,7 @@
 ;      picno, idloc1           containing correct values read from flash
 
 slave
-       call    det_slave_setup
+       call    det_slave_init
 
        mov_fw  picno
        call    i2cs_init
@@ -21,8 +21,8 @@ slave
        mov_wf  INTCON
 
        bt_f_if1 idloc1,idloc1_boarddet
-       goto    det_scanloop_detectors
-       goto    det_scanloop_reversers
+       goto    backgroundloop_detectors
+       goto    backgroundloop_reversers
 
 ;----------
 i2csu_write_begin
index 41b2362e057019731f0ec7eb7b67ee0adf8d1f19..de5c5532ec5e907e2695a78ae4132f6afd333758 100644 (file)
@@ -72,7 +72,6 @@
 
        udata_acs
 
-t              res     1
 ch             res     1
 mode           res     1
 mode_readhex   equ     0
index 1fbbd4526a0778080d658f027c42583a8971848d..f9f16ce2b84e9f111609bcafd526059377edbd4e 100644 (file)
@@ -8,12 +8,12 @@ idloc1_boarddet       equ     6
 t              res     1       ; general temporary
 outmsg_end     res     1       ; first empty byte in outbuf
 
- udata 0x200
+outbuf_section udata 0x200
 outbuf_szln2   equ     7
 outbuf_size    equ     (1<<outbuf_szln2)
 outbuf         res     outbuf_size
 
- udata 0x0f8 ; bottom byte is all-bits-set except for 3 bitnum bits
+bitnum2bit_section udata 0x0f8
 bitnum2bit     res     8       ; bitnum2bit[x] = 1<<x
 
  include final.inc
index 5a7f64407e14e66d2614f3ccc3172f82f4b68977..75dbf06f1d600bc34a2ab81387f4613b4d2d8e01 100644 (file)
@@ -26,5 +26,5 @@ ours.redacted.forsafety
 ours.layout-data.c
 detectors.pin-info
 reversers.pin-info
-ours-pindata.asm
+ours+pindata.asm
 *.d
index 7beefbad998be4125e182ae51df980dd49c84982..742e6b0940a4fad5cd918059a98d1dda0d70c5b2 100644 (file)
@@ -22,7 +22,7 @@ LPAGES=        $(foreach x, 0 1 2 3 4 5 6, $(foreach y, 1 2 3 4 5, ours-p0-$xx$y.ps))
 CPROGS=                subseg2display compose-segenco
 
 default:       $(CPROGS) for-test-ui
-for-pic:       ours-pindata.asm
+for-pic:       ours+pindata.asm
 recurse:       $(CPROGS) for-pic for-test-ui
 all:           default lpages layers extras
 for-test-ui:   ours.graph.c ours.redactgraph ours.raw.neato.ps \
@@ -70,7 +70,7 @@ compose-segenco: compose-segenco.o
                        reversers.pin-info detectors.pin-info
                ./$(filter-out %.pin-info, $^) $o
 
-%-pindata.asm: %.layout-data.c
+%+pindata.asm: %.layout-data.c
                @:
 
 %.pin-info:    pin-info-gen ../pcb/%.net
@@ -141,7 +141,7 @@ subseg2display.o compose-segenco.o: segcmap.h
 clean:
                -rm -f -- *.d4 *~ t.* *.m *.new core
                -rm -f ours.*.ps parts.ps *.neato.ps ours.*.neato
-               -rm -f *.pin-info *-pindata.asm
+               -rm -f *.pin-info *+pindata.asm
                -rm -f *.redacted.forsafety *.redacted.forneato
                -rm -f *.oprint-*.ps *.run-layout
                -rm -f *.segcmap *.segcmapreq
index e84539a83002cc6482d7b8571132127c63c58a29..5943fe727735950cf7640e0bea073405daf26d6a 100755 (executable)
@@ -28,12 +28,16 @@ our (%nodes);
 # $nodes{$node}[$side]{Seg}
 # $nodes{$node}[$side]{End}
 
+our ($maxptixln2) = 5;
+
 our ($nextboardnum,@boardtype,%numboards,$nreverses,@sensesin,@sensesbase);
+our (@objkinds,%pin_used);
 # @boardtype[$boardnum]
 # $numboards{$type}
 # $nreverses
 # $sensesin[$page]
 # $sensesbase[$boardnum]= ($page << 7) | $baselsbyte
+# %pin_used{$objkind}[$objnum] = [ $boardnum, $pin_info, $objonboard ]
 $nextboardnum= 0;
 $nreverses= 0;
 $sensesin[0]= 0;
@@ -139,17 +143,18 @@ sub line_boards () {
     $sensesbase[$num]= ($page << 7) | $sensesin[$page];
     $sensesin[$page] += $sense_count;
 
-    &{"line_board_$type"}($num);
+    &{"line_boards_$type"}($num);
 }
 
-sub line_board_reversers ($) {
+sub line_boards_reversers {
     my ($num) = @_;
     my ($i,$objnum);
-    for ($i=0; $i<5; $i++) {
-       $objnum= so_boob('reverse', [ $num,$i ]);
+    for ($i=0; $i<6; $i++) {
+       $objnum= boob2objnum($num,$i,'reverse',0);
        $nreverses= $objnum+1 if $objnum >= $nreverses;
     }
 }
+sub line_boards_detectors { }
 
 sub mistake ($) {
     my ($m) = @_;
@@ -230,16 +235,18 @@ sub pa_boob ($) {
     return [ $1,$2 ];
 }
 
-# so_boob_KIND($boardnum,$objnum,$boardtype,$pininfo) -> global object number
+# boob2objnum_KIND($boardnum,$objnum,$boardtype,$mkused
+#  -> global object number
 
-sub so_boob_pt {
+sub boob2objnum_pt {
     my ($boardnum,$obj)=@_;
-    mistake("point encoding out of range") if $boardnum>31;
-    die if $obj > 31;
-    return ($boardnum << 5) | $obj;
+    mistake("point encoding out of range") if
+       $boardnum >= (1 << (10 - $maxptixln2));
+    die if $obj >= (1 << $maxptixln2);
+    return ($boardnum << $maxptixln2) | $obj;
 }
 
-sub so_boob_reverse {
+sub boob2objnum_reverse {
     my ($boardnum,$obj,$boardtype)=@_;
 
     # Converts board and object number (in canonical pic number plus
@@ -260,7 +267,7 @@ sub so_boob_reverse {
     
     my ($cycle,$boardincycle,$cyclebasebyte,$byte,$bit);
     die unless $boardtype eq 'reversers';
-    die if $obj > 5;
+    die $obj if $obj > 5;
     $obj = sprintf '%d', $obj;
     $obj =~ y/302154/543210/; # mapping due to polarity_do_here
     $cycle= int(($boardnum+3) / 7);
@@ -281,7 +288,7 @@ sub so_boob_reverse {
     return $byte*7 + 3 - $bit;
 }
 
-sub so_boob_sense($$$) {
+sub boob2objnum_sense {
     my ($boardnum,$obj)=@_;
     my ($inpage);
     $inpage= $obj + $sensesbase[$boardnum];
@@ -289,8 +296,23 @@ sub so_boob_sense($$$) {
     return ($boardnum << 7) | $inpage;
 }    
 
-sub so_boob ($$) {
-    my ($kind,$bo) = @_;
+sub boob2objnum ($$$$) {
+    my ($boardnum,$obj,$kind,$mkused) = @_;
+    my ($type);
+    $type= $boardtype[$boardnum];
+    return &{"boob2objnum_$kind"}($boardnum,$obj,$type,$mkused);
+}
+
+sub boob_used_bit ($$$) {
+    my ($boardnum,$obj,$kind) = @_;
+    my ($objnum);
+    $objnum= boob2objnum($boardnum, $obj, $kind, 0);
+    return defined $pin_used{$kind}[$objnum] ? 1 : 0;
+}
+
+sub so_boob ($$$) {
+    my ($kind,$mkused,$bo) = @_;
+    my ($type,$pi);
     if (defined $bo) {
        my ($board,$obj)= @$bo;
        my ($objnum,$type,$pi);
@@ -301,17 +323,18 @@ sub so_boob ($$) {
        mistake("object reference $kind $board.$obj out of range for".
                " board type $type")
            unless defined $pi->[$obj];
-       $objnum= &{"so_boob_$kind"}($board,$obj,$type,$pi);
-       $pin_used{$kind}[$objnum]= [ $board, $pi->[$obj], $obj ];
+       $objnum= boob2objnum($board,$obj,$kind,$mkused);
+       $pin_used{$kind}[$objnum]= [ $board, $pi->[$obj], $obj ]
+           if $mkused;
        return sprintf("%4d /* %d.%-2d*/", $objnum, $board, $obj);
     } else {
        return "   0 /*none*/ ";
     }
 }
 
-sub so_oboob ($$) {
-    my ($kind,$obj) = @_;
-    return so_boob($kind, defined $obj ? $obj->{BoOb} : undef);
+sub so_objboob ($$$) {
+    my ($kind,$mkused,$obj) = @_;
+    return so_boob($kind,$mkused, defined $obj ? $obj->{BoOb} : undef);
 }
 
 sub mainread () {
@@ -406,7 +429,7 @@ sub writeout () {
            $delim=' ';
            foreach $boob (@{ $ptv->{BoOb} }) {
                o($delim);
-               o(so_boob('pt',$boob));
+               o(so_boob('pt',1, $boob));
                $delim= ', ';
            }
            o(" };\n");
@@ -434,8 +457,8 @@ sub writeout () {
          "\"$seg\",", $segr->{Inv},
          $segr->{FeatCount}, ($segr->{FeatCount} ? "mfi_$seg," : '0,'),
          $segr->{Posns}, "spci_$seg,",
-         so_oboob('sense',$segr),
-         so_oboob('reverse', $segr->{Inv} ? $segr : undef));
+         so_objboob('sense',1, $segr),
+         so_objboob('reverse',1, $segr->{Inv} ? $segr : undef));
        $delim= ',';
     }
     o("\n};\n");
@@ -443,79 +466,144 @@ sub writeout () {
 
 # writeasm_KIND()
 
-sub o_section ($) {
-    my ($sec) = @_;
-    o("$sec code ${sec}_start");
+sub o_section ($$) {
+    my ($sec,$docstring) = @_;
+    o("\n;----------\n".
+      " org $sec\n");
+    o($docstring);
+}
+sub o_section_end_fill ($$$) {
+    my ($lastnumdone, $fillvalue, $entrysize) = @_;
+    if ($entrysize == 1 and $lastnumdone & 1) {
+       o(", $fillvalue & 0xff\n");
+       $lastnumdone++;
+    } else {
+       o("\n");
+    }
+    o(sprintf " fill %s, %d*(maxpic-%d)\n\n",
+      $fillvalue, $entrysize, $lastnumdone);
+}
+
+sub o_db ($;$) {
+    my ($ix,$every) = @_;
+    $every=16 unless defined $every;
+    o(($every ? $ix % $every : $ix) ? ',' : "\n db ");
 }
 
 sub writeasm_sense {
-    o_section("pindata_pic2detinfo");
-    o("Exists equ 0x8000\n".
-      "Detectors equ 0x0080\n".
-      "Reversers equ 0x0000\n");
+    my ($num, $base);
+    o_section('pic2detinfo',<<'END');
+; Table indexed by pic no., giving information about sensing
+; Each element is two bytes:
+;  1st byte   bit 7     Set iff this board exists for the purposes of sensing
+;             bits 6-3  Not used, set to zero
+;             bits 2-0  Top 3 bits of sense segment numbers on this board
+;  2nd byte   bit 7     Set iff this board is a Detectors board
+;             bits 6-0  Base for bottom 7 bits of segment number
+;                       (per-board segment no. is added to this; carry
+;                        to upper 3 bits is not permitted)
+END
+    o("SenseExists equ 0x80\n".
+      "Detectors equ 0x80\n".
+      "Reversers equ 0x00\n\n");
     for ($num=0; $num<@boardtype; $num++) {
-       if (!defined $boardtype[$num]) { o(" dw  0\n"); next; }
+       if (!defined $boardtype[$num]) { o(" dw  0\t\t\t\t; $num\n"); next; }
        $base= $sensesbase[$num];
-       o(sprintf " dw  Exists | %-10s | 0x%02x%02x\n",
-         ucfirst($boardtype[$num]), $base >> 7, $base & 0x7f);
+       o(sprintf " db  SenseExists | 0x%02x, %12s | 0x%02x\t; %d\n",
+         $base >> 7, ucfirst($boardtype[$num]), $base & 0x7f, $num);
+    }
+    o_section_end_fill($num, 0, 2);
+}
+
+sub writeasm_pt {
+    my ($num, $elemsize, $byte, $bit, $objnum);
+    o_section('picno2ptmap',<<'END');
+; Bitmap indexed first by pic no, and then by point no. on that board,
+; saying whether the point is present or not.  Each pic has 4 bytes,
+; ie 32 bits.  First byte is points 0 to 7, in bits 0 to 7 respectively
+; so that MSbit of byte 3 (4th byte) is point no.31.  Unused boards
+; or boards with no points are all-bits-0.
+END
+    for ($num=0; $num<@boardtype; $num++) {
+       if (!defined $boardtype[$num]) { o(" dw  0\t\t\t\t; $num"); next; }
+       die if $maxptixln2 < 4; # must be whole no. of 16-bit words
+       $elemsize= 1 << ($maxptixln2-3);
+       for ($byte=0; $byte < $elemsize; $byte++) {
+           o_db($byte, 0);
+           o("b'");
+           for ($bit=7; $bit>=0; $bit--) {
+               o(boob_used_bit($num, $byte*8 + $bit, 'pt'));
+           }
+           o("'");
+       }
+       o(" ; $num");
     }
-    o(sprintf " fill 0, maxboards_count-%d\n", $num);
     o("\n");
+    o_section_end_fill($num, 0, $elemsize);
+
+    my($typeix,$type,$pt,$pi);
+    o_section('bkptix2portnumbitnum',<<"END");
+; Table giving physical ports and pins for points for each
+; kind of board.  Index is point number (for reversers boards)
+; or point number + 2^$maxptixln2 (for detectors boards).
+; Value is one byte, either 0xff meaning that board type has
+; no such point, or top nybble being port number (0 for A, 1 for B,
+; etc.) and bottom nybble being bit number.  Ie,
+;   Index:  00Dppppp    where D is 1 iff detectors board and p is pt ix
+;   Value:  0ppp0bbb    where p is port num and b is bit num; or 0xff
+END
+    o(" radix hex\n");
+    for ($typeix=0; $typeix<2; $typeix++) {
+       $type= qw(reversers detectors)[$typeix];
+       die $type unless $pin_info{$type};
+       o("; $type:");
+       for ($pt=0; $pt < (1 << $maxptixln2); $pt++) {
+           o_db($pt);
+           $pi= $pin_info{$type}{'pt'}[$pt];
+           if (defined $pi) {
+               $pi =~ m/^(\d)\,(\d)\,/ or die;
+               o($1.$2);
+           } else {
+               o('ff');
+           }
+       }
+       o("\n");
+    }
+    o(" radix dec\n\n");
+}
+
+sub writeasm_reverse {
+    my ($num,$kc,$bit);
+    o_section('picno2revbits',<<END);
+; Table listing which reversers are connected/enabled.
+; Index is pic number.  Value is 0xff for non-reversers boards,
+; or bitmap of connected reversers.  LSbit is reverse 0, etc.
+END
+    for ($num=0; $num<@boardtype; $num++) {
+       o_db($num, 4);
+       $kc= $kind_count{$boardtype[$num]}{'reverse'};
+       if ($kc) {
+           die if $kc > 7;
+           o("b'");
+           for ($bit= $kc-1; $bit>=0; $bit--) {
+               o(boob_used_bit($num, $bit, 'reverse'));
+           }
+           o("'");
+       } else {
+           o('0xff');
+       }
+    }
+    o_section_end_fill($num, '0xffff', 1);
 }
 
-#      for $w (qw(pic port bit)) {
-#          @d=();
-#          o("\n");
-#          o("${k}_${w}_data_section  org  ${k}_${w}_data\n");
-#          for ($i=0; $i<@{ $pin_used{$k} }; $i++) {
-#              $or= $pin_used{$k}[$i];
-#              if (defined $or) {
-#                  $or->[1] =~ m/^(\d+)\,\d+,(\w+)$/;
-#                  ($portnum,$bit)= ($1,$2);
-#                  $portnum= sprintf "%02x", $portnum + 0x89; # 89=LATA
-#                  $bit= sprintf "%02x", hex $bit;
-#              } else {
-#                  $portnum=$bit='00';
-#              }
-#              if ($w eq 'pic') {
-#                  if (defined $or) {
-#                      push @d, $or->[0];
-#                  } else {
-#                      push @d, 'X',
-#                  }
-#              } elsif ($w eq 'port') {
-#                  push @d, $portnum;
-#              } elsif ($w eq 'bit') {
-#                  push @d, $bit;
-#              } else {
-#                  die;
-#              }
-#          }
-#          push @d, 'X' if @d^1;
-#          @d= map { s/^[a-f]/0$&/; sprintf "%3s", $_ } @d;
-#          for (;;) {
-#              $d[$each/2] = " $d[$each/2]" if $#d >= $each/2;
-#              last if @d <= $each;
-#              o("        db      ". join(',',@d[0..($each-1)]). "\n");
-#              @d= @d[$each..$#d];
-#          }
-#          o("        db      ".join(',',@d)."\n");
-#          if ($w eq 'pic') {
-#              o("        if \$ > ${k}_pic_data + ${k}_num_max\n".
-#                "         error \"too much ${k}_picdata\"\n".
-#                "        endif\n".
-#                "        fill 0xffff, ${k}_pic_data + ${k}_num_max - \$\n");
-#          }
-#      }
-#     }
 sub writeasm () {
     my ($k,$w,$i,@d,$or,$p,$portnum,$bit,$each);
     close STDOUT or die $!;
-    open STDOUT, ">$basename-pindata.asm" or die $!;
+    open STDOUT, ">$basename+pindata.asm" or die $!;
     o("; autogenerated - do not edit\n");
     o("        include pindata.inc\n".
       "        radix dec\n".
-      "X       equ 0xff\n");
+      "ff equ 0xff\n");
     $each= 10;
     for $k (@objkinds) {
        &{"writeasm_$k"}();