Another step in the development Cauchy sequence
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Wed, 19 Mar 2025 15:54:09 +0000 (15:54 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Wed, 19 Mar 2025 15:54:09 +0000 (15:54 +0000)
developer/cc馃枆/Core.lib.c
developer/cc馃枆/Map.lib.c [new file with mode: 0644]
developer/cc馃枆/TM.lib.c [new file with mode: 0644]
developer/cc馃枆/TM_scratch.c [new file with mode: 0644]
developer/document馃枆/alignment.org [new file with mode: 0644]

index 26297b8..53e0632 100644 (file)
@@ -1,29 +1,18 @@
  /*
   Core - core memory operations.
 
-  This file has the template parameter: `CVT`
+  Abbreviations used in comments:
 
-  `CVT` Cell Value Type`. It is the type of the datum placed in a cell. By default (when the   macro CVT has no definition) the cell value type is taken as AUM. This file must
-  be included with CVT undefined, before inclusions with it defined.
-  `AU` `Addressable Unit for the machine`, on most all machines today this is uint8_t,
-  though the C standard has never required this.
-
-  'ATP' `At This Point' in the code. Acronym used in comments usually before pointing
-  out certain values variables must have.
-
-  'AToW' - At Time of Writing, also used in comments.
-
-  'Tape' is operated on by the Tape Machine.
+    'ATP' `At This Point' in the code. Acronym used in comments usually before pointing
+    out certain values variables must have.
 
-  'Area' is subset of an address space that is used as a virtual Tape by a machine.
+    'AToW' - At Time of Writing, also used in comments.
 
-   An Area with zero elements has 'length == 0' or is 'empty'. In contrast, and
-   area located (position specified) with a null pointer is said not to exist.
+  Abbreviations used in identifiers:
+  `AU` `Addressable Unit for the machine`. The C standard leaves this open to definition by the architecture and calls it `char`. On most all machines today it is uint8_t;
 
-   When all the functions that have a specific type of operand given are group together
-   in a table, we call the table a 'Function Given Type X', table. In general we call
-   these FG (Function Given) tables. A specific instance of an FG table is an `fg` table.
+  We use structs to group functions into a namespace. When all the functions that have a specific type of given argument are group together, we call the table a 'Functions Given Type X table', or 'FG table' for short. A specific instance of an FG table is an `fg` table.
 
 */
 
@@ -31,7 +20,7 @@
 
 #ifndef FACE
 #define Core路IMPLEMENTATION
-#define FAC
+#define FACE
 #endif 
 
 //--------------------------------------------------------------------------------
     // reminds me of FORTRAN star types
     #define AU uint8_t
     #define AU2 uint16_t
-    #define UA4 uint32_t
-    #define UA8 uint64_t
+    #define AU4 uint32_t
+    #define AU8 uint64_t
 
-    #define AU_MAX ~(AU)0
-    #define AU2_MAX ~(AU2)0
-    #define UA4_MAX ~(AU4)0
-    #define UA8_MAX ~(AU8)0
+    #define AU_MAX (~(AU)0)
+    #define AU2_MAX (~(AU2)0)
+    #define AU4_MAX (~(AU4)0)
+    #define AU8_MAX (~(AU8)0)
 
     // ask the compiler what this is
     // when using enums we get this whether we want it or not
     #define WU unsigned int
-    #define WU ~(WU)0
+    #define WU_MAX (~(WU)0)
 
     // extent is an address or an index.  It is not a length.
     // The index scaling CVT type is appended to the end of the extent related identifiers..
-    // E.g. exent_of路AU(uint64_t) == 7 while exent_of路uint16_t(uint64_t) == 3;
-    // exent_of路AU of the address space is ~(uintptr)0;
+    // E.g. extent_of路AU(uint64_t) == 7 while extent_of路uint16_t(uint64_t) == 3;
+    // extent_of路AU of the address space is ~(uintptr)0;
     #define extent_of路AU(x)(sizeof(x) - 1)
     #define extent_t路AU size_t
 
 
   #endif
 
-  #ifdef CVT
-    #define 螢(extent_t ,CVT) size_t
-  #endif
-
   //----------------------------------------
-  // argument guard interface
+  // flag facility, argument guard facility
   //----------------------------------------
 
-  #ifndef CVT  
-
     typedef void (*Core路Flag路Fn)(WU *flag ,WU err);
 
     void Core路Flag路count(WU *flag ,WU err){
     #define Core路Guard路return(chk)\
       if( chk.flag ) return Core路Status路derailed;\
       else return Core路Status路on_track;
-
-  #endif 
+    #define Core路Guard路assert(chk) assert(!chk.flag);
 
   //----------------------------------------
   // functions interface
   //----------------------------------------
   
-  // no state, this is merely a namespace
+    // no state, this is merely a namespace
 
-  #ifndef CVT
     typedef struct{
       Core路Status (*on_track)();
       Core路Status (*derailed)();
       Core路Status (*round_up)(AU *p ,extent路AU alignment ,AU **result);
     } Core路F;
     Local Core路F Core路f;
-  #endif 
-
-  #ifdef CVT
-    typedef struct{
-      // nothing here right now
-    } 螢(Core路F ,CVT);
-    Local 螢(Core路F ,CVT) 螢(Core路F ,CVT)路f;
-  #endif
-
-  //----------------------------------------
-  // Tape Machine interface
-  //----------------------------------------
-
-  #ifndef CVT
-
-    typedef struct Core路TM_NX;
-
-    /*
-      For an CVT machine tape, a mounted tape will be singleton or segment.
-    */
-    typedef enum{
-       Core路Tape路Topo路mu = 0 
-      ,Core路Tape路Topo路nonexistent = 1 
-      ,Core路Tape路Topo路empty       = 1 << 1
-      ,Core路Tape路Topo路singleton   = 1 << 2
-      ,Core路Tape路Topo路segment     = 1 << 3
-      ,Core路Tape路Topo路circle      = 1 << 4
-      ,Core路Tape路Topo路tail_cyclic = 1 << 5
-      ,Core路Tape路Topo路infinite    = 1 << 6
-    }Core路Tape路Topo;
-
-    const Core路Tape路Topo Core路Tape路Topo路finite_nz = 
-      Core路Tape路Topo路singleton | Core路Tape路Topo路segment
-      ;
-
-    // If tape machine does not support step left, then Status路leftmost 
-    // will be reported as Status路interim.
-    typedef enum{
-       Core路TM路Head路Status路mu = 0
-      ,Core路TM路Head路Status路not_on_tape = 1
-      ,Core路TM路Head路Status路origin    = 1 << 1
-      ,Core路TM路Head路Status路interim   = 1 << 2
-      ,Core路TM路Head路Status路rightmost = 1 << 3
-    } Core路TM路Head路Status;
-
-    const Core路TM路Head路Status Core路TM路Head路Status路on_tape = 
-      Core路TM路Head路Status路origin
-      | Core路TM路Head路Status路interim
-      | Core路TM路Head路Status路rightmost
-      ;
-
-    // tape and area are included with Tape Machine to facilitate abstract interfaces.
-    typedef struct{
-
-      struct {
-        Core路Status (*topo)(Core路TM_NX *tm ,Core路Tape路Topo *topo);
-        Core路Status (*extent)(Core路TM_NX *tm ,extent_t路AU *result);
-      } tape;
-
-      struct {
-        // Initialize tm
-        Core路Status (*mount_pe)(Core路TM_NX *tm ,AU position[] ,extent_t路AU extent路AU);
-        Core路Status (*mount_pp)(Core路TM_NX *tm ,AU *position_left ,AU *position_right);
-  
-        // predicates
-        Core路Status (*encloses_pt)(Core路TM_NX *tm ,AU *pt ,bool *result);
-        Core路Status (*encloses_pt_strictly)(Core路TM_NX *tm ,AU *pt ,bool *result);
-        Core路Status (*encloses_area)(Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag);
-        Core路Status (*encloses_area_strictly)(
-          Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag
-        );
-        Core路Status (*overlap)(Core路TM_NX *a ,Core路TM_NX *b ,bool *result);
-      } area;
-
-      // tape machine functions
-      Core路Status (*mount)(Core路TM_NX *tm);
-      Core路Status (*dismount)(Core路TM_NX *tm);
-
-      Core路Status (*status)(Core路TM_NX *tm ,Core路TM路Head路Status *status);
-      Core路Status (*can_read)(Core路TM_NX *tm ,bool *flag);
-      Core路Status (*on_origin)(Core路TM_NX *tm ,bool *flag);
-      Core路Status (*on_rightmost)(Core路TM_NX *tm ,bool *flag);
-
-      Core路Status (*copy_datum)(Core路TM_NX *tm_read ,Core路TM_NX *tm_write);
-      Core路Status (*read)(Core路TM_NX *tm ,AU *read_pt);
-      Core路Status (*write)(Core路TM_NX *tm ,AU *write_pt);
-      Core路Status (*head_pt)(Core路TM_NX *tm ,AU *head_pt);
-
-      Core路Status (*rewind)(Core路TM_NX *tm);
-      Core路Status (*step)(Core路TM_NX *tm);
-      Core路Status (*step_left)(Core路TM_NX *tm);
-      Core路Status (*step_right)(Core路TM_NX *tm); // Synonym for step
-
-    } Core路TM_NX路FG;
-
-    Core路TM_NX路FG Core路TM_NX路fg;
-
-  #endif // #ifndef CVT
-
-  #ifndef CVT
-    typedef struct 螢(Core路TM_NX ,CVT);
-
-    typedef struct{
-
-      struct {
-        Core路Status (*extent)(螢(Core路TM_NX ,CVT) *tm ,螢(extent_t ,CVT) *result);
-      } tape;
-
-      struct {
-
-        // Initialize tm
-        Core路Status (*mount_pe)(Core路TM_NX tm ,CVT position[] ,螢(extent_t ,CVT) extent);
-        Core路Status (*mount_pp)(Core路TM_NX *tm ,CVT *position_left ,CVT *position_right);
-
-        // initializes inner
-        Core路Status (*largest_aligned)(Core路TM_NX_uint8_t *outer ,螢(Core路TM_NX ,CVT) *inner);
-
-        Core路Status (*encloses_pt)(螢(Core路TM_NX ,CVT) *tm ,CVT *pt ,bool *result);
-        Core路Status (*encloses_pt_strictly)(螢(Core路TM_NX ,CVT) *tm ,CVT *pt ,bool *result);
-
-        Core路Status (*encloses_area)(
-          螢(Core路TM_NX ,CVT) *outer ,螢(Core路TM_NX ,CVT) *inner ,bool *flag
-        );
-        Core路Status (*encloses_area_strictly)(
-          螢(Core路TM_NX ,CVT) *outer ,螢(Core路TM_NX ,CVT) *inner ,bool *flag
-        );
-        Core路Status (*overlap)(
-          螢(Core路TM_NX ,CVT) *a ,螢(Core路TM_NX ,CVT) *b ,bool *result
-        );
-      } area;
-
-      Core路Status (*copy_datum)( 螢(Core路TM_NX ,CVT) *tm_read ,螢(Core路TM_NX ,CVT) *tm_write );
-      Core路Status       (*read)( 螢(Core路TM_NX ,CVT) *tm ,CVT *remote_pt );
-      Core路Status      (*write)( 螢(Core路TM_NX ,CVT) *tm ,CVT *remote_pt );
-      Core路Status    (*head_pt)( 螢(Core路TM_NX ,CVT) *tm ,CVT *head_pt );
-
-
-    } 螢(Core路TM_NX ,CVT)路FG;
-
-    螢(Core路TM_NX ,CVT)路FG 螢(Core路TM_NX ,CVT)路fg;
-
-  #endif // #ifdef CVT
-
-  //----------------------------------------
-  // Map interface
-  //----------------------------------------
 
-  #ifndef CVT
-
-    typedef enum{
-       Core路Map路Status路mu = 0
-      ,Core路Map路Status路no_tape
-      ,Core路Map路Status路not_computable
-      ,Core路Map路Status路complete
-    } Core路Map路Status;
-
-    typedef enum{
-       Core路Map路Completion路mu = 0
-      ,Core路Map路Completion路null_fn                 = 1 
-      ,Core路Map路Completion路no_tape_access          = 1 << 1
-      ,Core路Map路Completion路failed                  = 1 << 2
-      ,Core路Map路Completion路perfect_fit             = 1 << 3
-      ,Core路Map路Completion路read_surplus            = 1 << 4
-      ,Core路Map路Completion路read_surplus_write_gap  = 1 << 5
-      ,Core路Map路Completion路write_available         = 1 << 6
-      ,Core路Map路Completion路write_gap               = 1 << 7
-    } Core路Map路Completion;
-
-    const uint Core路Map路Completion路derailed =
-        Core路Map路Completion路no_tape                
-      | Core路Map路Completion路not_computable         
-      | Core路Map路Completion路failed
-      ;
-
-    const uint Core路Map路Completion路on_track =
-        Core路Map路Completion路perfect_fit            
-      | Core路Map路Completion路read_surplus           
-      | Core路Map路Completion路read_surplus_write_gap 
-      | Core路Map路Completion路write_available        
-      | Core路Map路Completion路write_gap              
-      ;
-
-    typedef Core路Map路Fn (*Core路Map路Fn)(AU *x ,AU *fx);
-
-  #endif // #ifndef CVT
-
-  #ifdef CVT
-    typedef 螢(Core路Map ,CVT)路Fn (*Core路Map路Fn)(CVT *x ,CVT *fx);
-
-  #endif CVT
-
-#endif
 
 //--------------------------------------------------------------------------------
 // Implementation
       #include <stdio.h>
     #endif
 
+  //--------------------------------------------------------------------------------
   // implementation to go into the lib.a file
   //
     #ifndef LOCAL
     #endif 
 
+  //--------------------------------------------------------------------------------
   #ifdef LOCAL
 
     //----------------------------------------
     // argument guard implementation
     //----------------------------------------
 
-    #ifndef CVT
-      Local void Core路Guard路init(Core路Guard *chk ,Core路Flag路Fn af){
-        if( !chk ) return;
+      Local void Core路Guard路init(Core路Guard *chk, const char *name, Core路Flag路Fn af){
+        if(!chk) return;
+        chk->name = name;
         chk->flag_function = af;
         chk->flag = 0;
       }
 
       Local void Core路Guard路check(
          Core路Guard *chk
-        ,uint err
+        ,WU err
         ,bool condition
         ,const char *message
       ){
         ,.reset = Core路Guard路reset
         ,.check = Core路Guard路check
       };
-    #endif // *ifndef CVG
 
     //----------------------------------------
     // Functions implementation
     //----------------------------------------
 
-    #ifndef CVT
-
       Core路Status Core路on_track(){ return Core路Status路on_track; }
       Core路Status Core路derailed(){ return Core路Status路derailed; }
 
       Local Core路Status Core路is_aligned(AU *p ,extent路AU alignment ,bool *flag){
-        #ifdef Core路Debug
+        #ifdef Core路DEBUG
           Core路Guard路init_count(chk);
           Core路Guard路fg.check(&chk ,1 ,p ,"given NULL p");
           Core路Guard路fg.check(&chk ,1 ,flag ,"flag is NULL, so nowhere to write result");
       }
 
       Local Core路Status Core路round_down(AU *p ,extent路AU alignment ,AU **result){
-        #ifdef Core路Debug
+        #ifdef Core路DEBUG
           Core路Guard路init_count(chk);
           Core路Guard路fg.check(&chk ,1 ,p ,"given NULL p to round");
           Core路Guard路fg.check(&chk ,1 ,result ,"result is NULL, so nowhere to write result");
       }
 
       Local Core路Status Core路round_up(AU *p ,extent路AU alignment ,AU **result){
-        #ifdef Core路Debug
+        #ifdef Core路DEBUG
           Core路Guard路init_count(chk);
           Core路Guard路fg.check(&chk ,1 ,p ,"given NULL p to round");
           Core路Guard路fg.check(&chk ,1 ,result ,"result is NULL, so nowhere to write result");
       }
 
       Local Core路F Core路f = {
-        .on_track = Core路on_track
-        ,.derailed = Core路derailed
-        ,.is_aligned = Core路is_aligned
-        ,.round_down = round_down
-        ,.round_up = round_up
+          .on_track = Core路on_track
+          ,.derailed = Core路derailed
+          ,.is_aligned = Core路is_aligned
+          ,.round_down = Core路round_down  // Add `Core`
+          ,.round_up = Core路round_up      // Add `Core`
       };
 
-    #endif // #ifndef CVT
-
-    #ifdef CVT
-
-      // Struct instance initialization
-      螢(Core路F ,CVT) 螢(Core路F ,CVT)路f = {
-      };
-
-    #endif
-
-  //----------------------------------------
-  // TM_NX implementation
-  //----------------------------------------
-
-  /*
-  TM_NX are initialized with calls to 'mount_pe' or 'mount_pp'.  These both bind the machine to a tape, and mount the tape. Hence, there is no such thing as an initialized which is not bound to a tape. (It is possible to dismount the tm->hd, then remount tm->hd, but the tape remains bound through that process.)
-
-  Because the TM_NX has no destructive operations, Once it is initialized the tape will never get shorter. With TM_MX it is not possible to mount an empty tape, because the minimum value of extent路AU is zero. Therefore the tape can never be empty.
-
-  For an initialized TM_NX, TM_NX.array.hd == NULL means the tape is currently not mounted.
-
-  C has no means of binding an operation to allocation apart from the initializer syntax, but the user might not initialize a tape machine after allocating one. There is no deterministic method available to a TM_NX to detect if a machine is uninitialized. However, if it happens that TM_NX.array.position == NULL, the only explanations are 1) a bug  2) the machine was not initialized - and the initialized data in TM_NX.array.position happened to be zero. 
-
-  It is an error to re-initialize the machine while it is being used, unfortunately this is a contract with the user, because the TM_NX has no way to detect if the machine was initialized in the first place. 
-
-  */
-
-  #ifndef CVT
-    struct{
-      AU *position;
-      extent路AU extent路AU;
-      AU *hd;
-    }Core路TM_NX;
-  #endif
-
-  #ifdef CVT
-    struct{
-      CVT *position;
-      extent路AU extent路AU;
-      CVT *hd;
-    }螢(Core路TM_NX ,CVT);
-  #endif
-
-  //----------------------------------------
-  // TM_NX implementation
-  //----------------------------------------
-
-    //-----------------------------------
-    // common error messages
-
-    const char *螢(Core路TM_NX ,CVT)路Msg路tm="given NULL tm";
-    const char *螢(Core路TM_NX ,CVT)路Msg路flag="given NULL flag pointer";
-    const char *螢(Core路TM_NX ,CVT)路Msg路address=
-      "given NULL address pointer ,or address struct holds NULL address";
-    const char *螢(Core路TM_NX ,CVT)路Msg路address_on_tape=
-      "given address is not on the tape";
-    const char *螢(Core路TM_NX ,CVT)路Msg路extent路AU="given NULL extent路AU pointer";
-    const char *螢(Core路TM_NX ,CVT)路Msg路position=
-      "Null position.This is only possible when the tape machine has not been initialized.";
-
-    #ifndef CVT
-      Core路Status Core路TM_NX路topo(Core路TM_NX *tm ,Core路Tape路Topo *topo){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,topo ,"topo ptr is NULL, so nowhere to put result");
-          Core路Guard路if_return(chk);
-        #endif
-        if(tm->extent路AU == 0){
-          *topo = Core路Tape路Topo路singleton; 
-        }else{
-          *topo = Core路Tape路Topo路segment;
-        }
-        return Core路Status路on_track;
-      }
-
-      // extent路AU is an AU index
-      Local Core路Status Core路TM_NX路extent路AU(Core路TM_NX *tm ,extent路AU *extent路AU){
-        Core路Tape路Topo topo;
-        Core路Status status = Core路TM_NX_##CVT路topo(tm ,&topo);
-        boolean good_topo = 
-          (status == Core路Status路on_track) && (topo & Core路Tape路Topo路finite_nz)
-          ;
-
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,extent路AU ,Core路TM_NX路Msg路extent路AU);
-          Core路Guard路fg.check(
-            &chk ,0 ,good_topo
-            ,"Tape does not exist or topology does not have an extent路AU."
-          );
-          Core路Guard路if_return(chk);
-        #endif
-
-        if(!good_topo) return Core路Status路derailed;
-        *extent路AU = tm->array.extent路AU;
-        return Core路Status路on_track;
-      }
-
-    #endif
-
-    #ifdef CVT
-
-      //-----------------------------------
-      // Area functions within Core路TM_NX_##CVT
-
-      Core路Status Core路TM_NX_##CVT路topo(Core路TM_NX *tm ,Core路Tape路Topo *topo){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,topo ,"topo ptr is NULL, so nowhere to put result");
-          Core路Guard路if_return(chk);
-        #endif
-          if(tm->extent路AU == 0){
-            *topo = Core路Tape路Topo路singleton; 
-          }else{
-            *topo = Core路Tape路Topo路segment;
-          }
-          return Core路Status路on_track;
-      }
-
-
-      Local Core路Status Core路TM_NX_##CVT路mount_pe(
-        Core路TM_NX *tm ,void *position ,extent路AU extent路AU
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,position ,"given NULL position");
-          Core路Guard路if_return(chk);
-        #endif
-        tm->array.position = position->array.address;
-        tm->array.extent路AU = extent路AU;
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路mount_pp(
-        Core路TM_NX *tm ,void *position_left ,void *position_right
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          bool good_address = position_left && position_left->address;
-          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
-          good_address = position_right && position_right->address;
-          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
-          if(position_left && position_right){
-            Core路Guard路fg.check(
-              &chk ,1 ,position_right->array.address >= position_left->array.address
-              ,"position_right < position_left"
-            );
-          }
-          Core路Guard路if_return(chk);
-        #endif
-
-        extent路AU computed_extent路AU = 
-            (extent路AU)(
-              (uintptr_t)position_right->array.address - (uintptr_t)position_left->array.address
-            );
-
-        return Core路TM_NX_##CVT路mount_pe(tm ,position_left ,computed_extent路AU);
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路largest_aligned_64(
-        Core路TM_NX *outer ,Core路TM_NX *inner_64
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,outer ,"given NULL outer TM");
-          if(outer){
-            Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"NULL outer->array.position");
-          }
-          Core路Guard路fg.check(&chk ,1 ,inner_64 ,"given NULL inner TM");
-          Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"outer TM has NULL position");
-          Core路Guard路if_return(chk);
-        #endif
-
-        uintptr_t p0 = (uintptr_t)outer->array.position;
-        uintptr_t p1 = (uintptr_t)outer->array.position + outer->array.extent路AU;
-
-        CVT *p0_64 = (CVT *)( (p0 + 0x7) & ~(uintptr_t)0x7 );
-        CVT *p1_64 = (CVT *)( (p1 - 0x7) & ~(uintptr_t)0x7 );
-
-        if(p1_64 < p0_64){
-          inner_64->array.position = NULL;
-          inner_64->array.extent路AU = 0;
-          return Core路Status路derailed;
-        }
-
-        inner_64->array.position = p0_64;
-        inner_64->array.extent路AU = (extent路AU)(p1_64 - p0_64);
-        return Core路Status路on_track;
-      }
-
-
-      Local Core路Status Core路TM_NX_##CVT路encloses_pt(
-        Core路TM_NX *tm ,void *a ,bool *result
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          bool good_address = a && a->address;
-          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
-          Core路Guard路fg.check(&chk ,1 ,result ,"given NULL result pointer");
-          Core路Guard路if_return(chk);
-        #endif
-
-        *result = 
-             (a->array.address >= tm->array.position) 
-          && (a->array.address <= tm->array.position + tm->array.extent路AU);
-
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路encloses_pt_strictly(
-        Core路TM_NX *tm ,void *a ,bool *result
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          bool good_address = a && a->address;
-          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
-          Core路Guard路fg.check(&chk ,1 ,result ,"given NULL result pointer");
-          Core路Guard路if_return(chk);
-        #endif
-
-        *result = 
-             (a->array.address > tm->array.position) 
-          && (a->array.address < tm->array.position + tm->array.extent路AU);
-
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路encloses_tm(
-        Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,outer ,"given NULL outer TM");
-          if(outer){
-            Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"NULL outer->array.position");
-          }
-          Core路Guard路fg.check(&chk ,1 ,inner ,"given NULL inner TM");
-          if(inner){
-            Core路Guard路fg.check(&chk ,1 ,inner->array.position ,"NULL inner->array.position");
-          }
-          Core路Guard路fg.check(&chk ,1 ,flag ,"given NULL flag pointer");
-          Core路Guard路if_return(chk);
-        #endif
-
-        *flag =
-             (inner->array.position >= outer->array.position) 
-          && (inner->array.position + inner->array.extent路AU <= outer->array.position + outer->array.extent路AU);
-
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路encloses_tm_strictly(
-        Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,outer ,"given NULL outer TM");
-          if(outer){
-            Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"NULL outer->array.position");
-          }
-          Core路Guard路fg.check(&chk ,1 ,inner ,"given NULL inner TM");
-          if(inner){
-            Core路Guard路fg.check(&chk ,1 ,inner->array.position ,"NULL inner->array.position");
-          }
-          Core路Guard路fg.check(&chk ,1 ,flag ,"given NULL flag pointer");
-          Core路Guard路if_return(chk);
-        #endif
-
-        *flag =
-             (inner->array.position > outer->array.position) 
-          && (inner->array.position + inner->array.extent路AU < outer->array.position + outer->array.extent路AU);
-
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路overlap(
-        Core路TM_NX *a ,Core路TM_NX *b ,bool *result
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,a ,"given NULL TM A");
-          if(a){
-            Core路Guard路fg.check(&chk ,1 ,a->array.position ,"NULL a->array.position");
-          }
-          Core路Guard路fg.check(&chk ,1 ,b ,"given NULL TM B");
-          if(b){
-            Core路Guard路fg.check(&chk ,1 ,b->array.position ,"NULL b->array.position");
-          }
-          Core路Guard路fg.check(&chk ,1 ,result ,"given NULL result pointer");
-          Core路Guard路if_return(chk);
-        #endif
-
-        *result =
-             (a->array.position < b->array.position + b->array.extent路AU) 
-          && (b->array.position < a->array.position + a->array.extent路AU);
-
-        return Core路Status路on_track;
-      }
-
-
-      //-----------------------------------
-      // base Tape Machine operations
-
-      Local Core路Status Core路TM_NX_##CVT路mount(Core路TM_NX *tm){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,tm->array.position ,Core路TM_NX_##CVT路Msg路position);
-          Core路Guard路if_return(chk);
-        #endif
-
-        tm->array.hd = tm->array.position;
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路dismount(Core路TM_NX *tm){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路if_return(chk);
-        #endif
-
-        // Reset head position upon dismount
-        tm->array.hd = NULL;
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路status(
-        Core路TM_NX *tm ,Core路TM路Head路Status *status
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,status ,"given NULL status pointer");
-          Core路Guard路if_return(chk);
-        #endif
-
-        if(tm->array.hd == NULL){
-          *status = Core路TM路Head路Status路not_on_tape;
-        }else if(tm->array.hd == tm->array.position){
-          *status = Core路TM路Head路Status路origin;
-        }else if(tm->array.hd == tm->array.position + tm->array.extent路AU){
-          *status = Core路TM路Head路Status路rightmost;
-        }else{
-          *status = Core路TM路Head路Status路interim;
-        }
-
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路can_read(Core路TM_NX *tm ,bool *flag){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          if(tm){
-            // All initialized TM_NX_##CVT have an initialized position
-            // Maybe this catches that the machine is uninitialized?
-            Core路Guard路fg.check(&chk ,1 ,tm->array.position ,Core路TM_NX_##CVT路Msg路position);
-          }      
-          Core路Guard路fg.check(&chk ,1 ,flag ,Core路TM_NX_##CVT路Msg路flag);
-          Core路Guard路if_return(chk);
-        #endif
-        *flag = tm && tm->array.hd != NULL;
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路on_origin(
-        Core路TM_NX *tm ,bool *flag
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,tm && tm->array.position ,Core路TM_NX_##CVT路Msg路position);
-          Core路Guard路fg.check(&chk ,1 ,flag ,Core路TM_NX_##CVT路Msg路flag);
-          Core路Guard路if_return(chk);
-        #endif
-
-        *flag = (tm->array.hd == tm->array.position);
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路on_rightmost(
-        Core路TM_NX *tm ,bool *flag
-      ){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,flag ,Core路TM_NX_##CVT路Msg路flag);
-          Core路Guard路fg.check(&chk ,1 ,tm && tm->array.position ,Core路TM_NX_##CVT路Msg路position);
-          Core路Guard路if_return(chk);
-        #endif
-
-        *flag = tm->array.hd == (tm->array.position + tm->array.extent路AU);
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路copy_datum(Core路TM_NX *tm_read ,Core路TM_NX *tm_write){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm_read ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,tm_write ,Core路TM_NX_##CVT路Msg路tm);
-          if(tm_read && tm_write){
-            Core路Guard路fg.check(
-              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm_read ,tm_read->array.hd) 
-              ,"Source address is outside tape bounds"
-            );
-            Core路Guard路fg.check(
-              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm_write ,tm_write->array.hd) 
-              ,"Destination address is outside tape bounds"
-            );
-          }
-          Core路Guard路if_return(chk);
-        #endif
-
-        *(tm_write->array.hd) = *(tm_read->array.hd);
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路read(Core路TM_NX *tm ,void *read_pt){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          if(tm) Core路Guard路fg.check(&chk ,1 ,tm->array.hd ,Core路TM_NX_##CVT路Msg路address);
-          if(tm && tm->array.hd){
-            Core路Guard路fg.check(
-              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm ,tm->array.hd) 
-              ,"Given address is outside tape bounds"
-            );
-          }
-          Core路Guard路if_return(chk);
-        #endif
-
-        *(CVT *)read_pt = *(tm_array.hd);
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路write(Core路TM_NX *tm ,void *write_pt){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          if(tm) Core路Guard路fg.check(&chk ,1 ,tm->array.hd ,Core路TM_NX_##CVT路Msg路address);
-          if(tm && tm->array.hd){
-            Core路Guard路fg.check(
-              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm ,tm->array.hd) 
-              ,"Given address is outside tape bounds"
-            );
-          }
-          Core路Guard路if_return(chk);
-        #endif
-
-        *(tm->array.hd) = *(CVT *)write_pt;
-        return Core路Status路on_track;
-      }
-
-      Local Core路Status Core路TM_NX_##CVT路rewind(Core路TM_NX *tm){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          if(tm){
-            Core路Guard路fg.check(&chk ,1 ,tm->array.position ,Core路TM_NX_##CVT路Msg路position);
-          }
-          Core路Guard路if_return(chk);
-        #endif
-        tm->array.hd = tm->array.position;
-        return Core路Status路on_track;
-      }
-
-      Core路Status Core路TM_NX_##CVT路step(Core路TM_NX *tm){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,tm->array.position ,"step requested on unbound machine");
-          Core路Guard路fg.check(&chk ,1 ,tm->array.hd ,"step requested but tape not mounted");
-          Core路Guard路if_return(chk);
-        #endif
-        if( tm->array.hd < tm->array.position + tm->array.extent路AU ){
-          tm->array.hd++;
-          return Core路Status路on_track;
-        }
-        return Core路Status路derailed; // Stepping beyond tape bounds
-      }
-
-      Core路Status Core路TM_NX_##CVT路step_left(Core路TM_NX *tm){
-        #ifdef Core路Debug
-          Core路Guard路init_count(chk);
-          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
-          Core路Guard路fg.check(&chk ,1 ,tm->array.position 
-            ,"step_left requested on unbound machine"
-          );
-          Core路Guard路fg.check(&chk ,1 ,tm->array.hd 
-            ,"step_left requested with no mounted head"
-          );
-          Core路Guard路if_return(chk);
-        #endif
-        if( tm->array.hd > tm->array.position ){
-          tm->array.hd--;
-          return Core路Status路on_track;
-        }
-        return Core路Status路derailed; // Stepping beyond left boundary
-      }
-
-      // step_right is a synonym for step
-
-
-      //----------------------------------------
-      // Initialization for Core路TM_NX_##CVT路fg
-
-      Local Core路TM_NX路FG Core路TM_NX_##CVT路fg = {
-         .mount = Core路TM_NX_##CVT路mount
-        ,.dismount = Core路TM_NX_##CVT路dismount
-
-        ,.status = Core路TM_NX_##CVT路status
-        ,.can_read = Core路TM_NX_##CVT路can_read
-        ,.on_origin = Core路TM_NX_##CVT路on_origin
-        ,.on_rightmost = Core路TM_NX_##CVT路on_rightmost
-
-        ,.read = Core路TM_NX_##CVT路read
-        ,.write = Core路TM_NX_##CVT路write
-
-        ,.rewind = Core路TM_NX_##CVT路rewind
-        ,.step = Core路TM_NX_##CVT路step
-        ,.step_left = Core路TM_NX_##CVT路step_left
-        ,.step_right = Core路TM_NX_##CVT路step_right // Synonym for step
-
-        ,.area = {
-           .topo = Core路TM_NX_##CVT路topo
-          ,.extent路AU = Core路TM_NX_##CVT路extent路AU
-
-          ,.mount_pe = Core路TM_NX_##CVT路mount_pe
-          ,.mount_pp = Core路TM_NX_##CVT路mount_pp
-          ,.largest_aligned_64 = Core路TM_NX_##CVT路largest_aligned_64
-
-          ,.encloses_pt = Core路TM_NX_##CVT路encloses_pt
-          ,.encloses_pt_strictly = Core路TM_NX_##CVT路encloses_pt_strictly
-          ,.encloses_tm = Core路TM_NX_##CVT路encloses_tm
-          ,.encloses_tm_strictly = Core路TM_NX_##CVT路encloses_tm_strictly
-          ,.overlap = Core路TM_NX_##CVT路overlap
-        }
-      };
-
-    #endif
-
-    //----------------------------------------
-    // Map implementation
-    //----------------------------------------
-
-
-Core路Map路Completion Core路map(TM_MX *tm_read ,TM_MX *tm_write ,Core路Map路Fn fn){
-
-  Core路Guard路init_collect(chk);
-  if(!fn) chk.flag |= Core路Map路Completion路null_fn;
-  bool tm_read_can_read=false ,tm_write_can_read=false;
-  Core路TM路Head路Status tm_read_status ,tm_write_status;
-  if(
-    tm_read->can_read(tm_read ,&tm_read_can_read) == Core路Status路derailed
-    || tm_write->can_read(tm_write ,&tm_write_can_read) == Core路Status路derailed
-    || !tm_read_can_read
-    || !tm_write_can_read
-  ){
-    chk.flag |= Core路Map路Completion路no_tape_access;
-  }
-  Core路Guard路return(chk);
-
-  do{
-    TM_MX路Remote d_remote;
-    if( tm_read->read(tm_read ,&d_addr ,&d_remote) != Core路Status路on_track ){
-      chk.flag |= Core路Map路Completion路failed;
-      break;
-    }
-
-    TM_MX路Remote r_remote;
-    if(map->fn(&d_remote ,&r_remote) != Core路Status路on_track){
-      chk.flag |= Core路Map路Completion路not_computable;
-      break;
-    }
-
-    Core路TM_NX路Address r_addr;
-    if( tm_write->write(tm_write ,&r_addr ,&r_remote) != Core路Status路on_track ){
-      chk.flag |= Core路Map路Completion路failed;
-      break;
-    }
-
-    if(
-      tm_read->step(tm_read) != Core路Status路on_track
-      || tm_write->step(tm_write) != Core路Status路on_track
-    ){
-      chk.flag |= Core路Map路Completion路failed;
-      break;
-    }
-
-    tm_read->status(tm_read ,&tm_read_status);
-    tm_write->status(tm_write ,&tm_write_status);
-
-    if(
-      tm_read_status & Core路TM路Head路Status路rightmost
-      && tm_write_status & Core路TM路Head路Status路rightmost
-    ){
-      chk.flag |= Core路Map路Completion路perfect_fit;
-      break;
-    }
-
-    if(tm_read_status & Core路TM路Head路Status路rightmost){
-      chk.flag |= Core路Map路Completion路read_surplus;
-      break;
-    }
-
-    if(tm_write_status & Core路TM路Head路Status路rightmost){
-      chk.flag |= Core路Map路Completion路write_available;
-      break;
-    }
-
-  }while(true);
-
-  Core路Guard路return(chk);
-}
-
-
-    // Map function using trampoline execution model
-    Local Core路Map路Status Core路map(Core路Map路Fn fn){
-      #ifdef Core路Debug
-      if(!fn){
-        fprintf(stderr,"Core路map:: given null function");
-        return Core路Map路argument_guard;
-      }
-      if(
-         true
-         && fn != Core路Map路by_##CVT
-         && fn != Core路Map路##CVT_by_##CVT
-         && fn != Core路write_hex
-         && fn != Core路read_hex
-      ){
-        fprintf(stderr,"Core路map:: unrecognized copy function\n");
-        return Core路Map路argument_guard;
-      ) 
-      #endif
-
-      while(fn) fn = fn();
-      return tf.copy.status;
-    }
-
-
-
-    //----------------------------------------
-    // copy byte_by_byte 
-    //----------------------------------------
-
-    Core路Map路Fn Core路Map路Map路ByteByByte路perfect_fit;
-    Core路Map路Fn Core路Map路Map路ByteByByte路read_surplus;
-    Core路Map路Fn Core路Map路Map路ByteByByte路write_available;
-
-    Local Core路Map路Fn Core路Map路##CVT_by_##CVT(){
-      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) == Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write))
-        return Core路Map路ByteByByte路perfect_fit;
-
-      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) > Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write))
-        return Core路Map路ByteByByte路read_surplus;
-
-      return Core路Map路ByteByByte路write_available;
-    }
-
-    Local Core路Map路Fn Core路Map路ByteByByte路perfect_fit(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do{
-        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,*r);
-        if(*r == r1) break;
-        (*r)++;
-        (*w)++;
-      }while(true);
-
-      Core路tf.copy.status = Core路Map路Status路perfect_fit;
-      return NULL;
-    }
-
-    Local Core路Map路Fn Core路Map路ByteByByte路read_surplus(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
-
-      do{
-        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,*r);
-        if(*w == w1) break;
-        (*r)++;
-        (*w)++;
-      }while(true);
-
-      Core路tf.copy.status = Core路Map路Status路write_available;
-      return NULL;
-    }
-
-    Local Core路Map路Fn Core路Map路ByteByByte路write_avalable(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do{
-        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,*r);
-        if(*r == r1) break;
-        (*r)++;
-        (*w)++;
-      }while(true);
-
-      Core路tf.copy.status = Core路Map路Status路read_surplus;
-      return NULL;
-    }
-
-    //----------------------------------------
-    // copy copy_64
-
-    // 64-bit copy function with updated TableauFace terminology
-    Core路Map路Fn Core路Map路by_##CVT;
-    Core路Map路Fn Core路Map路ByWord64路leadin;
-    Core路Map路Fn Core路Map路ByWord64路bulk;
-    Core路Map路Fn Core路Map路ByWord64路tail;
-
-    // Initialize the copy_64 process
-    Local Core路Map路Fn Core路Map路by_##CVT(){
-      // Determine the largest 64-bit aligned region within the read area
-      Core路TM_NX_##CVT路largest_aligned_64(Core路tf.copy.read ,&Core路tl.copy_64.area_64);
-
-      // Choose the correct function based on alignment
-      if(Core路TM_NX_##CVT路empty(&Core路tl.copy_64.area_64)) return Core路Map路ByWord64路tail;
-      if(Core路is_aligned_on_64(Core路TM_NX_##CVT路position(Core路tf.copy.read))) return Core路Map路ByWord64路bulk;
-      return Core路Map路ByWord64路leadin;
-    }
-
-    // Lead-in byte copy (until alignment)
-    Local Core路Map路Fn Core路Map路ByWord64路leadin(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r0_64 = Core路TM_NX_##CVT路position(&Core路tl.copy_64.area_64);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do{
-        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,r0_64 ,*r);
-        if(*r == r0_64) break;
-        (*r)++;
-        (*w)++;
-      }while(true);
-
-      return Core路Map路ByWord64路bulk;
-    }
-
-    // Bulk word copy
-    Local Core路Map路Fn Core路Map路ByWord64路bulk(){
-      uint64_t **r = (uint64_t **)&Core路tf.copy.read_pt;
-      uint64_t **w = (uint64_t **)&Core路tf.copy.write_pt;
-      uint64_t *r1_64 = Core路TM_NX_##CVT路position_right(&Core路tl.copy_64.area_64);
-
-      do{
-        **w = Core路tf.copy.read_fn_64(Core路tf.copy.read ,r1_64 ,*r);
-        if(*r == r1_64) break;
-        (*r)++;
-        (*w)++;
-      }while(true);
-
-      return Core路Map路ByWord64路tail;
-    }
-
-    // Tail byte copy (unaligned trailing bytes)
-    Local Core路Map路Fn Core路Map路ByWord64路tail(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(&Core路tl.copy_64.area_64);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do{
-        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,r1 ,*r);
-        if(*r == r1) break;
-        (*r)++;
-        (*w)++;
-      }while(true);
-
-      Core路tf.copy.status = Core路Map路Status路perfect_fit;
-      return NULL;
-    }
-
-    //----------------------------------------
-    // copy write hex
-
-    Local uint16_t Core路byte_to_hex(CVT byte){
-      static const char hex_digits[] = "0123456789ABCDEF";
-      return 
-          (hex_digits[byte >> 4] << 8) 
-        | hex_digits[byte & 0x0F];
-    }
-
-    // Forward Declarations
-    Core路Map路Fn Core路Map路write_hex;
-    Core路Map路Fn Core路Map路WriteHex路perfect_fit;
-    Core路Map路Fn Core路Map路WriteHex路read_surplus;
-    Core路Map路Fn Core路Map路WriteHex路write_available;
-
-    // Hex Encoding: Initialize Map
-    Local Core路Map路Fn Core路Map路write_hex(){
-      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) == (Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write) >> 1)){
-        return Core路Map路WriteHex路perfect_fit;
-      }
-      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) > (Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write) >> 1)){
-        return Core路Map路WriteHex路read_surplus;
-      }
-      return Core路Map路WriteHex路write_available;
-    }
-
-    Local Core路Map路Fn Core路Map路WriteHex路perfect_fit(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do {
-        *(uint16_t *)*w = Core路hex.byte_to_hex(**r);
-        if(*r == r1) break;
-        (*r)++;
-        (*w) += 2;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路perfect_fit;
-      return NULL;
-    }
-
-    // Hex Encoding: Read Surplus
-    Local Core路Map路Fn Core路Map路WriteHex路read_surplus(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do {
-        *(uint16_t *)*w = Core路write_hex.byte_to_hex(**r);
-        if(*r == r1) break;
-        (*r)++;
-        (*w) += 2;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路read_surplus;
-      return NULL;
-    }
-
-    // Hex Encoding: Write Available
-    Local Core路Map路Fn Core路Map路WriteHex路write_available(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
-
-      do {
-        *(uint16_t *)*w = Core路write_hex.byte_to_hex(**r);
-        if(*w == w1) break;
-        (*r)++;
-        (*w) += 2;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路write_available;
-      return NULL;
-    }
-
-    //----------------------------------------
-    // copy read hex
-
-    Local CVT Core路hex_to_byte(uint16_t hex){
-      CVT high = hex >> 8;
-      CVT low = hex & 0xFF;
-
-      high = 
-          (high >= '0' && high <= '9') ? (high - '0')
-        : (high >= 'A' && high <= 'F') ? (high - 'A' + 10)
-        : (high >= 'a' && high <= 'f') ? (high - 'a' + 10)
-        : 0;
-
-      low = 
-          (low >= '0' && low <= '9') ? (low - '0')
-        : (low >= 'A' && low <= 'F') ? (low - 'A' + 10)
-        : (low >= 'a' && low <= 'f') ? (low - 'a' + 10)
-        : 0;
-
-      return (high << 4) | low;
-    }
-
-    Core路Map路Fn Core路Map路read_hex;
-    Core路Map路Fn Core路Map路ReadHex路perfect_fit;
-    Core路Map路Fn Core路Map路ReadHex路read_surplus;
-    Core路Map路Fn Core路Map路ReadHex路write_available;
-
-    Local Core路Map路Fn Core路Map路read_hex(){
-      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) == Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
-        return Core路Map路ReadHex路perfect_fit;
-      }
-      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) > Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
-        return Core路Map路ReadHex路read_surplus;
-      }
-      return Core路Map路ReadHex路write_available;
-    }
-
-    Local Core路Map路Fn Core路Map路ReadHex路perfect_fit(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do {
-        **w = Core路hex_to_byte(*(uint16_t *)*r);
-        if(*r == r1) break;
-        (*r) += 2;
-        (*w)++;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路perfect_fit;
-      return NULL;
-    }
-
-    Local Core路Map路Fn Core路Map路ReadHex路read_surplus(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do {
-        **w = Core路tf.read_hex.hex_to_byte(*(uint16_t *)*r);
-        if(*r == r1) break;
-        (*r) += 2;
-        (*w)++;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路read_surplus;
-      return NULL;
-    }
-
-    Local Core路Map路Fn Core路Map路ReadHex路write_available(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
-
-      do {
-        **w = Core路tf.read_hex.hex_to_byte(*(uint16_t *)*r);
-        if(*w == w1) break;
-        (*r) += 2;
-        (*w)++;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路write_available;
-      return NULL;
-    }
-
-    //----------------------------------------
-    // copy read hex
-
-    Core路Map路Fn Core路Map路read_hex;
-    Core路Map路Fn Core路Map路ReadHex路perfect_fit;
-    Core路Map路Fn Core路Map路ReadHex路read_surplus;
-    Core路Map路Fn Core路Map路ReadHex路write_available;
-
-    Local Core路Map路Fn Core路Map路read_hex(){
-      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) == Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
-        return Core路Map路ReadHex路perfect_fit;
-      }
-      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) > Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
-        return Core路Map路ReadHex路read_surplus;
-      }
-      return Core路Map路ReadHex路write_available;
-    }
-
-    Local Core路Map路Fn Core路Map路ReadHex路perfect_fit(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do {
-        **w = Core路hex_to_byte(*(uint16_t *)*r);
-        if(*r == r1) break;
-        (*r) += 2;
-        (*w)++;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路perfect_fit;
-      return NULL;
-    }
-
-    Local Core路Map路Fn Core路Map路ReadHex路read_surplus(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
-      CVT **w = &Core路tf.copy.write_pt;
-
-      do {
-        **w = Core路hex_to_byte(*(uint16_t *)*r);
-        if(*r == r1) break;
-        (*r) += 2;
-        (*w)++;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路read_surplus;
-      return NULL;
-    }
-
-    Local Core路Map路Fn Core路Map路ReadHex路write_available(){
-      CVT **r = &Core路tf.copy.read_pt;
-      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
-      CVT **w = &Core路tf.copy.write_pt;
-      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
-
-      do {
-        **w = Core路hex_to_byte(*(uint16_t *)*r);
-        if(*w == w1) break;
-        (*r) += 2;
-        (*w)++;
-      } while(true);
-
-      Core路tf.copy.status = Core路Map路Status路write_available;
-      return NULL;
-    }
-
-
-
   #endif // LOCAL
 
 #endif // IMPLEMENTATION
diff --git a/developer/cc馃枆/Map.lib.c b/developer/cc馃枆/Map.lib.c
new file mode 100644 (file)
index 0000000..26297b8
--- /dev/null
@@ -0,0 +1,1486 @@
+ /*
+  Core - core memory operations.
+
+  This file has the template parameter: `CVT`
+
+  `CVT` Cell Value Type`. It is the type of the datum placed in a cell. By default (when the   macro CVT has no definition) the cell value type is taken as AUM. This file must
+  be included with CVT undefined, before inclusions with it defined.
+  `AU` `Addressable Unit for the machine`, on most all machines today this is uint8_t,
+  though the C standard has never required this.
+
+  'ATP' `At This Point' in the code. Acronym used in comments usually before pointing
+  out certain values variables must have.
+
+  'AToW' - At Time of Writing, also used in comments.
+
+  'Tape' is operated on by the Tape Machine.
+
+  'Area' is subset of an address space that is used as a virtual Tape by a machine.
+
+   An Area with zero elements has 'length == 0' or is 'empty'. In contrast, and
+   area located (position specified) with a null pointer is said not to exist.
+
+   When all the functions that have a specific type of operand given are group together
+   in a table, we call the table a 'Function Given Type X', table. In general we call
+   these FG (Function Given) tables. A specific instance of an FG table is an `fg` table.
+
+*/
+
+#define Core路DEBUG
+
+#ifndef FACE
+#define Core路IMPLEMENTATION
+#define FAC
+#endif 
+
+//--------------------------------------------------------------------------------
+// Interface
+
+#ifndef Core路FACE
+#define Core路FACE
+
+  #include <stdint.h>
+  #include <stddef.h>
+
+  //----------------------------------------
+  // memory interface
+  //----------------------------------------
+
+  #ifndef CVT  
+
+    // Expand namespace with a macro parameter given value.
+    // The namespace and the extended value will be evaluated for macros.
+    // Greek capital letter 'Xi' for eXtend.
+    #define _螢(a ,b) a##路##b
+    #define 螢(a ,b) _螢(a ,b)
+
+    // ask the machine what this is
+    // C language standard left this undefined, probably why unicode uses 'octet'
+    // AToW industry uses uint8_t
+    // reminds me of FORTRAN star types
+    #define AU uint8_t
+    #define AU2 uint16_t
+    #define UA4 uint32_t
+    #define UA8 uint64_t
+
+    #define AU_MAX ~(AU)0
+    #define AU2_MAX ~(AU2)0
+    #define UA4_MAX ~(AU4)0
+    #define UA8_MAX ~(AU8)0
+
+    // ask the compiler what this is
+    // when using enums we get this whether we want it or not
+    #define WU unsigned int
+    #define WU ~(WU)0
+
+    // extent is an address or an index.  It is not a length.
+    // The index scaling CVT type is appended to the end of the extent related identifiers..
+    // E.g. exent_of路AU(uint64_t) == 7 while exent_of路uint16_t(uint64_t) == 3;
+    // exent_of路AU of the address space is ~(uintptr)0;
+    #define extent_of路AU(x)(sizeof(x) - 1)
+    #define extent_t路AU size_t
+
+    // Funny, we seldom check for this, but maybe someone is running a microcontroller or something, so we will here. Also, too bad that address 0 can't be used.
+    #define extent_address_space路AU ~(uintptr)0;
+
+    typedef enum{
+       Core路Status路mu = 0
+      ,Core路Status路on_track
+      ,Core路Status路derailed
+    }Core路Status;
+
+  #endif
+
+  #ifdef CVT
+    #define 螢(extent_t ,CVT) size_t
+  #endif
+
+  //----------------------------------------
+  // argument guard interface
+  //----------------------------------------
+
+  #ifndef CVT  
+
+    typedef void (*Core路Flag路Fn)(WU *flag ,WU err);
+
+    void Core路Flag路count(WU *flag ,WU err){
+      if(err == WU_MAX){ *flag = WU_MAX; return;}
+
+      //*flag + err > WU_MAX
+      if(*flag > WU_MAX - err){ *flag = WU_MAX; return;}
+
+      (*flag) += err;
+    }
+
+    void Core路Flag路collect(WU *flag ,WU err){
+      (*flag) |= err;
+    }
+
+    typedef struct {
+      char *name;
+      Core路Flag路Fn flag_function;
+      WU flag;
+    } Core路Guard;
+
+    typedef struct {
+      void (*init)(Core路Guard *chk ,const char *name ,Core路Flag路Fn af);
+      void (*reset)(Core路Guard *chk);
+      void (*check)(
+         Core路Guard *chk
+        ,WU err
+        ,bool condition
+        ,char *message
+      );
+    } Core路Guard路FG;
+
+    // Default guard function table
+    // initialized in the implementation section below
+    Local Core路Guard路FG Core路Guard路fg;
+
+    #define Core路Guard路init_count(chk) \
+      Core路Guard chk; \
+      Core路Guard路fg.init(&chk ,__func__ ,Core路Flag路count);
+
+    #define Core路Guard路init_collect(chk) \
+      Core路Guard chk; \
+      Core路Guard路fg.init(&chk ,__func__ ,Core路Flag路collect);
+
+    #define Core路Guard路if_return(chk) if( chk.flag ) return Core路Status路derailed;
+    #define Core路Guard路return(chk)\
+      if( chk.flag ) return Core路Status路derailed;\
+      else return Core路Status路on_track;
+
+  #endif 
+
+  //----------------------------------------
+  // functions interface
+  //----------------------------------------
+  
+  // no state, this is merely a namespace
+
+  #ifndef CVT
+    typedef struct{
+      Core路Status (*on_track)();
+      Core路Status (*derailed)();
+      Core路Status (*is_aligned)(AU *p ,extent路AU alignment ,bool *flag);
+      Core路Status (*round_down)(AU *p ,extent路AU alignment ,AU **result);
+      Core路Status (*round_up)(AU *p ,extent路AU alignment ,AU **result);
+    } Core路F;
+    Local Core路F Core路f;
+  #endif 
+
+  #ifdef CVT
+    typedef struct{
+      // nothing here right now
+    } 螢(Core路F ,CVT);
+    Local 螢(Core路F ,CVT) 螢(Core路F ,CVT)路f;
+  #endif
+
+  //----------------------------------------
+  // Tape Machine interface
+  //----------------------------------------
+
+  #ifndef CVT
+
+    typedef struct Core路TM_NX;
+
+    /*
+      For an CVT machine tape, a mounted tape will be singleton or segment.
+    */
+    typedef enum{
+       Core路Tape路Topo路mu = 0 
+      ,Core路Tape路Topo路nonexistent = 1 
+      ,Core路Tape路Topo路empty       = 1 << 1
+      ,Core路Tape路Topo路singleton   = 1 << 2
+      ,Core路Tape路Topo路segment     = 1 << 3
+      ,Core路Tape路Topo路circle      = 1 << 4
+      ,Core路Tape路Topo路tail_cyclic = 1 << 5
+      ,Core路Tape路Topo路infinite    = 1 << 6
+    }Core路Tape路Topo;
+
+    const Core路Tape路Topo Core路Tape路Topo路finite_nz = 
+      Core路Tape路Topo路singleton | Core路Tape路Topo路segment
+      ;
+
+    // If tape machine does not support step left, then Status路leftmost 
+    // will be reported as Status路interim.
+    typedef enum{
+       Core路TM路Head路Status路mu = 0
+      ,Core路TM路Head路Status路not_on_tape = 1
+      ,Core路TM路Head路Status路origin    = 1 << 1
+      ,Core路TM路Head路Status路interim   = 1 << 2
+      ,Core路TM路Head路Status路rightmost = 1 << 3
+    } Core路TM路Head路Status;
+
+    const Core路TM路Head路Status Core路TM路Head路Status路on_tape = 
+      Core路TM路Head路Status路origin
+      | Core路TM路Head路Status路interim
+      | Core路TM路Head路Status路rightmost
+      ;
+
+    // tape and area are included with Tape Machine to facilitate abstract interfaces.
+    typedef struct{
+
+      struct {
+        Core路Status (*topo)(Core路TM_NX *tm ,Core路Tape路Topo *topo);
+        Core路Status (*extent)(Core路TM_NX *tm ,extent_t路AU *result);
+      } tape;
+
+      struct {
+        // Initialize tm
+        Core路Status (*mount_pe)(Core路TM_NX *tm ,AU position[] ,extent_t路AU extent路AU);
+        Core路Status (*mount_pp)(Core路TM_NX *tm ,AU *position_left ,AU *position_right);
+  
+        // predicates
+        Core路Status (*encloses_pt)(Core路TM_NX *tm ,AU *pt ,bool *result);
+        Core路Status (*encloses_pt_strictly)(Core路TM_NX *tm ,AU *pt ,bool *result);
+        Core路Status (*encloses_area)(Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag);
+        Core路Status (*encloses_area_strictly)(
+          Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag
+        );
+        Core路Status (*overlap)(Core路TM_NX *a ,Core路TM_NX *b ,bool *result);
+      } area;
+
+      // tape machine functions
+      Core路Status (*mount)(Core路TM_NX *tm);
+      Core路Status (*dismount)(Core路TM_NX *tm);
+
+      Core路Status (*status)(Core路TM_NX *tm ,Core路TM路Head路Status *status);
+      Core路Status (*can_read)(Core路TM_NX *tm ,bool *flag);
+      Core路Status (*on_origin)(Core路TM_NX *tm ,bool *flag);
+      Core路Status (*on_rightmost)(Core路TM_NX *tm ,bool *flag);
+
+      Core路Status (*copy_datum)(Core路TM_NX *tm_read ,Core路TM_NX *tm_write);
+      Core路Status (*read)(Core路TM_NX *tm ,AU *read_pt);
+      Core路Status (*write)(Core路TM_NX *tm ,AU *write_pt);
+      Core路Status (*head_pt)(Core路TM_NX *tm ,AU *head_pt);
+
+      Core路Status (*rewind)(Core路TM_NX *tm);
+      Core路Status (*step)(Core路TM_NX *tm);
+      Core路Status (*step_left)(Core路TM_NX *tm);
+      Core路Status (*step_right)(Core路TM_NX *tm); // Synonym for step
+
+    } Core路TM_NX路FG;
+
+    Core路TM_NX路FG Core路TM_NX路fg;
+
+  #endif // #ifndef CVT
+
+  #ifndef CVT
+    typedef struct 螢(Core路TM_NX ,CVT);
+
+    typedef struct{
+
+      struct {
+        Core路Status (*extent)(螢(Core路TM_NX ,CVT) *tm ,螢(extent_t ,CVT) *result);
+      } tape;
+
+      struct {
+
+        // Initialize tm
+        Core路Status (*mount_pe)(Core路TM_NX tm ,CVT position[] ,螢(extent_t ,CVT) extent);
+        Core路Status (*mount_pp)(Core路TM_NX *tm ,CVT *position_left ,CVT *position_right);
+
+        // initializes inner
+        Core路Status (*largest_aligned)(Core路TM_NX_uint8_t *outer ,螢(Core路TM_NX ,CVT) *inner);
+
+        Core路Status (*encloses_pt)(螢(Core路TM_NX ,CVT) *tm ,CVT *pt ,bool *result);
+        Core路Status (*encloses_pt_strictly)(螢(Core路TM_NX ,CVT) *tm ,CVT *pt ,bool *result);
+
+        Core路Status (*encloses_area)(
+          螢(Core路TM_NX ,CVT) *outer ,螢(Core路TM_NX ,CVT) *inner ,bool *flag
+        );
+        Core路Status (*encloses_area_strictly)(
+          螢(Core路TM_NX ,CVT) *outer ,螢(Core路TM_NX ,CVT) *inner ,bool *flag
+        );
+        Core路Status (*overlap)(
+          螢(Core路TM_NX ,CVT) *a ,螢(Core路TM_NX ,CVT) *b ,bool *result
+        );
+      } area;
+
+      Core路Status (*copy_datum)( 螢(Core路TM_NX ,CVT) *tm_read ,螢(Core路TM_NX ,CVT) *tm_write );
+      Core路Status       (*read)( 螢(Core路TM_NX ,CVT) *tm ,CVT *remote_pt );
+      Core路Status      (*write)( 螢(Core路TM_NX ,CVT) *tm ,CVT *remote_pt );
+      Core路Status    (*head_pt)( 螢(Core路TM_NX ,CVT) *tm ,CVT *head_pt );
+
+
+    } 螢(Core路TM_NX ,CVT)路FG;
+
+    螢(Core路TM_NX ,CVT)路FG 螢(Core路TM_NX ,CVT)路fg;
+
+  #endif // #ifdef CVT
+
+  //----------------------------------------
+  // Map interface
+  //----------------------------------------
+
+  #ifndef CVT
+
+    typedef enum{
+       Core路Map路Status路mu = 0
+      ,Core路Map路Status路no_tape
+      ,Core路Map路Status路not_computable
+      ,Core路Map路Status路complete
+    } Core路Map路Status;
+
+    typedef enum{
+       Core路Map路Completion路mu = 0
+      ,Core路Map路Completion路null_fn                 = 1 
+      ,Core路Map路Completion路no_tape_access          = 1 << 1
+      ,Core路Map路Completion路failed                  = 1 << 2
+      ,Core路Map路Completion路perfect_fit             = 1 << 3
+      ,Core路Map路Completion路read_surplus            = 1 << 4
+      ,Core路Map路Completion路read_surplus_write_gap  = 1 << 5
+      ,Core路Map路Completion路write_available         = 1 << 6
+      ,Core路Map路Completion路write_gap               = 1 << 7
+    } Core路Map路Completion;
+
+    const uint Core路Map路Completion路derailed =
+        Core路Map路Completion路no_tape                
+      | Core路Map路Completion路not_computable         
+      | Core路Map路Completion路failed
+      ;
+
+    const uint Core路Map路Completion路on_track =
+        Core路Map路Completion路perfect_fit            
+      | Core路Map路Completion路read_surplus           
+      | Core路Map路Completion路read_surplus_write_gap 
+      | Core路Map路Completion路write_available        
+      | Core路Map路Completion路write_gap              
+      ;
+
+    typedef Core路Map路Fn (*Core路Map路Fn)(AU *x ,AU *fx);
+
+  #endif // #ifndef CVT
+
+  #ifdef CVT
+    typedef 螢(Core路Map ,CVT)路Fn (*Core路Map路Fn)(CVT *x ,CVT *fx);
+
+  #endif CVT
+
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+
+#ifdef Core路IMPLEMENTATION
+  // declarations available to all of the IMPLEMENTATION go here
+  //
+    #ifdef Core路DEBUG
+      #include <stdio.h>
+    #endif
+
+  // implementation to go into the lib.a file
+  //
+    #ifndef LOCAL
+    #endif 
+
+  #ifdef LOCAL
+
+    //----------------------------------------
+    // argument guard implementation
+    //----------------------------------------
+
+    #ifndef CVT
+      Local void Core路Guard路init(Core路Guard *chk ,Core路Flag路Fn af){
+        if( !chk ) return;
+        chk->flag_function = af;
+        chk->flag = 0;
+      }
+
+      Local void Core路Guard路reset(Core路Guard *chk){
+        if( !chk ) return;
+        chk->flag = 0;
+      }
+
+      Local void Core路Guard路check(
+         Core路Guard *chk
+        ,uint err
+        ,bool condition
+        ,const char *message
+      ){
+        if( !chk || !chk->flag_function ) return;
+        if( condition ) return;
+        fprintf(stderr ,"%s\n" ,message);
+        chk->flag_function(&chk->flag ,err);
+      }
+
+      Local Core路Guard路FG Core路Guard路fg = {
+         .init = Core路Guard路init
+        ,.reset = Core路Guard路reset
+        ,.check = Core路Guard路check
+      };
+    #endif // *ifndef CVG
+
+    //----------------------------------------
+    // Functions implementation
+    //----------------------------------------
+
+    #ifndef CVT
+
+      Core路Status Core路on_track(){ return Core路Status路on_track; }
+      Core路Status Core路derailed(){ return Core路Status路derailed; }
+
+      Local Core路Status Core路is_aligned(AU *p ,extent路AU alignment ,bool *flag){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,p ,"given NULL p");
+          Core路Guard路fg.check(&chk ,1 ,flag ,"flag is NULL, so nowhere to write result");
+          Core路Guard路if_return(chk);
+        #endif
+        *flag = ( (uintptr_t)p & alignment ) == 0;
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路round_down(AU *p ,extent路AU alignment ,AU **result){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,p ,"given NULL p to round");
+          Core路Guard路fg.check(&chk ,1 ,result ,"result is NULL, so nowhere to write result");
+          Core路Guard路if_return(chk);
+        #endif
+        *result = (AU *)( (uintptr_t)p & ~(uintptr_t)alignment );
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路round_up(AU *p ,extent路AU alignment ,AU **result){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,p ,"given NULL p to round");
+          Core路Guard路fg.check(&chk ,1 ,result ,"result is NULL, so nowhere to write result");
+          Core路Guard路if_return(chk);
+        #endif
+        *result = (AU *)( ( (uintptr_t)p + alignment ) & ~(uintptr_t)alignment );
+        return Core路Status路on_track;
+      }
+
+      Local Core路F Core路f = {
+        .on_track = Core路on_track
+        ,.derailed = Core路derailed
+        ,.is_aligned = Core路is_aligned
+        ,.round_down = round_down
+        ,.round_up = round_up
+      };
+
+    #endif // #ifndef CVT
+
+    #ifdef CVT
+
+      // Struct instance initialization
+      螢(Core路F ,CVT) 螢(Core路F ,CVT)路f = {
+      };
+
+    #endif
+
+  //----------------------------------------
+  // TM_NX implementation
+  //----------------------------------------
+
+  /*
+  TM_NX are initialized with calls to 'mount_pe' or 'mount_pp'.  These both bind the machine to a tape, and mount the tape. Hence, there is no such thing as an initialized which is not bound to a tape. (It is possible to dismount the tm->hd, then remount tm->hd, but the tape remains bound through that process.)
+
+  Because the TM_NX has no destructive operations, Once it is initialized the tape will never get shorter. With TM_MX it is not possible to mount an empty tape, because the minimum value of extent路AU is zero. Therefore the tape can never be empty.
+
+  For an initialized TM_NX, TM_NX.array.hd == NULL means the tape is currently not mounted.
+
+  C has no means of binding an operation to allocation apart from the initializer syntax, but the user might not initialize a tape machine after allocating one. There is no deterministic method available to a TM_NX to detect if a machine is uninitialized. However, if it happens that TM_NX.array.position == NULL, the only explanations are 1) a bug  2) the machine was not initialized - and the initialized data in TM_NX.array.position happened to be zero. 
+
+  It is an error to re-initialize the machine while it is being used, unfortunately this is a contract with the user, because the TM_NX has no way to detect if the machine was initialized in the first place. 
+
+  */
+
+  #ifndef CVT
+    struct{
+      AU *position;
+      extent路AU extent路AU;
+      AU *hd;
+    }Core路TM_NX;
+  #endif
+
+  #ifdef CVT
+    struct{
+      CVT *position;
+      extent路AU extent路AU;
+      CVT *hd;
+    }螢(Core路TM_NX ,CVT);
+  #endif
+
+  //----------------------------------------
+  // TM_NX implementation
+  //----------------------------------------
+
+    //-----------------------------------
+    // common error messages
+
+    const char *螢(Core路TM_NX ,CVT)路Msg路tm="given NULL tm";
+    const char *螢(Core路TM_NX ,CVT)路Msg路flag="given NULL flag pointer";
+    const char *螢(Core路TM_NX ,CVT)路Msg路address=
+      "given NULL address pointer ,or address struct holds NULL address";
+    const char *螢(Core路TM_NX ,CVT)路Msg路address_on_tape=
+      "given address is not on the tape";
+    const char *螢(Core路TM_NX ,CVT)路Msg路extent路AU="given NULL extent路AU pointer";
+    const char *螢(Core路TM_NX ,CVT)路Msg路position=
+      "Null position.This is only possible when the tape machine has not been initialized.";
+
+    #ifndef CVT
+      Core路Status Core路TM_NX路topo(Core路TM_NX *tm ,Core路Tape路Topo *topo){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,topo ,"topo ptr is NULL, so nowhere to put result");
+          Core路Guard路if_return(chk);
+        #endif
+        if(tm->extent路AU == 0){
+          *topo = Core路Tape路Topo路singleton; 
+        }else{
+          *topo = Core路Tape路Topo路segment;
+        }
+        return Core路Status路on_track;
+      }
+
+      // extent路AU is an AU index
+      Local Core路Status Core路TM_NX路extent路AU(Core路TM_NX *tm ,extent路AU *extent路AU){
+        Core路Tape路Topo topo;
+        Core路Status status = Core路TM_NX_##CVT路topo(tm ,&topo);
+        boolean good_topo = 
+          (status == Core路Status路on_track) && (topo & Core路Tape路Topo路finite_nz)
+          ;
+
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,extent路AU ,Core路TM_NX路Msg路extent路AU);
+          Core路Guard路fg.check(
+            &chk ,0 ,good_topo
+            ,"Tape does not exist or topology does not have an extent路AU."
+          );
+          Core路Guard路if_return(chk);
+        #endif
+
+        if(!good_topo) return Core路Status路derailed;
+        *extent路AU = tm->array.extent路AU;
+        return Core路Status路on_track;
+      }
+
+    #endif
+
+    #ifdef CVT
+
+      //-----------------------------------
+      // Area functions within Core路TM_NX_##CVT
+
+      Core路Status Core路TM_NX_##CVT路topo(Core路TM_NX *tm ,Core路Tape路Topo *topo){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,topo ,"topo ptr is NULL, so nowhere to put result");
+          Core路Guard路if_return(chk);
+        #endif
+          if(tm->extent路AU == 0){
+            *topo = Core路Tape路Topo路singleton; 
+          }else{
+            *topo = Core路Tape路Topo路segment;
+          }
+          return Core路Status路on_track;
+      }
+
+
+      Local Core路Status Core路TM_NX_##CVT路mount_pe(
+        Core路TM_NX *tm ,void *position ,extent路AU extent路AU
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,position ,"given NULL position");
+          Core路Guard路if_return(chk);
+        #endif
+        tm->array.position = position->array.address;
+        tm->array.extent路AU = extent路AU;
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路mount_pp(
+        Core路TM_NX *tm ,void *position_left ,void *position_right
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          bool good_address = position_left && position_left->address;
+          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
+          good_address = position_right && position_right->address;
+          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
+          if(position_left && position_right){
+            Core路Guard路fg.check(
+              &chk ,1 ,position_right->array.address >= position_left->array.address
+              ,"position_right < position_left"
+            );
+          }
+          Core路Guard路if_return(chk);
+        #endif
+
+        extent路AU computed_extent路AU = 
+            (extent路AU)(
+              (uintptr_t)position_right->array.address - (uintptr_t)position_left->array.address
+            );
+
+        return Core路TM_NX_##CVT路mount_pe(tm ,position_left ,computed_extent路AU);
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路largest_aligned_64(
+        Core路TM_NX *outer ,Core路TM_NX *inner_64
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,outer ,"given NULL outer TM");
+          if(outer){
+            Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"NULL outer->array.position");
+          }
+          Core路Guard路fg.check(&chk ,1 ,inner_64 ,"given NULL inner TM");
+          Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"outer TM has NULL position");
+          Core路Guard路if_return(chk);
+        #endif
+
+        uintptr_t p0 = (uintptr_t)outer->array.position;
+        uintptr_t p1 = (uintptr_t)outer->array.position + outer->array.extent路AU;
+
+        CVT *p0_64 = (CVT *)( (p0 + 0x7) & ~(uintptr_t)0x7 );
+        CVT *p1_64 = (CVT *)( (p1 - 0x7) & ~(uintptr_t)0x7 );
+
+        if(p1_64 < p0_64){
+          inner_64->array.position = NULL;
+          inner_64->array.extent路AU = 0;
+          return Core路Status路derailed;
+        }
+
+        inner_64->array.position = p0_64;
+        inner_64->array.extent路AU = (extent路AU)(p1_64 - p0_64);
+        return Core路Status路on_track;
+      }
+
+
+      Local Core路Status Core路TM_NX_##CVT路encloses_pt(
+        Core路TM_NX *tm ,void *a ,bool *result
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          bool good_address = a && a->address;
+          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
+          Core路Guard路fg.check(&chk ,1 ,result ,"given NULL result pointer");
+          Core路Guard路if_return(chk);
+        #endif
+
+        *result = 
+             (a->array.address >= tm->array.position) 
+          && (a->array.address <= tm->array.position + tm->array.extent路AU);
+
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路encloses_pt_strictly(
+        Core路TM_NX *tm ,void *a ,bool *result
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          bool good_address = a && a->address;
+          Core路Guard路fg.check(&chk ,1 ,good_address ,Core路TM_NX_##CVT路Msg路address);
+          Core路Guard路fg.check(&chk ,1 ,result ,"given NULL result pointer");
+          Core路Guard路if_return(chk);
+        #endif
+
+        *result = 
+             (a->array.address > tm->array.position) 
+          && (a->array.address < tm->array.position + tm->array.extent路AU);
+
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路encloses_tm(
+        Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,outer ,"given NULL outer TM");
+          if(outer){
+            Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"NULL outer->array.position");
+          }
+          Core路Guard路fg.check(&chk ,1 ,inner ,"given NULL inner TM");
+          if(inner){
+            Core路Guard路fg.check(&chk ,1 ,inner->array.position ,"NULL inner->array.position");
+          }
+          Core路Guard路fg.check(&chk ,1 ,flag ,"given NULL flag pointer");
+          Core路Guard路if_return(chk);
+        #endif
+
+        *flag =
+             (inner->array.position >= outer->array.position) 
+          && (inner->array.position + inner->array.extent路AU <= outer->array.position + outer->array.extent路AU);
+
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路encloses_tm_strictly(
+        Core路TM_NX *outer ,Core路TM_NX *inner ,bool *flag
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,outer ,"given NULL outer TM");
+          if(outer){
+            Core路Guard路fg.check(&chk ,1 ,outer->array.position ,"NULL outer->array.position");
+          }
+          Core路Guard路fg.check(&chk ,1 ,inner ,"given NULL inner TM");
+          if(inner){
+            Core路Guard路fg.check(&chk ,1 ,inner->array.position ,"NULL inner->array.position");
+          }
+          Core路Guard路fg.check(&chk ,1 ,flag ,"given NULL flag pointer");
+          Core路Guard路if_return(chk);
+        #endif
+
+        *flag =
+             (inner->array.position > outer->array.position) 
+          && (inner->array.position + inner->array.extent路AU < outer->array.position + outer->array.extent路AU);
+
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路overlap(
+        Core路TM_NX *a ,Core路TM_NX *b ,bool *result
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,a ,"given NULL TM A");
+          if(a){
+            Core路Guard路fg.check(&chk ,1 ,a->array.position ,"NULL a->array.position");
+          }
+          Core路Guard路fg.check(&chk ,1 ,b ,"given NULL TM B");
+          if(b){
+            Core路Guard路fg.check(&chk ,1 ,b->array.position ,"NULL b->array.position");
+          }
+          Core路Guard路fg.check(&chk ,1 ,result ,"given NULL result pointer");
+          Core路Guard路if_return(chk);
+        #endif
+
+        *result =
+             (a->array.position < b->array.position + b->array.extent路AU) 
+          && (b->array.position < a->array.position + a->array.extent路AU);
+
+        return Core路Status路on_track;
+      }
+
+
+      //-----------------------------------
+      // base Tape Machine operations
+
+      Local Core路Status Core路TM_NX_##CVT路mount(Core路TM_NX *tm){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,tm->array.position ,Core路TM_NX_##CVT路Msg路position);
+          Core路Guard路if_return(chk);
+        #endif
+
+        tm->array.hd = tm->array.position;
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路dismount(Core路TM_NX *tm){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路if_return(chk);
+        #endif
+
+        // Reset head position upon dismount
+        tm->array.hd = NULL;
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路status(
+        Core路TM_NX *tm ,Core路TM路Head路Status *status
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,status ,"given NULL status pointer");
+          Core路Guard路if_return(chk);
+        #endif
+
+        if(tm->array.hd == NULL){
+          *status = Core路TM路Head路Status路not_on_tape;
+        }else if(tm->array.hd == tm->array.position){
+          *status = Core路TM路Head路Status路origin;
+        }else if(tm->array.hd == tm->array.position + tm->array.extent路AU){
+          *status = Core路TM路Head路Status路rightmost;
+        }else{
+          *status = Core路TM路Head路Status路interim;
+        }
+
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路can_read(Core路TM_NX *tm ,bool *flag){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          if(tm){
+            // All initialized TM_NX_##CVT have an initialized position
+            // Maybe this catches that the machine is uninitialized?
+            Core路Guard路fg.check(&chk ,1 ,tm->array.position ,Core路TM_NX_##CVT路Msg路position);
+          }      
+          Core路Guard路fg.check(&chk ,1 ,flag ,Core路TM_NX_##CVT路Msg路flag);
+          Core路Guard路if_return(chk);
+        #endif
+        *flag = tm && tm->array.hd != NULL;
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路on_origin(
+        Core路TM_NX *tm ,bool *flag
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,tm && tm->array.position ,Core路TM_NX_##CVT路Msg路position);
+          Core路Guard路fg.check(&chk ,1 ,flag ,Core路TM_NX_##CVT路Msg路flag);
+          Core路Guard路if_return(chk);
+        #endif
+
+        *flag = (tm->array.hd == tm->array.position);
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路on_rightmost(
+        Core路TM_NX *tm ,bool *flag
+      ){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,flag ,Core路TM_NX_##CVT路Msg路flag);
+          Core路Guard路fg.check(&chk ,1 ,tm && tm->array.position ,Core路TM_NX_##CVT路Msg路position);
+          Core路Guard路if_return(chk);
+        #endif
+
+        *flag = tm->array.hd == (tm->array.position + tm->array.extent路AU);
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路copy_datum(Core路TM_NX *tm_read ,Core路TM_NX *tm_write){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm_read ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,tm_write ,Core路TM_NX_##CVT路Msg路tm);
+          if(tm_read && tm_write){
+            Core路Guard路fg.check(
+              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm_read ,tm_read->array.hd) 
+              ,"Source address is outside tape bounds"
+            );
+            Core路Guard路fg.check(
+              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm_write ,tm_write->array.hd) 
+              ,"Destination address is outside tape bounds"
+            );
+          }
+          Core路Guard路if_return(chk);
+        #endif
+
+        *(tm_write->array.hd) = *(tm_read->array.hd);
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路read(Core路TM_NX *tm ,void *read_pt){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          if(tm) Core路Guard路fg.check(&chk ,1 ,tm->array.hd ,Core路TM_NX_##CVT路Msg路address);
+          if(tm && tm->array.hd){
+            Core路Guard路fg.check(
+              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm ,tm->array.hd) 
+              ,"Given address is outside tape bounds"
+            );
+          }
+          Core路Guard路if_return(chk);
+        #endif
+
+        *(CVT *)read_pt = *(tm_array.hd);
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路write(Core路TM_NX *tm ,void *write_pt){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          if(tm) Core路Guard路fg.check(&chk ,1 ,tm->array.hd ,Core路TM_NX_##CVT路Msg路address);
+          if(tm && tm->array.hd){
+            Core路Guard路fg.check(
+              &chk ,1 ,Core路TM_NX_##CVT路area.encloses_pt(tm ,tm->array.hd) 
+              ,"Given address is outside tape bounds"
+            );
+          }
+          Core路Guard路if_return(chk);
+        #endif
+
+        *(tm->array.hd) = *(CVT *)write_pt;
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status Core路TM_NX_##CVT路rewind(Core路TM_NX *tm){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          if(tm){
+            Core路Guard路fg.check(&chk ,1 ,tm->array.position ,Core路TM_NX_##CVT路Msg路position);
+          }
+          Core路Guard路if_return(chk);
+        #endif
+        tm->array.hd = tm->array.position;
+        return Core路Status路on_track;
+      }
+
+      Core路Status Core路TM_NX_##CVT路step(Core路TM_NX *tm){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,tm->array.position ,"step requested on unbound machine");
+          Core路Guard路fg.check(&chk ,1 ,tm->array.hd ,"step requested but tape not mounted");
+          Core路Guard路if_return(chk);
+        #endif
+        if( tm->array.hd < tm->array.position + tm->array.extent路AU ){
+          tm->array.hd++;
+          return Core路Status路on_track;
+        }
+        return Core路Status路derailed; // Stepping beyond tape bounds
+      }
+
+      Core路Status Core路TM_NX_##CVT路step_left(Core路TM_NX *tm){
+        #ifdef Core路Debug
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,Core路TM_NX_##CVT路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,tm->array.position 
+            ,"step_left requested on unbound machine"
+          );
+          Core路Guard路fg.check(&chk ,1 ,tm->array.hd 
+            ,"step_left requested with no mounted head"
+          );
+          Core路Guard路if_return(chk);
+        #endif
+        if( tm->array.hd > tm->array.position ){
+          tm->array.hd--;
+          return Core路Status路on_track;
+        }
+        return Core路Status路derailed; // Stepping beyond left boundary
+      }
+
+      // step_right is a synonym for step
+
+
+      //----------------------------------------
+      // Initialization for Core路TM_NX_##CVT路fg
+
+      Local Core路TM_NX路FG Core路TM_NX_##CVT路fg = {
+         .mount = Core路TM_NX_##CVT路mount
+        ,.dismount = Core路TM_NX_##CVT路dismount
+
+        ,.status = Core路TM_NX_##CVT路status
+        ,.can_read = Core路TM_NX_##CVT路can_read
+        ,.on_origin = Core路TM_NX_##CVT路on_origin
+        ,.on_rightmost = Core路TM_NX_##CVT路on_rightmost
+
+        ,.read = Core路TM_NX_##CVT路read
+        ,.write = Core路TM_NX_##CVT路write
+
+        ,.rewind = Core路TM_NX_##CVT路rewind
+        ,.step = Core路TM_NX_##CVT路step
+        ,.step_left = Core路TM_NX_##CVT路step_left
+        ,.step_right = Core路TM_NX_##CVT路step_right // Synonym for step
+
+        ,.area = {
+           .topo = Core路TM_NX_##CVT路topo
+          ,.extent路AU = Core路TM_NX_##CVT路extent路AU
+
+          ,.mount_pe = Core路TM_NX_##CVT路mount_pe
+          ,.mount_pp = Core路TM_NX_##CVT路mount_pp
+          ,.largest_aligned_64 = Core路TM_NX_##CVT路largest_aligned_64
+
+          ,.encloses_pt = Core路TM_NX_##CVT路encloses_pt
+          ,.encloses_pt_strictly = Core路TM_NX_##CVT路encloses_pt_strictly
+          ,.encloses_tm = Core路TM_NX_##CVT路encloses_tm
+          ,.encloses_tm_strictly = Core路TM_NX_##CVT路encloses_tm_strictly
+          ,.overlap = Core路TM_NX_##CVT路overlap
+        }
+      };
+
+    #endif
+
+    //----------------------------------------
+    // Map implementation
+    //----------------------------------------
+
+
+Core路Map路Completion Core路map(TM_MX *tm_read ,TM_MX *tm_write ,Core路Map路Fn fn){
+
+  Core路Guard路init_collect(chk);
+  if(!fn) chk.flag |= Core路Map路Completion路null_fn;
+  bool tm_read_can_read=false ,tm_write_can_read=false;
+  Core路TM路Head路Status tm_read_status ,tm_write_status;
+  if(
+    tm_read->can_read(tm_read ,&tm_read_can_read) == Core路Status路derailed
+    || tm_write->can_read(tm_write ,&tm_write_can_read) == Core路Status路derailed
+    || !tm_read_can_read
+    || !tm_write_can_read
+  ){
+    chk.flag |= Core路Map路Completion路no_tape_access;
+  }
+  Core路Guard路return(chk);
+
+  do{
+    TM_MX路Remote d_remote;
+    if( tm_read->read(tm_read ,&d_addr ,&d_remote) != Core路Status路on_track ){
+      chk.flag |= Core路Map路Completion路failed;
+      break;
+    }
+
+    TM_MX路Remote r_remote;
+    if(map->fn(&d_remote ,&r_remote) != Core路Status路on_track){
+      chk.flag |= Core路Map路Completion路not_computable;
+      break;
+    }
+
+    Core路TM_NX路Address r_addr;
+    if( tm_write->write(tm_write ,&r_addr ,&r_remote) != Core路Status路on_track ){
+      chk.flag |= Core路Map路Completion路failed;
+      break;
+    }
+
+    if(
+      tm_read->step(tm_read) != Core路Status路on_track
+      || tm_write->step(tm_write) != Core路Status路on_track
+    ){
+      chk.flag |= Core路Map路Completion路failed;
+      break;
+    }
+
+    tm_read->status(tm_read ,&tm_read_status);
+    tm_write->status(tm_write ,&tm_write_status);
+
+    if(
+      tm_read_status & Core路TM路Head路Status路rightmost
+      && tm_write_status & Core路TM路Head路Status路rightmost
+    ){
+      chk.flag |= Core路Map路Completion路perfect_fit;
+      break;
+    }
+
+    if(tm_read_status & Core路TM路Head路Status路rightmost){
+      chk.flag |= Core路Map路Completion路read_surplus;
+      break;
+    }
+
+    if(tm_write_status & Core路TM路Head路Status路rightmost){
+      chk.flag |= Core路Map路Completion路write_available;
+      break;
+    }
+
+  }while(true);
+
+  Core路Guard路return(chk);
+}
+
+
+    // Map function using trampoline execution model
+    Local Core路Map路Status Core路map(Core路Map路Fn fn){
+      #ifdef Core路Debug
+      if(!fn){
+        fprintf(stderr,"Core路map:: given null function");
+        return Core路Map路argument_guard;
+      }
+      if(
+         true
+         && fn != Core路Map路by_##CVT
+         && fn != Core路Map路##CVT_by_##CVT
+         && fn != Core路write_hex
+         && fn != Core路read_hex
+      ){
+        fprintf(stderr,"Core路map:: unrecognized copy function\n");
+        return Core路Map路argument_guard;
+      ) 
+      #endif
+
+      while(fn) fn = fn();
+      return tf.copy.status;
+    }
+
+
+
+    //----------------------------------------
+    // copy byte_by_byte 
+    //----------------------------------------
+
+    Core路Map路Fn Core路Map路Map路ByteByByte路perfect_fit;
+    Core路Map路Fn Core路Map路Map路ByteByByte路read_surplus;
+    Core路Map路Fn Core路Map路Map路ByteByByte路write_available;
+
+    Local Core路Map路Fn Core路Map路##CVT_by_##CVT(){
+      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) == Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write))
+        return Core路Map路ByteByByte路perfect_fit;
+
+      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) > Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write))
+        return Core路Map路ByteByByte路read_surplus;
+
+      return Core路Map路ByteByByte路write_available;
+    }
+
+    Local Core路Map路Fn Core路Map路ByteByByte路perfect_fit(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do{
+        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,*r);
+        if(*r == r1) break;
+        (*r)++;
+        (*w)++;
+      }while(true);
+
+      Core路tf.copy.status = Core路Map路Status路perfect_fit;
+      return NULL;
+    }
+
+    Local Core路Map路Fn Core路Map路ByteByByte路read_surplus(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
+
+      do{
+        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,*r);
+        if(*w == w1) break;
+        (*r)++;
+        (*w)++;
+      }while(true);
+
+      Core路tf.copy.status = Core路Map路Status路write_available;
+      return NULL;
+    }
+
+    Local Core路Map路Fn Core路Map路ByteByByte路write_avalable(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do{
+        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,*r);
+        if(*r == r1) break;
+        (*r)++;
+        (*w)++;
+      }while(true);
+
+      Core路tf.copy.status = Core路Map路Status路read_surplus;
+      return NULL;
+    }
+
+    //----------------------------------------
+    // copy copy_64
+
+    // 64-bit copy function with updated TableauFace terminology
+    Core路Map路Fn Core路Map路by_##CVT;
+    Core路Map路Fn Core路Map路ByWord64路leadin;
+    Core路Map路Fn Core路Map路ByWord64路bulk;
+    Core路Map路Fn Core路Map路ByWord64路tail;
+
+    // Initialize the copy_64 process
+    Local Core路Map路Fn Core路Map路by_##CVT(){
+      // Determine the largest 64-bit aligned region within the read area
+      Core路TM_NX_##CVT路largest_aligned_64(Core路tf.copy.read ,&Core路tl.copy_64.area_64);
+
+      // Choose the correct function based on alignment
+      if(Core路TM_NX_##CVT路empty(&Core路tl.copy_64.area_64)) return Core路Map路ByWord64路tail;
+      if(Core路is_aligned_on_64(Core路TM_NX_##CVT路position(Core路tf.copy.read))) return Core路Map路ByWord64路bulk;
+      return Core路Map路ByWord64路leadin;
+    }
+
+    // Lead-in byte copy (until alignment)
+    Local Core路Map路Fn Core路Map路ByWord64路leadin(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r0_64 = Core路TM_NX_##CVT路position(&Core路tl.copy_64.area_64);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do{
+        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,r0_64 ,*r);
+        if(*r == r0_64) break;
+        (*r)++;
+        (*w)++;
+      }while(true);
+
+      return Core路Map路ByWord64路bulk;
+    }
+
+    // Bulk word copy
+    Local Core路Map路Fn Core路Map路ByWord64路bulk(){
+      uint64_t **r = (uint64_t **)&Core路tf.copy.read_pt;
+      uint64_t **w = (uint64_t **)&Core路tf.copy.write_pt;
+      uint64_t *r1_64 = Core路TM_NX_##CVT路position_right(&Core路tl.copy_64.area_64);
+
+      do{
+        **w = Core路tf.copy.read_fn_64(Core路tf.copy.read ,r1_64 ,*r);
+        if(*r == r1_64) break;
+        (*r)++;
+        (*w)++;
+      }while(true);
+
+      return Core路Map路ByWord64路tail;
+    }
+
+    // Tail byte copy (unaligned trailing bytes)
+    Local Core路Map路Fn Core路Map路ByWord64路tail(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(&Core路tl.copy_64.area_64);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do{
+        **w = Core路tf.copy.read_fn_8(Core路tf.copy.read ,r1 ,*r);
+        if(*r == r1) break;
+        (*r)++;
+        (*w)++;
+      }while(true);
+
+      Core路tf.copy.status = Core路Map路Status路perfect_fit;
+      return NULL;
+    }
+
+    //----------------------------------------
+    // copy write hex
+
+    Local uint16_t Core路byte_to_hex(CVT byte){
+      static const char hex_digits[] = "0123456789ABCDEF";
+      return 
+          (hex_digits[byte >> 4] << 8) 
+        | hex_digits[byte & 0x0F];
+    }
+
+    // Forward Declarations
+    Core路Map路Fn Core路Map路write_hex;
+    Core路Map路Fn Core路Map路WriteHex路perfect_fit;
+    Core路Map路Fn Core路Map路WriteHex路read_surplus;
+    Core路Map路Fn Core路Map路WriteHex路write_available;
+
+    // Hex Encoding: Initialize Map
+    Local Core路Map路Fn Core路Map路write_hex(){
+      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) == (Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write) >> 1)){
+        return Core路Map路WriteHex路perfect_fit;
+      }
+      if(Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) > (Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write) >> 1)){
+        return Core路Map路WriteHex路read_surplus;
+      }
+      return Core路Map路WriteHex路write_available;
+    }
+
+    Local Core路Map路Fn Core路Map路WriteHex路perfect_fit(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do {
+        *(uint16_t *)*w = Core路hex.byte_to_hex(**r);
+        if(*r == r1) break;
+        (*r)++;
+        (*w) += 2;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路perfect_fit;
+      return NULL;
+    }
+
+    // Hex Encoding: Read Surplus
+    Local Core路Map路Fn Core路Map路WriteHex路read_surplus(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do {
+        *(uint16_t *)*w = Core路write_hex.byte_to_hex(**r);
+        if(*r == r1) break;
+        (*r)++;
+        (*w) += 2;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路read_surplus;
+      return NULL;
+    }
+
+    // Hex Encoding: Write Available
+    Local Core路Map路Fn Core路Map路WriteHex路write_available(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
+
+      do {
+        *(uint16_t *)*w = Core路write_hex.byte_to_hex(**r);
+        if(*w == w1) break;
+        (*r)++;
+        (*w) += 2;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路write_available;
+      return NULL;
+    }
+
+    //----------------------------------------
+    // copy read hex
+
+    Local CVT Core路hex_to_byte(uint16_t hex){
+      CVT high = hex >> 8;
+      CVT low = hex & 0xFF;
+
+      high = 
+          (high >= '0' && high <= '9') ? (high - '0')
+        : (high >= 'A' && high <= 'F') ? (high - 'A' + 10)
+        : (high >= 'a' && high <= 'f') ? (high - 'a' + 10)
+        : 0;
+
+      low = 
+          (low >= '0' && low <= '9') ? (low - '0')
+        : (low >= 'A' && low <= 'F') ? (low - 'A' + 10)
+        : (low >= 'a' && low <= 'f') ? (low - 'a' + 10)
+        : 0;
+
+      return (high << 4) | low;
+    }
+
+    Core路Map路Fn Core路Map路read_hex;
+    Core路Map路Fn Core路Map路ReadHex路perfect_fit;
+    Core路Map路Fn Core路Map路ReadHex路read_surplus;
+    Core路Map路Fn Core路Map路ReadHex路write_available;
+
+    Local Core路Map路Fn Core路Map路read_hex(){
+      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) == Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
+        return Core路Map路ReadHex路perfect_fit;
+      }
+      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) > Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
+        return Core路Map路ReadHex路read_surplus;
+      }
+      return Core路Map路ReadHex路write_available;
+    }
+
+    Local Core路Map路Fn Core路Map路ReadHex路perfect_fit(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do {
+        **w = Core路hex_to_byte(*(uint16_t *)*r);
+        if(*r == r1) break;
+        (*r) += 2;
+        (*w)++;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路perfect_fit;
+      return NULL;
+    }
+
+    Local Core路Map路Fn Core路Map路ReadHex路read_surplus(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do {
+        **w = Core路tf.read_hex.hex_to_byte(*(uint16_t *)*r);
+        if(*r == r1) break;
+        (*r) += 2;
+        (*w)++;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路read_surplus;
+      return NULL;
+    }
+
+    Local Core路Map路Fn Core路Map路ReadHex路write_available(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
+
+      do {
+        **w = Core路tf.read_hex.hex_to_byte(*(uint16_t *)*r);
+        if(*w == w1) break;
+        (*r) += 2;
+        (*w)++;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路write_available;
+      return NULL;
+    }
+
+    //----------------------------------------
+    // copy read hex
+
+    Core路Map路Fn Core路Map路read_hex;
+    Core路Map路Fn Core路Map路ReadHex路perfect_fit;
+    Core路Map路Fn Core路Map路ReadHex路read_surplus;
+    Core路Map路Fn Core路Map路ReadHex路write_available;
+
+    Local Core路Map路Fn Core路Map路read_hex(){
+      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) == Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
+        return Core路Map路ReadHex路perfect_fit;
+      }
+      if((Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.read) >> 1) > Core路TM_NX_##CVT路extent_by路AU(Core路tf.copy.write)){
+        return Core路Map路ReadHex路read_surplus;
+      }
+      return Core路Map路ReadHex路write_available;
+    }
+
+    Local Core路Map路Fn Core路Map路ReadHex路perfect_fit(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do {
+        **w = Core路hex_to_byte(*(uint16_t *)*r);
+        if(*r == r1) break;
+        (*r) += 2;
+        (*w)++;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路perfect_fit;
+      return NULL;
+    }
+
+    Local Core路Map路Fn Core路Map路ReadHex路read_surplus(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
+      CVT **w = &Core路tf.copy.write_pt;
+
+      do {
+        **w = Core路hex_to_byte(*(uint16_t *)*r);
+        if(*r == r1) break;
+        (*r) += 2;
+        (*w)++;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路read_surplus;
+      return NULL;
+    }
+
+    Local Core路Map路Fn Core路Map路ReadHex路write_available(){
+      CVT **r = &Core路tf.copy.read_pt;
+      CVT *r1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.read);
+      CVT **w = &Core路tf.copy.write_pt;
+      CVT *w1 = Core路TM_NX_##CVT路position_right(Core路tf.copy.write);
+
+      do {
+        **w = Core路hex_to_byte(*(uint16_t *)*r);
+        if(*w == w1) break;
+        (*r) += 2;
+        (*w)++;
+      } while(true);
+
+      Core路tf.copy.status = Core路Map路Status路write_available;
+      return NULL;
+    }
+
+
+
+  #endif // LOCAL
+
+#endif // IMPLEMENTATION
diff --git a/developer/cc馃枆/TM.lib.c b/developer/cc馃枆/TM.lib.c
new file mode 100644 (file)
index 0000000..947bbed
--- /dev/null
@@ -0,0 +1,472 @@
+/*
+  TM - Tape Machine
+
+  This file has the template parameter: `CVT`
+
+  `CVT` Cell Value Type`. It is the type of the datum placed in a cell. By default (when the   macro CVT has no definition) the cell value type is taken as AUM. This file must
+  be included with CVT undefined ,before inclusions with it defined.
+  'Tape' is operated on by the Tape Machine.
+
+  'Area' is subset of an address space that is used as a virtual Tape by a machine.
+
+   An Area with zero elements has 'length == 0' or is 'empty'. In contrast ,and
+   area located (position specified) with a null pointer is said not to exist.
+
+*/
+
+#define TM路DEBUG
+
+#ifndef FACE
+#define TM路IMPLEMENTATION
+#define FACE
+#endif 
+
+//--------------------------------------------------------------------------------
+// Interface
+
+#ifndef TM路FACE
+#define TM路FACE
+
+  #include <stdint.h>
+  #include <stddef.h>
+
+  #include "Core.lib.c"
+
+  //----------------------------------------
+  // Tape Machine interface
+  //----------------------------------------
+
+  #ifndef CVT
+    typedef enum{
+       TM路Tape路Topo路mu = 0 
+      ,TM路Tape路Topo路nonexistent = 1 
+      ,TM路Tape路Topo路empty       = 1 << 1
+      ,TM路Tape路Topo路singleton   = 1 << 2
+      ,TM路Tape路Topo路segment     = 1 << 3
+      ,TM路Tape路Topo路circle      = 1 << 4
+      ,TM路Tape路Topo路tail_cyclic = 1 << 5
+      ,TM路Tape路Topo路infinite    = 1 << 6
+    }TM路Tape路Topo;
+
+    const TM路Tape路Topo TM路Tape路Topo路finite_nz = 
+      TM路Tape路Topo路singleton | TM路Tape路Topo路segment
+      ;
+
+    // If tape machine does not support step left ,then Status路leftmost 
+    // will be reported as Status路interim.
+    typedef enum{
+       TM路Head路Status路mu = 0
+      ,TM路Head路Status路not_on_tape = 1
+      ,TM路Head路Status路origin    = 1 << 1
+      ,TM路Head路Status路interim   = 1 << 2
+      ,TM路Head路Status路rightmost = 1 << 3
+    } TM路Head路Status;
+
+    const TM路Head路Status TM路Head路Status路on_tape = 
+      TM路Head路Status路origin
+      | TM路Head路Status路interim
+      | TM路Head路Status路rightmost
+      ;
+  #endif // #ifndef CVT
+
+  #ifndef CVT
+    typedef struct 螢(TM路Array ,CVT);
+
+    // tape and area are included with Tape Machine to facilitate abstract interfaces.
+    typedef struct{
+
+      struct {
+        Core路Status      (*topo)  ( 螢(TM路Array ,CVT) *tm ,TM路Tape路Topo *result );
+        螢(extent_t ,CVT) (*extent)( 螢(TM路Array ,CVT) *tm );
+      } tape;
+
+      struct {
+        // Initialize tm
+        Core路Status (*mount_pe)(螢(TM路Array ,CVT) *tm ,CVT position[] ,螢(extent_t ,CVT) extent);
+        Core路Status (*mount_pp)(螢(TM路Array ,CVT) *tm ,CVT *position_left ,CVT *position_right);
+      } area;
+
+      // tape machine functions
+      Core路Status (*mount)   (螢(TM路Array ,CVT) *tm);
+      Core路Status (*dismount)(螢(TM路Array ,CVT) *tm);
+
+      TM路Head路Status (*status)        (螢(TM路Array ,CVT) *tm ,TM路Head路Status *status);
+      Core路Status    (*head_on_format)(螢(TM路Array ,CVT) *tm ,bool *flag);
+
+      bool (*can_read)    (螢(TM路Array ,CVT) *tm);
+      bool (*on_origin)   (螢(TM路Array ,CVT) *tm);
+      bool (*on_rightmost)(螢(TM路Array ,CVT) *tm);
+
+      void (*step)      (螢(TM路Array ,CVT) *tm);
+      void (*step_left) (螢(TM路Array ,CVT) *tm);
+      void (*step_right)(螢(TM路Array ,CVT) *tm); // Synonym for step
+      void (*rewind)    (螢(TM路Array ,CVT) *tm);
+
+      void (*copy_datum)( 螢(TM路Array ,CVT) *tm_read ,螢(TM路Array ,CVT) *tm_write );
+      void (*read)      ( 螢(TM路Array ,CVT) *tm ,CVT *remote_pt );
+      void (*write)     ( 螢(TM路Array ,CVT) *tm ,CVT *remote_pt );
+
+    } 螢(TM路Array ,CVT)路FG;
+
+    螢(TM路Array ,CVT)路FG 螢(TM路Array ,CVT)路fg;
+
+  #endif // #ifdef CVT
+
+#endif
+
+//--------------------------------------------------------------------------------
+// Implementation
+
+#ifdef TM路IMPLEMENTATION
+  // declarations available to all of the IMPLEMENTATION go here
+  //
+    #ifdef TM路DEBUG
+      #include <stdio.h>
+    #endif
+
+  // implementation to go into the lib.a file
+  //
+    #ifndef LOCAL
+    #endif 
+
+  #ifdef LOCAL
+
+    //----------------------------------------
+    // TM路Array implementation
+    //----------------------------------------
+
+    /*
+      TM路Array is bound to a tape with head on the tape via mount_pe or mount_pp.  
+
+      Once a tape is bound ,it remains so ,though the head can be dismounted
+      and remounted.
+
+      C lacks an allocation-bound initialization feature ,so the library user is responsible
+      to make sure a TM路Array has been initialized before use.
+
+      The TM路Array has no locking facility ,so it is not possible to know if it is in use.
+
+      Re-initializing a TM路Array while in use can lead to unspecified badness. Use `rewind` instead.
+    */
+
+    //----------------------------------------
+    // TM路Array implementation
+    //----------------------------------------
+
+    #ifndef CVT
+
+      //-----------------------------------
+      // common error messages
+
+      const char *TM路Array路Msg路tm="given NULL tm";
+      const char *TM路Array路Msg路flag="given NULL flag pointer";
+      const char *TM路Array路Msg路result="given NULL result pointer";
+      const char *TM路Array路Msg路position=
+        "Null position.This is only possible when the tape machine has not been initialized.";
+
+    #endif // #ifndef CVT
+
+    #ifdef CVT
+
+      struct{
+        CVT *hd;
+        CVT *position;
+        螢(extent_t ,CVT) extent;
+      }螢(TM路Array ,CVT);
+
+      //-----------------------------------
+      // TM路Array.tape implementation
+
+      /*
+        For an Array Tape Machine ,a bound tape will be singleton or segment.
+        An initialized Array Tape Machine always has a bound tape.
+      */
+      Core路Status 螢(TM路Array ,CVT)路topo(螢(TM路Array ,CVT) *tm ,TM路Tape路Topo *result){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
+          if(tm) Core路Guard路fg.check(&chk ,1 ,tm->position ,TM路Array路Msg路position);
+          Core路Guard路fg.check(&chk ,1 ,result ,TM路Array路Msg路result);
+          Core路Guard路if_return(chk);
+        #endif
+        if(tm->extent == 0){
+          *result = TM路Tape路Topo路singleton; 
+        }else{
+          *result = TM路Tape路Topo路segment;
+        }
+        return Core路Status路on_track;
+      }
+
+      // check the topo to make sure tape has extent before calling this
+      // `extent路CVT` returns the index to the rightmost cell in the array.
+      Local  螢(extent_t ,CVT) 螢(TM路Array ,CVT)路extent(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Tape路Topo topo = Core路Tape路Topo路mu;
+          Core路Status status = 螢(TM路Array ,CVT)路topo(tm ,&topo);
+          bool good_topo = 
+            (status == Core路Status路on_track) && (topo & Core路Tape路Topo路finite_nz)
+            ;
+          Core路Guard路fg.check(&chk ,1 ,good_topo ,"Tape does not have an extent.");
+          Core路Guard路assert(chk);
+        #endif
+
+        *result = tm->extent;
+        return Core路Status路on_track;
+      }
+
+      //-----------------------------------
+      // TM路Array.area implementation 
+
+      Local Core路Status 螢(TM路Array ,CVT)路mount_pe(
+        螢(TM路Array ,CVT) *tm ,CVT *position ,螢(extent_t ,CVT) extent
+      ){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,position ,"Given NULL position.");
+          Core路Guard路if_return(chk);
+        #endif
+        tm->position = position;
+        tm->extent = extent;
+        tm->hd = position; // mount the head on the origin cell
+        return Core路Status路on_track;
+      }
+
+      // If size of CVT is not a power of two this can perform a divide
+      Local Core路Status 螢(TM路Array ,CVT)路mount_pp(
+        螢(TM路Array ,CVT) *tm ,CVT *pos_leftmost ,CVT *pos_rightmost
+      ){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,pos_leftmost  ,"Null pos_leftmost.");
+          Core路Guard路fg.check(&chk ,1 ,pos_rightmost ,"Null pos_rightmost.");
+          if(pos_leftmost && pos_rightmost){
+            Core路Guard路fg.check(&chk ,1 ,pos_rightmost >= pos_leftmost 
+              ,"pos_rightmost < pos_leftmost"
+            );
+          }
+          Core路Guard路if_return(chk);
+        #endif
+
+        螢(extent_t ,CVT) extent = pos_rightmost - pos_leftmost);
+        return 螢(TM路Array ,CVT)路mount_pe(tm ,pos_leftmost ,extent);
+      }
+
+      //-----------------------------------
+      // base Tape Machine operations
+
+      Local Core路Status 螢(TM路Array ,CVT)路mount(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
+          if(tm) Core路Guard路fg.check(&chk ,1 ,tm->position ,TM路Array路Msg路position);
+          Core路Guard路if_return(chk);
+        #endif
+
+        // mounting an already mounted head does nothing ,perhaps you meant `rewind`?
+        if(!tm->hd) tm->hd = tm->position;
+        return Core路Status路on_track;
+      }
+
+      Local Core路Status 螢(TM路Array ,CVT)路dismount(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
+          Core路Guard路if_return(chk);
+        #endif
+
+        tm->hd = NULL;
+        return Core路Status路on_track;
+      }
+
+      Local TM路Head路Status 螢(TM路Array ,CVT)路status(
+        螢(TM路Array ,CVT) *tm ,TM路Head路Status *status
+      ){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
+          Core路Guard路fg.check(&chk ,1 ,status ,"given NULL status pointer");
+          Core路Guard路if_return(chk);
+        #endif
+
+        if(tm->hd == NULL){
+          *status = TM路Head路Status路not_on_tape;
+        }else if(tm->hd == tm->position){
+          *status = TM路Head路Status路origin;
+        }else if(tm->hd == tm->position + tm->extent){
+          *status = TM路Head路Status路rightmost;
+        }else{
+          *status = TM路Head路Status路interim;
+        }
+
+        return Core路Status路on_track;
+      }
+
+     // Stronger than `can_read`. Used mostly for debugging.
+     // as it checks for a legal head position.
+      Local Core路Status 螢(TM路Array ,CVT)路head_on_format(
+        螢(TM路Array ,CVT) *tm ,bool *flag
+      ){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
+          if(tm) Core路Guard路fg.check(&chk ,1 ,tm->position ,TM路Array路Msg路position);
+          Core路Guard路fg.check(&chk ,1 ,flag ,TM路Array路Msg路flag);
+          Core路Guard路if_return(chk);
+        #endif
+
+        *flag = 
+             tm->hd
+          && tm->hd >= tm->position
+          && tm->hd - tm->position <= tm->extent
+          && ( (AU *)tm->hd - (AU *)tm->position ) % sizeof(CVT) == 0 // '%' expensive
+          ;
+        return Core路Status路on_track;
+      }
+
+      bool 螢(TM路Array ,CVT)路can_read(螢(TM路Array ,CVT) *tm){
+        return tm && tm->position && tm->hd;
+      }
+
+      // can_read was true
+      bool 螢(TM路Array ,CVT)路on_origin(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
+          Core路Guard路assert(chk);
+        #endif
+        return tm->hd == tm->position;
+      }
+
+      // can_read was true
+      bool 螢(TM路Array ,CVT)路on_rightmost(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
+          Core路Guard路assert(chk);
+        #endif
+        return tm->hd == tm->position;
+      }
+
+      void 螢(TM路Array ,CVT)路step(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
+          Core路Guard路assert(chk);
+        #endif
+        tm->hd++;
+      }
+
+      void 螢(TM路Array ,CVT)路step_left(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
+          Core路Guard路assert(chk);
+        #endif
+        tm->hd--;
+      }
+
+      void 螢(TM路Array ,CVT)路rewind(螢(TM路Array ,CVT) *tm){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
+          Core路Guard路assert(chk);
+        #endif
+        tm->hd = tm->position;
+      }
+
+      // tm_can_read must be true for both machines.
+      void 螢(TM路Array ,CVT)路copy_datum(螢(TM路Array ,CVT) *tm_read ,螢(TM路Array ,CVT) *tm_write){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm_read ,flag) == Control路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"tm_read head off track");
+          s = 螢(TM路Array ,CVT)路head_on_format(tm_write ,flag) == Control路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"tm_write head off track");
+          Core路Guard路assert(chk);
+        #endif
+
+        *(tm_write->hd) = *(tm_read->hd);
+        return Core路Status路on_track;
+      }
+
+      void 螢(TM路Array ,CVT)路read(螢(TM路Array ,CVT) *tm ,CVT *read_pt){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
+          Core路Guard路assert(chk);
+        #endif
+
+        *read_pt = *(tm->hd);
+      }
+
+      void 螢(TM路Array ,CVT)路write(螢(TM路Array ,CVT) *tm ,CVT *write_pt){
+        #ifdef TM路DEBUG
+          Core路Guard路init_count(chk);
+          bool flag = true ,s;
+          s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+          Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
+          Core路Guard路assert(chk);
+        #endif
+
+        *(tm->hd) = *write_pt;
+      }
+
+      // step_right is a synonym for step
+
+
+      //----------------------------------------
+      // Initialization for 螢(TM路Array ,CVT)路fg
+
+      Local 螢(TM路Array ,CVT)路FG 螢(TM路Array ,CVT)路fg = {
+        .tape = {
+           .topo   = 螢(TM路Array ,CVT)路topo
+           .extent = 螢(TM路Array ,CVT)路extent
+        }
+
+        ,.area = {
+           .mount_pe = 螢(TM路Array ,CVT)路mount_pe
+          ,.mount_pp = 螢(TM路Array ,CVT)路mount_pp
+        }
+
+        ,.mount    = 螢(TM路Array ,CVT)路mount
+        ,.dismount = 螢(TM路Array ,CVT)路dismount
+
+        ,.status         = 螢(TM路Array ,CVT)路status
+        ,.head_on_format = 螢(TM路Array ,CVT)路head_on_format
+
+        ,.can_read     = 螢(TM路Array ,CVT)路can_read
+        ,.on_origin    = 螢(TM路Array ,CVT)路on_origin
+        ,.on_rightmost = 螢(TM路Array ,CVT)路on_rightmost
+
+        ,.step = 螢(TM路Array ,CVT)路step
+        ,.step_left = 螢(TM路Array ,CVT)路step_left
+        ,.step_right = 螢(TM路Array ,CVT)路step_right // Synonym for step
+        ,.rewind = 螢(TM路Array ,CVT)路rewind
+
+        ,.copy_datum = 螢(TM路Array ,CVT)路copy_datum
+        ,.read = 螢(TM路Array ,CVT)路read
+        ,.write = 螢(TM路Array ,CVT)路write
+
+      };
+
+    #endif // ifdef CVT
+
+  #endif // LOCAL
+
+#endif // IMPLEMENTATION
diff --git a/developer/cc馃枆/TM_scratch.c b/developer/cc馃枆/TM_scratch.c
new file mode 100644 (file)
index 0000000..13b2240
--- /dev/null
@@ -0,0 +1,65 @@
+      // This initializes 'inner'.
+      // `alignment` is an extent, e.g. extent_of路AU(uint64_t) = 0x7
+      Local TM路Status 螢(TM路NX ,CVT)路largest_aligned(
+        TM路NX路AU *outer ,螢(TM路NX ,CVT) *inner ,extent路AU alignment
+      ){
+        uintptr_t p0 = (uintptr_t)outer->position;
+        uintptr_t p1 = (uintptr_t)outer->position + outer->extent;
+
+        CVT *p0_aligned = (CVT *)(
+          (p0 + alignment) & ~( (uintptr_t)alignment )
+        );
+        CVT *p1_aligned = (CVT *)(
+          ( p1 - extent_of路AU(CVT) ) & ~( (uintptr_t)alignment )
+        );
+
+        if( p1_aligned < p0_aligned ) return TM路Status路derailed;
+
+        inner->position = p0_aligned;
+        inner->extent = (螢(extent_t ,CVT))(p1_aligned - p0_aligned};
+        return TM路Status路on_track;
+      }
+
+
+
+    
+      Local TM路Status TM路NX路topo(TM路NX *tm ,TM路Tape路Topo *topo){
+        #ifdef TM路Debug
+          TM路Guard路init_count(chk);
+          TM路Guard路fg.check(&chk ,1 ,tm ,TM路NX_##CVT路Msg路tm);
+          TM路Guard路fg.check(&chk ,1 ,topo ,"topo ptr is NULL, so nowhere to put result");
+          TM路Guard路if_return(chk);
+        #endif
+        if(tm->extent路AU == 0){
+          *topo = TM路Tape路Topo路singleton; 
+        }else{
+          *topo = TM路Tape路Topo路segment;
+        }
+        return TM路Status路on_track;
+      }
+
+      // extent路AU is an AU index
+      Local TM路Status TM路NX路extent路AU(TM路NX *tm ,extent路AU *extent路AU){
+        TM路Tape路Topo topo;
+        TM路Status status = TM路NX_##CVT路topo(tm ,&topo);
+        boolean good_topo = 
+          (status == TM路Status路on_track) && (topo & TM路Tape路Topo路finite_nz)
+          ;
+
+        #ifdef TM路Debug
+          TM路Guard路init_count(chk);
+          TM路Guard路fg.check(&chk ,1 ,tm ,TM路NX路Msg路tm);
+          TM路Guard路fg.check(&chk ,1 ,extent路AU ,TM路NX路Msg路extent路AU);
+          TM路Guard路fg.check(
+            &chk ,0 ,good_topo
+            ,"Tape does not exist or topology does not have an extent路AU."
+          );
+          TM路Guard路if_return(chk);
+        #endif
+
+        if(!good_topo) return TM路Status路derailed;
+        *extent路AU = tm->array.extent路AU;
+        return TM路Status路on_track;
+      }
+
+    #endif
diff --git a/developer/document馃枆/alignment.org b/developer/document馃枆/alignment.org
new file mode 100644 (file)
index 0000000..aa9ee34
--- /dev/null
@@ -0,0 +1,13 @@
+
+
+Interesting observation, recovering alignment for a pointer into an array is expensive.  It requires modulus against the element size to find how far off the pointer is.
+
+If one starts aligned, say on zero, then only increments by the element size, alignment is not ever lost.  However, if an element pointer is computed by a imprecise process, and rounding is recovered to get it back again, then the modulus is required.
+
+However, modulus is not hard on powers of the radix boundaries. 
+
+So either a) in the first place make elements a power of the radix in size, perhaps even using padding,  b)  change the radix of the number system so the native element size if the radix, or a power there of  c) never do a computation that loses alignment.
+
+As a consequence it is expensive to compute the extent of an object with arbitrary CVT (Cell Value Type).  Given the two bounding pointers, one must subtract and divide by the sizeof(CVT) to recover the extent, and divide is expensive. In contrast when given the position and extent, the address of the rightmost cell can be recovered with an addition. 
+
+It follows that if the extent is needed that it makes more sense to store the position and extent for an interval than it does to store two bounding pointers.