This is the mail archive of the cgen@sources.redhat.com mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch][rfa] CGEN Model Support for SID


Hi,

This submission cleans up the partially adapted support for CGEN models for SID and enables it. Attached are patches for CGEN and SID which accomplish this:

o sid-model.patch.txt's: Patches for CGEN and SID
o cgen-model.h: New class definition in sid/component/cgen-cpu
o *.ChangeLog: ChangeLogs for the above

Also attached are examples of the generated code and suggested usage for the xstormy16:

o xstormy16-model.{cxx,h}: CGEN-generated model code
o xstormy16-model-gen.patch.txt: Additional code generated into xstormy16-decode.h and xstormy16-sem.cxx
o xstormy16-model.patch.txt: Patch showing suggest usage of the generated code by a SID cgen-cpu.


Notes:

o The implementation is similar to the existing implementation for sim/common simulators except:
- The generated functions are encapsulated into a class: <prefix>_<model>_model
- Functions are generated for modelling each insn both before and after execution. The sim/common implementation only generated a function to be called after execution, however, there was a need for modelling both before and after in the implementaion of the FRV simulator which was handled somewhat awkwardly. Therefore I added this capability for this implementation.
- As in the existing sim/common implementation, there are hooks provided (at the cgen-model level) for modelling before and after groups of parallel insns.


A general outline of the design follows:

o A new class, cgen-model, has been defined in sid/component/cgen-cpu/cgen-model.h. It provides the methods for modelling before and after groups of parallel insns with default virtual implementations and keeps a pointer to the cpu for reporting computed latencies.

o The script sid/component/cgen-cpu/CGEN.sh has been enhanced to process the option 'with-profile=fn' and to generate the files model.cxx and model.h.

o For each model (cgen model) used by a all machines (cgen mach) being generated, a class, @prefix at _@model at _model is generated in sid/component/cgen-cpu/@cpu@/@prefix at -model dot {cxx,h}. These classes each inherit from cgen-cpu and implement the functions for modelling each unit before and after each insn. Default virtual implementations are provided as well as a table mapping each insn to its unit modelling functions and functions for indexing the table to make the calls.

o The generated code, as is, is complete and implements default latency computations as defined by the (timing ...) elements of each insn in the .cpu file.

o Since the default implementations are virtual, the programmer may inherit the generated class(es) to implement more complex modelling behavior for each unit of each model as needed.

o Calls to the modelling functions are inserted, as necessary, into the cpu's step_insns method. See xstormy16-model.patch.txt for an example.

This implementation has been tested on xstormy16 and an internal port which makes extensive use of this new work. Other ports are not affected since they do not make use of this functionality.

I am seeking comments leading toward approval to commit the general changes. I can also commit the xtormy16-specific code if folks think it would be of use as an example.

Dave
Index: cgen/cgen-sid.scm
===================================================================
RCS file: /cvs/src/src/cgen/cgen-sid.scm,v
retrieving revision 1.1
diff -c -p -r1.1 cgen-sid.scm
*** cgen/cgen-sid.scm	8 Dec 2000 22:34:20 -0000	1.1
--- cgen/cgen-sid.scm	31 Mar 2003 19:41:47 -0000
***************
*** 1,7 ****
  ; Simulator generator entry point.
  ; This is invoked to build: desc.h, cpu.h, defs.h, decode.h, decode.cxx,
! ; semantics.cxx, sem-switch.cxx.
! ; Copyright (C) 2000 Red Hat, Inc.
  ; This file is part of CGEN.
  ;
  ; This is a standalone script, we don't load anything until we parse the
--- 1,7 ----
  ; Simulator generator entry point.
  ; This is invoked to build: desc.h, cpu.h, defs.h, decode.h, decode.cxx,
! ; semantics.cxx, sem-switch.cxx, model.h, model.cxx
! ; Copyright (C) 2000, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  ;
  ; This is a standalone script, we don't load anything until we parse the
***************
*** 41,46 ****
--- 41,48 ----
  	 (lambda (arg) (file-write arg cgen-sem-switch.cxx)))
     (list '-M "file" "generate model.cxx in <file>"
  	 (lambda (arg) (file-write arg cgen-model.cxx)))
+    (list '-N "file" "generate model.h in <file>"
+ 	 (lambda (arg) (file-write arg cgen-model.h)))
     )
  )
  
Index: cgen/model.scm
===================================================================
RCS file: /cvs/src/src/cgen/model.scm,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 model.scm
*** cgen/model.scm	28 Jul 2000 04:11:52 -0000	1.1.1.1
--- cgen/model.scm	31 Mar 2003 19:41:47 -0000
***************
*** 1,5 ****
  ; CPU implementation description.
! ; Copyright (C) 2000 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
--- 1,5 ----
  ; CPU implementation description.
! ; Copyright (C) 2000, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
***************
*** 66,78 ****
      (elm-xset! result 'done done)
      result)
  )
- 
- (define (unit:enum u)
-   (gen-c-symbol (string-append "UNIT_"
- 			       (string-upcase (obj:name (unit:model u)))
- 			       "_"
- 			       (string-upcase (obj:name u))))
- )
  
  ; The `<model>' class.
  ;
--- 66,71 ----
***************
*** 272,277 ****
--- 265,271 ----
  ; are returned as (model1), i.e. an empty unit list.
  
  (define (parse-insn-timing context insn-timing-desc)
+   (logit 2 "parse-insn-timing: context==" context ", desc==" insn-timing-desc "\n")
    (map (lambda (model-timing-desc)
  	 (let* ((model-name (car model-timing-desc))
  		(model (current-model-lookup model-name)))
Index: cgen/sid-decode.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid-decode.scm,v
retrieving revision 1.8
diff -c -p -r1.8 sid-decode.scm
*** cgen/sid-decode.scm	7 Feb 2002 18:46:19 -0000	1.8
--- cgen/sid-decode.scm	31 Mar 2003 19:41:47 -0000
***************
*** 1,5 ****
  ; Decoder generation.
! ; Copyright (C) 2000, 2002 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; Return decode entries for each insn.
--- 1,5 ----
  ; Decoder generation.
! ; Copyright (C) 2000, 2002, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; Return decode entries for each insn.
*************** struct @prefix at _scache {
*** 300,306 ****
    // argument buffer
    @prefix at _sem_fields fields;
  
! " (if (or (with-profile?) (with-parallel-write?))
        (string-append "
    // writeback flags
    // Only used if profiling or parallel execution support enabled during
--- 300,306 ----
    // argument buffer
    @prefix at _sem_fields fields;
  
! " (if (or (with-any-profile?) (with-parallel-write?))
        (string-append "
    // writeback flags
    // Only used if profiling or parallel execution support enabled during
Index: cgen/sid-model.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid-model.scm,v
retrieving revision 1.3
diff -c -p -r1.3 sid-model.scm
*** cgen/sid-model.scm	7 Jan 2002 08:23:59 -0000	1.3
--- cgen/sid-model.scm	31 Mar 2003 19:41:47 -0000
***************
*** 1,7 ****
  ; Simulator model support, plus misc. things associated with a cpu family.
! ; Copyright (C) 2000, 2002 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; Return C code to define cpu implementation properties.
  
  (define (-gen-cpu-imp-properties)
--- 1,12 ----
  ; Simulator model support, plus misc. things associated with a cpu family.
! ; Copyright (C) 2000, 2002, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  
+ (define (unit:enum u)
+   (gen-c-symbol (string-append "UNIT_"
+ 			       (string-upcase (obj:name u))))
+ )
+ 
  ; Return C code to define cpu implementation properties.
  
  (define (-gen-cpu-imp-properties)
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 63,79 ****
     )
  )
  
  ; Return name of profiling handler for MODEL, UNIT.
  ; Also called by sim.scm.
  
! (define (gen-model-unit-fn-name model unit)
!   (string-append "@prefix at _model_" (gen-sym model) "_" (gen-sym unit))
  )
  
! ; Return decls of all insn model handlers.
! ; This is called from sim-decode.scm.
! 
! (define (gen-model-fn-decls)
    (let ((gen-args (lambda (args)
  		    (gen-c-args (map (lambda (arg)
  				       (string-append
--- 68,86 ----
     )
  )
  
+ ; Return the name of the class representing the given MODEL.
+ (define (gen-model-class-name model)
+   (string-append "@prefix at _" (gen-sym model) "_model")
+ )
+ 
  ; Return name of profiling handler for MODEL, UNIT.
  ; Also called by sim.scm.
  
! (define (gen-model-unit-fn-name model unit when)
!   (string-append "model_" (gen-sym unit) "_" (symbol->string when))
  )
  
! (define (gen-model-unit-fn-decl model unit when)
    (let ((gen-args (lambda (args)
  		    (gen-c-args (map (lambda (arg)
  				       (string-append
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 84,135 ****
  					     (not (null? (cdr arg))))
  					   args)))))
  	)
  
!     (string-list
!      ; -gen-hw-profile-decls
!      "/* Function unit handlers (user written).  */\n\n"
!      (string-list-map
!       (lambda (model)
! 	(string-list-map (lambda (unit)
! 			   (string-append
! 			    "extern int "
! 			    (gen-model-unit-fn-name model unit)
! 			    " (@cpu at _cpu *, const struct @prefix at _idesc *,"
! 			    " int /*unit_num*/, int /*referenced*/"
! 			    (gen-args (unit:inputs unit))
! 			    (gen-args (unit:outputs unit))
! 			    ");\n"))
! 			 (model:units model)))
!       (current-model-list))
!      "\n"
!      "/* Profiling before/after handlers (user written) */\n\n"
!      "extern void @prefix at _model_insn_before (@cpu at _cpu *, int /*first_p*/);\n"
!      "extern void @prefix at _model_insn_after (@cpu at _cpu *, int /*last_p*/, int /*cycles*/);\n"
!      "\n"
!      ))
  )
  
  ; Return name of profile handler for INSN, MODEL.
  
! (define (-gen-model-insn-fn-name model insn)
!   (string-append "model_" (gen-sym model) "_" (gen-sym insn))
  )
  
  ; Return function to model INSN.
  
! (define (-gen-model-insn-fn model insn)
    (logit 2 "Processing modeling for " (obj:name insn) ": \"" (insn-syntax insn) "\" ...\n")
    (let ((sfmt (insn-sfmt insn)))
      (string-list
!      "static int\n"
!      (-gen-model-insn-fn-name model insn)
!      " (@cpu at _cpu *current_cpu, @prefix at _scache *sem_arg)\n"
       "{\n"
       (if (with-scache?)
  	 (gen-define-field-macro sfmt)
  	 "")
!      "  const @prefix at _argbuf * UNUSED abuf = sem_arg->argbuf;\n"
!      "  const @prefix at _idesc * UNUSED idesc = abuf->idesc;\n"
       ; or: idesc = & CPU_IDESC (current_cpu) ["
       ; (gen-cpu-insn-enum (mach-cpu (model:mach model)) insn)
       ; "];\n"
--- 91,176 ----
  					     (not (null? (cdr arg))))
  					   args)))))
  	)
+     (string-append
+      "  virtual UINT "
+      (gen-model-unit-fn-name model unit when)
+      " (@cpu at _cpu *cpu, const struct @prefix at _idesc *idesc,"
+      " int unit_num"
+      (if (equal? when 'after)
+ 	 ", unsigned long long referenced" "")
+      (gen-args (unit:inputs unit))
+      (gen-args (unit:outputs unit))
+      ")\n"))
+ )
  
! ; Return decls of all insn model handlers.
! 
! (define (gen-model-fn-decls model)
!   (string-list
!    "\n"
!    "// Function unit handlers\n"
!    "// To be overridden as needed.\n"
!    (string-list-map (lambda (unit)
! 		      (string-append
! 		       (gen-model-unit-fn-decl model unit 'before)
! 		       "    {\n"
! 		       "      return 0;\n"
! 		       "    }\n"
! 		       (gen-model-unit-fn-decl model unit 'after)
! 		       "    {\n"
! 		       "      return timing[idesc->sem_index].units[unit_num].done;\n"
! 		       "    }\n"))
! 		    (model:units model))
!   )
  )
  
  ; Return name of profile handler for INSN, MODEL.
  
! (define (-gen-model-insn-fn-name model insn when)
!   (string-append "model_" (gen-sym insn) "_" (symbol->string when))
! )
! 
! (define (-gen-model-insn-qualified-fn-name model insn when)
!   (string-append (gen-model-class-name model) "::" (-gen-model-insn-fn-name model insn when))
! )
! 
! ; Return declaration of function to model INSN.
! 
! (define (-gen-model-insn-fn-decl model insn when)
!   (string-list
!    "UINT "
!    (-gen-model-insn-fn-name model insn when)
!    " (@cpu at _cpu *current_cpu, @prefix at _scache *sem);\n"
!   )
! )
! 
! (define (-gen-model-insn-fn-decls model)
!   (string-list
!    "  // These methods call the appropriate unit modeller(s) for each insn.\n"
!    (string-list-map
!     (lambda (insn)
!       (string-list
!        "  " (-gen-model-insn-fn-decl model insn 'before)
!        "  " (-gen-model-insn-fn-decl model insn 'after)))
!     (non-multi-insns (real-insns (current-insn-list))))
!   )
  )
  
  ; Return function to model INSN.
  
! (define (-gen-model-insn-fn model insn when)
    (logit 2 "Processing modeling for " (obj:name insn) ": \"" (insn-syntax insn) "\" ...\n")
    (let ((sfmt (insn-sfmt insn)))
      (string-list
!      "UINT\n"
!      (-gen-model-insn-qualified-fn-name model insn when)
!      " (@cpu at _cpu *current_cpu, @prefix at _scache *sem)\n"
       "{\n"
       (if (with-scache?)
  	 (gen-define-field-macro sfmt)
  	 "")
!      "  const @prefix at _scache* abuf = sem;\n"
!      "  const @prefix at _idesc* idesc = abuf->idesc;\n"
       ; or: idesc = & CPU_IDESC (current_cpu) ["
       ; (gen-cpu-insn-enum (mach-cpu (model:mach model)) insn)
       ; "];\n"
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 145,151 ****
  	  (gen-extract-ifields (sfmt-iflds sfmt) (sfmt-length sfmt) "  " #f)
  	  (gen-sfmt-argvars-assigns sfmt)))
       ; Emit code to model the insn.  Function units are handled here.
!      (send insn 'gen-profile-code model "cycles")
       "  return cycles;\n"
       (if (with-scache?)
  	 (gen-undef-field-macro sfmt)
--- 186,192 ----
  	  (gen-extract-ifields (sfmt-iflds sfmt) (sfmt-length sfmt) "  " #f)
  	  (gen-sfmt-argvars-assigns sfmt)))
       ; Emit code to model the insn.  Function units are handled here.
!      (send insn 'gen-profile-code model when "cycles")
       "  return cycles;\n"
       (if (with-scache?)
  	 (gen-undef-field-macro sfmt)
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 153,158 ****
--- 194,200 ----
       "}\n\n"))
  )
  
+ 
  ; Return insn modeling handlers.
  ; ??? Might wish to reduce the amount of output by combining identical cases.
  ; ??? Modelling of insns could be table driven, but that puts constraints on
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 163,174 ****
     "/* Model handlers for each insn.  */\n\n"
     (lambda () (string-write-map
  	       (lambda (model)
  		 (string-write-map
! 		  (lambda (insn) (-gen-model-insn-fn model insn))
  		  (non-multi-insns (real-insns (current-insn-list)))))
  	       (current-model-list)))
     )
  )
  
  ; Generate timing table entry for function unit U while executing INSN.
  ; U is a <unit> object.
--- 205,328 ----
     "/* Model handlers for each insn.  */\n\n"
     (lambda () (string-write-map
  	       (lambda (model)
+ 		 (string-write
+ 		  ; Generate the model constructor.
+ 		  (gen-model-class-name model) "::" (gen-model-class-name model) " (@cpu at _cpu *cpu)\n"
+ 		  "  : cgen_model (cpu)\n"
+ 		  "{\n"
+ 		  "}\n"
+ 		  "\n")
  		 (string-write-map
! 		  (lambda (insn)
! 		    (string-list
! 		     (-gen-model-insn-fn model insn 'before)
! 		     (-gen-model-insn-fn model insn 'after)))
  		  (non-multi-insns (real-insns (current-insn-list)))))
  	       (current-model-list)))
     )
  )
+ 
+ (define (-gen-model-class-decls model)
+   (string-append
+    "\n"
+    "  "
+    (gen-enum-decl 'unit_number "unit types"
+ 		  "UNIT_"
+ 		  (cons '(none)
+ 			(append
+ 			 ; "apply append" squeezes out nils.
+ 			 (apply append
+ 				(list 
+ 				 ; create <model_name>-<unit-name> for each unit
+ 				 (let ((units (model:units model)))
+ 				   (if (null? units)
+ 				       nil
+ 				       (map (lambda (unit)
+ 					      (cons (obj:name unit)
+ 						    (cons '- (atlist-attrs (obj-atlist model)))))
+ 					    units)))))
+ 			 '((max)))))
+    "  struct unit {\n"
+    "    unit_number unit;\n"
+    "    UINT issue;\n"
+    "    UINT done;\n"
+    "  };\n\n"
+ 
+    ; FIXME: revisit MAX_UNITS
+   "  #define MAX_UNITS ("
+   (number->string
+    (let ((insn-list (non-multi-insns (real-insns (current-insn-list)))))
+      (if (null? insn-list)
+ 	 1
+ 	 (apply max
+ 		(map (lambda (lengths) (apply max lengths))
+ 		     (map (lambda (insn)
+ 			    (let ((timing (insn-timing insn)))
+ 			      (if (null? timing)
+ 				  '(1)
+ 				  (map (lambda (insn-timing)
+ 					 (length (timing:units (cdr insn-timing))))
+ 				       timing))))
+ 			  insn-list))))))
+    ")\n"
+   )
+ )
+ 
+ ; Return the C++ class representing the given model.
+ (define (gen-model-class model)
+   (string-list
+    "\
+ class " (gen-model-class-name model) " : public cgen_model
+ {
+ public:
+   " (gen-model-class-name model) " (@cpu at _cpu *cpu);
+ 
+   // Call the proper unit modelling function for the given insn.
+   UINT model_before (@cpu at _cpu *current_cpu, @prefix at _scache* sem)
+     {
+       return (this->*(timing[sem->idesc->sem_index].model_before)) (current_cpu, sem);
+     } 
+   UINT model_after (@cpu at _cpu *current_cpu, @prefix at _scache* sem)
+     {
+       return (this->*(timing[sem->idesc->sem_index].model_after)) (current_cpu, sem);
+     } 
+ "
+    (gen-model-fn-decls model)
+    "\
+ 
+ protected:
+ "
+    (-gen-model-insn-fn-decls model)
+    (-gen-model-class-decls model)
+ "\
+ 
+   typedef UINT (" (gen-model-class-name model) "::*model_function) (@cpu at _cpu* current_cpu, @prefix at _scache* sem);
+ 
+   struct insn_timing {
+     // This is an integer that identifies this insn.
+     UINT num;
+     // Functions to handle insn-specific profiling.
+     model_function model_before;
+     model_function model_after;
+     // Array of function units used by this insn.
+     unit units[MAX_UNITS];
+   };
+ 
+   static const insn_timing timing[];
+ };
+ "
+   )
+ )
+ 
+ ; Return the C++ classes representing the current list of models.
+ (define (gen-model-classes)
+    (string-list-map
+     (lambda (model)
+       (string-list
+        "\n"
+        (gen-model-class model)))
+     (current-model-list))
+ )
  
  ; Generate timing table entry for function unit U while executing INSN.
  ; U is a <unit> object.
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 177,183 ****
  (define (-gen-insn-unit-timing model insn u args)
    (string-append
     "{ "
!    "(int) " (unit:enum u) ", "
     (number->string (unit:issue u)) ", "
     (let ((cycles (assq-ref args 'cycles)))
       (if cycles
--- 331,337 ----
  (define (-gen-insn-unit-timing model insn u args)
    (string-append
     "{ "
!    (gen-model-class-name model) "::" (unit:enum u) ", "
     (number->string (unit:issue u)) ", "
     (let ((cycles (assq-ref args 'cycles)))
       (if cycles
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 198,205 ****
       (gen-cpu-insn-enum (mach-cpu (model:mach model)) insn)
       ", "
       (if (obj-has-attr? insn 'VIRTUAL)
! 	 "0"
! 	 (-gen-model-insn-fn-name model insn))
       ", { "
       (string-drop
        -2
--- 352,361 ----
       (gen-cpu-insn-enum (mach-cpu (model:mach model)) insn)
       ", "
       (if (obj-has-attr? insn 'VIRTUAL)
! 	 "0, 0"
! 	 (string-append
! 	  "& " (-gen-model-insn-qualified-fn-name model insn 'before) ", "
! 	  "& " (-gen-model-insn-qualified-fn-name model insn 'after)))
       ", { "
       (string-drop
        -2
*************** static const MACH_IMP_PROPERTIES @cpu at _i
*** 220,226 ****
  (define (-gen-model-timing-table model)
    (string-write
     "/* Model timing data for `" (obj:name model) "'.  */\n\n"
!    "static const @PREFIX at _INSN_TIMING " (gen-sym model) "_timing[] = {\n"
     (lambda () (string-write-map (lambda (insn) (-gen-insn-timing model insn))
  				(non-multi-insns (non-alias-insns (current-insn-list)))))
     "};\n\n"
--- 376,382 ----
  (define (-gen-model-timing-table model)
    (string-write
     "/* Model timing data for `" (obj:name model) "'.  */\n\n"
!    "const " (gen-model-class-name model) "::insn_timing " (gen-model-class-name model) "::timing[] = {\n"
     (lambda () (string-write-map (lambda (insn) (-gen-insn-timing model insn))
  				(non-multi-insns (non-alias-insns (current-insn-list)))))
     "};\n\n"
*************** const MACH " (gen-sym mach) "_mach =
*** 340,362 ****
  		  copyright-red-hat package-red-hat-simulators)
     "\
  
! #include \"@arch at -main dot h\"
  
  using namespace @cpu@; // FIXME: namespace organization still wip
  
  /* The profiling data is recorded here, but is accessed via the profiling
     mechanism.  After all, this is information for profiling.  */
  
- #if WITH_PROFILE_MODEL_P
- 
  "
     -gen-model-insn-fns
     -gen-model-profile-data
! "#endif /* WITH_PROFILE_MODEL_P */\n\n"
! 
!    -gen-model-defns
!    -gen-cpu-imp-properties
!    -gen-cpu-defns
!    -gen-mach-defns
     )
  )
--- 496,543 ----
  		  copyright-red-hat package-red-hat-simulators)
     "\
  
! #include \"@cpu at  dot h\"
  
  using namespace @cpu@; // FIXME: namespace organization still wip
  
  /* The profiling data is recorded here, but is accessed via the profiling
     mechanism.  After all, this is information for profiling.  */
  
  "
     -gen-model-insn-fns
     -gen-model-profile-data
! ;  not adapted for sid yet
! ;   -gen-model-defns
! ;   -gen-cpu-imp-properties
! ;   -gen-cpu-defns
! ;   -gen-mach-defns
     )
+ )
+ 
+ (define (cgen-model.h)
+   (logit 1 "Generating " (gen-cpu-name) " model.h ...\n")
+   (assert-keep-one)
+ 
+   (string-write
+    (gen-copyright "Simulator model support for @prefix at  dot "
+ 		  copyright-red-hat package-red-hat-simulators)
+    "\
+ #ifndef @PREFIX at _MODEL_H
+ #define @PREFIX at _MODEL_H
+ 
+ #include \"cgen-cpu.h\"
+ #include \"cgen-model.h\"
+ 
+ namespace @cpu@
+ {
+ using namespace cgen;
+ "
+    (gen-model-classes)
+    "\
+ 
+ } // namespace @cpu@
+ 
+ #endif // @PREFIX at _MODEL_H
+ "
+   )
  )
Index: cgen/sid.scm
===================================================================
RCS file: /cvs/src/src/cgen/sid.scm,v
retrieving revision 1.8
diff -c -p -r1.8 sid.scm
*** cgen/sid.scm	12 Mar 2003 17:17:14 -0000	1.8
--- cgen/sid.scm	31 Mar 2003 19:41:47 -0000
***************
*** 1,5 ****
  ; Simulator generator support routines.
! ; Copyright (C) 2000, 2002 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; One goal of this file is to provide cover functions for all methods.
--- 1,5 ----
  ; Simulator generator support routines.
! ; Copyright (C) 2000, 2002, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; One goal of this file is to provide cover functions for all methods.
***************
*** 1281,1291 ****
  
  (method-make!
   <operand> 'gen-profile-code
!  (lambda (self insn out?)
     (string-append "  "
  		  "@prefix at _model_mark_"
  		  (if out? "set_" "get_")
  		  (gen-sym (op:type self))
  		  " (current_cpu"
  		  (if (hw-scalar? (op:type self))
  		      ""
--- 1281,1292 ----
  
  (method-make!
   <operand> 'gen-profile-code
!  (lambda (self insn when out?)
     (string-append "  "
  		  "@prefix at _model_mark_"
  		  (if out? "set_" "get_")
  		  (gen-sym (op:type self))
+ 		  "_" when
  		  " (current_cpu"
  		  (if (hw-scalar? (op:type self))
  		      ""
***************
*** 1376,1414 ****
  			       (current-model-list))
  			  '((max))))
     "#define MAX_MODELS ((int) MODEL_MAX)\n\n"
!    (gen-enum-decl 'unit_type "unit types"
! 		  "UNIT_"
! 		  (cons '(none)
! 			(append
! 			 ; "apply append" squeezes out nils.
! 			 (apply append
! 				; create <model_name>-<unit-name> for each unit
! 				(map (lambda (model)
! 				       (let ((units (model:units model)))
! 					 (if (null? units)
! 					     nil
! 					     (map (lambda (unit)
! 						    (cons (symbol-append (obj:name model) '-
! 									 (obj:name unit))
! 							  (cons '- (atlist-attrs (obj-atlist model)))))
! 						  units))))
! 				     (current-model-list)))
! 			 '((max)))))
!    ; FIXME: revisit MAX_UNITS
!    "#define MAX_UNITS ("
!    (number->string
!     (apply max
! 	   (map (lambda (lengths) (apply max lengths))
! 		(map (lambda (insn)
! 		       (let ((timing (insn-timing insn)))
! 			 (if (null? timing)
! 			     '(1)
! 			     (map (lambda (insn-timing)
! 				    (length (timing:units (cdr insn-timing))))
! 				  timing))))
! 		     (non-multi-insns (real-insns (current-insn-list)))))))
!    ")\n\n"
!    )
  )
  
  ; Function units.
--- 1377,1383 ----
  			       (current-model-list))
  			  '((max))))
     "#define MAX_MODELS ((int) MODEL_MAX)\n\n"
!   )
  )
  
  ; Function units.
***************
*** 1451,1457 ****
  
  (method-make!
   <unit> 'gen-profile-code
!  (lambda (self unit-num insn overrides cycles-var-name)
     (let (
  	 (inputs (unit:inputs self))
  	 (outputs (unit:outputs self))
--- 1420,1427 ----
  
  (method-make!
   <unit> 'gen-profile-code
!  (lambda (self unit-num insn when overrides cycles-var-name)
!    (logit 3 "  'gen-profile-code\n")
     (let (
  	 (inputs (unit:inputs self))
  	 (outputs (unit:outputs self))
***************
*** 1463,1468 ****
--- 1433,1439 ----
  	  ; UNIT-REFERENCED-VAR.
  	  ; ??? For now we assume all input operands are read.
  	  (gen-ref-arg (lambda (arg num in-out)
+ 			 (logit 3 "    gen-ref-arg\n")
  			 (let* ((op-name (assq-ref overrides (car arg)))
  				(op (insn-op-lookup (if op-name
  							(car op-name)
***************
*** 1492,1497 ****
--- 1463,1469 ----
  	  ; Initialize unit argument ARG.
  	  ; OUT? is #f for input args, #t for output args.
  	  (gen-arg-init (lambda (arg out?)
+ 			 (logit 3 "    gen-arg-unit\n")
  			  (if (or
  			       ; Ignore scalars.
  			       (null? (cdr arg))
***************
*** 1513,1518 ****
--- 1485,1491 ----
  	  ; Return C code to declare variable to hold unit argument ARG.
  	  ; OUT? is #f for input args, #t for output args.
  	  (gen-arg-decl (lambda (arg out?)
+ 			 (logit 3 "    gen-arg-decl " arg out? "\n")
  			  (if (null? (cdr arg)) ; ignore scalars
  			      ""
  			      (string-append "    "
***************
*** 1529,1534 ****
--- 1502,1508 ----
  	  ; Return C code to pass unit argument ARG to the handler.
  	  ; OUT? is #f for input args, #t for output args.
  	  (gen-arg-arg (lambda (arg out?)
+ 			 (logit 3 "    gen-arg-arg\n")
  			 (if (null? (cdr arg)) ; ignore scalars
  			     ""
  			     (string-append ", "
***************
*** 1538,1545 ****
  
       (string-append
        "  {\n"
!       "    int referenced = 0;\n"
!       "    unsigned long long UNUSED insn_referenced = abuf->written;\n"
        ; Declare variables to hold unit arguments.
        (string-map (lambda (arg) (gen-arg-decl arg #f))
  		  inputs)
--- 1512,1522 ----
  
       (string-append
        "  {\n"
!       (if (equal? when 'after)
! 	  (string-append
! 	   "    int referenced = 0;\n"
! 	   "    unsigned long long insn_referenced = abuf->written;\n")
! 	  "")
        ; Declare variables to hold unit arguments.
        (string-map (lambda (arg) (gen-arg-decl arg #f))
  		  inputs)
***************
*** 1596,1614 ****
  				    "invalid spec" arg))))
  		  overrides)
        ; Create bitmask indicating which args were referenced.
!       (string-map (lambda (arg num) (gen-ref-arg arg num 'in))
! 		  inputs
! 		  (iota (length inputs)))
!       (string-map (lambda (arg num) (gen-ref-arg arg num 'out))
! 		  outputs
! 		  (iota (length inputs)
! 			(length outputs)))
        ; Emit the call to the handler.
        "    " cycles-var-name " += "
!       (gen-model-unit-fn-name (unit:model self) self)
!       " (current_cpu, abuf->idesc"
        ", " (number->string unit-num)
!       ", referenced"
        (string-map (lambda (arg) (gen-arg-arg arg #f))
  		  inputs)
        (string-map (lambda (arg) (gen-arg-arg arg #t))
--- 1573,1594 ----
  				    "invalid spec" arg))))
  		  overrides)
        ; Create bitmask indicating which args were referenced.
!       (if (equal? when 'after)
! 	  (string-append
! 	   (string-map (lambda (arg num) (gen-ref-arg arg num 'in))
! 		       inputs
! 		       (iota (length inputs)))
! 	   (string-map (lambda (arg num) (gen-ref-arg arg num 'out))
! 		       outputs
! 		       (iota (length inputs)
! 			     (length outputs))))
! 	  "")
        ; Emit the call to the handler.
        "    " cycles-var-name " += "
!       (gen-model-unit-fn-name (unit:model self) self when)
!       " (current_cpu, idesc"
        ", " (number->string unit-num)
!       (if (equal? when 'after) ", referenced" "")
        (string-map (lambda (arg) (gen-arg-arg arg #f))
  		  inputs)
        (string-map (lambda (arg) (gen-arg-arg arg #t))
***************
*** 1623,1632 ****
  
  (method-make!
   <iunit> 'gen-profile-code
!  (lambda (self unit-num insn cycles-var-name)
     (let ((args (iunit:args self))
  	 (unit (iunit:unit self)))
!      (send unit 'gen-profile-code unit-num insn args cycles-var-name)))
  )
  
  ; Mode support.
--- 1603,1612 ----
  
  (method-make!
   <iunit> 'gen-profile-code
!  (lambda (self unit-num insn when cycles-var-name)
     (let ((args (iunit:args self))
  	 (unit (iunit:unit self)))
!      (send unit 'gen-profile-code unit-num insn when args cycles-var-name)))
  )
  
  ; Mode support.
***************
*** 1665,1679 ****
  
  (method-make!
   <insn> 'gen-profile-code
!  (lambda (self model cycles-var-name)
     (string-append
      (let ((timing (assq-ref (insn-timing self) (obj:name model))))
        (if timing
  	  (string-map (lambda (iunit unit-num)
! 			(send iunit 'gen-profile-code unit-num self cycles-var-name))
  		      (timing:units timing)
  		      (iota (length (timing:units timing))))
! 	  (send (model-default-unit model) 'gen-profile-code 0 self nil cycles-var-name)))
      ))
  )
  
--- 1645,1659 ----
  
  (method-make!
   <insn> 'gen-profile-code
!  (lambda (self model when cycles-var-name)
     (string-append
      (let ((timing (assq-ref (insn-timing self) (obj:name model))))
        (if timing
  	  (string-map (lambda (iunit unit-num)
! 			(send iunit 'gen-profile-code unit-num self when cycles-var-name))
  		      (timing:units timing)
  		      (iota (length (timing:units timing))))
! 	  (send (model-default-unit model) 'gen-profile-code 0 self when nil cycles-var-name)))
      ))
  )
  
Index: cgen/sim-model.scm
===================================================================
RCS file: /cvs/src/src/cgen/sim-model.scm,v
retrieving revision 1.3
diff -c -p -r1.3 sim-model.scm
*** cgen/sim-model.scm	20 Dec 2002 02:22:22 -0000	1.3
--- cgen/sim-model.scm	31 Mar 2003 19:41:47 -0000
***************
*** 1,8 ****
  ; Simulator model support, plus misc. things associated with a cpu family.
! ; Copyright (C) 2000 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; Return C code to define cpu implementation properties.
  
  (define (-gen-cpu-imp-properties)
    (string-list
--- 1,15 ----
  ; Simulator model support, plus misc. things associated with a cpu family.
! ; Copyright (C) 2000, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  
  ; Return C code to define cpu implementation properties.
+ 
+ (define (unit:enum u)
+   (gen-c-symbol (string-append "UNIT_"
+ 			       (string-upcase (obj:name (unit:model u)))
+ 			       "_"
+ 			       (string-upcase (obj:name u))))
+ )
  
  (define (-gen-cpu-imp-properties)
    (string-list
Index: cgen/utils.scm
===================================================================
RCS file: /cvs/src/src/cgen/utils.scm,v
retrieving revision 1.7
diff -c -p -r1.7 utils.scm
*** cgen/utils.scm	7 Jan 2002 08:23:59 -0000	1.7
--- cgen/utils.scm	31 Mar 2003 19:41:48 -0000
***************
*** 1,5 ****
  ; Generic Utilities.
! ; Copyright (C) 2000, 2002 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
--- 1,5 ----
  ; Generic Utilities.
! ; Copyright (C) 2000, 2002, 2003 Red Hat, Inc.
  ; This file is part of CGEN.
  ; See file COPYING.CGEN for details.
  
***************
*** 1141,1147 ****
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  "
  	"\
  This program is free software; you can redistribute it and/or modify
--- 1141,1147 ----
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
  "
  	"\
  This program is free software; you can redistribute it and/or modify
*************** with this program; if not, write to the 
*** 1166,1172 ****
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
  "
  	"\
  "))
--- 1166,1172 ----
    (cons "\
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.
  "
  	"\
  "))
Index: cgen/doc/rtl.texi
===================================================================
RCS file: /cvs/src/src/cgen/doc/rtl.texi,v
retrieving revision 1.17
diff -c -p -r1.17 rtl.texi
*** cgen/doc/rtl.texi	22 Dec 2002 04:49:26 -0000	1.17
--- cgen/doc/rtl.texi	31 Mar 2003 19:41:49 -0000
***************
*** 1,4 ****
! @c Copyright (C) 2000 Red Hat, Inc.
  @c This file is part of the CGEN manual.
  @c For copying conditions, see the file cgen.texi.
  
--- 1,4 ----
! @c Copyright (C) 2000, 2003 Red Hat, Inc.
  @c This file is part of the CGEN manual.
  @c For copying conditions, see the file cgen.texi.
  
*************** that supports the instruction.  The defa
*** 1892,1901 ****
  The syntax is:
  
  @example
! (mach-name (unit name (direction unit-var-name1 insn-operand-name1)
!                       (direction unit-var-name2 insn-operand-name2)
!                       ...
!                       (cycles cycle-count))
  @end example
  
  direction/unit-var-name/insn-operand-name mappings are optional.
--- 1892,1901 ----
  The syntax is:
  
  @example
! (model-name (unit name (direction unit-var-name1 insn-operand-name1)
!                        (direction unit-var-name2 insn-operand-name2)
!                        ...
!                        (cycles cycle-count))
  @end example
  
  direction/unit-var-name/insn-operand-name mappings are optional.
? sid/component/cgen-cpu/cgen-model.h
? sid/component/cgen-cpu/xstormy16/xstormy16-model.cxx
? sid/component/cgen-cpu/xstormy16/xstormy16-model.h
Index: sid/component/cgen-cpu/CGEN.sh.in
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/CGEN.sh.in,v
retrieving revision 1.2
diff -c -p -r1.2 CGEN.sh.in
*** sid/component/cgen-cpu/CGEN.sh.in	20 Sep 2002 01:00:28 -0000	1.2
--- sid/component/cgen-cpu/CGEN.sh.in	31 Mar 2003 19:42:03 -0000
***************
*** 13,18 ****
--- 13,20 ----
  #	defs.h             - generate defs.h file (cpu-family specific decls)
  #	decode.h           - generate decoder header file
  #	decode.cxx         - generate decoder
+ #	model.h            - generate model header file
+ #	model.cxx          - generate model
  #	semantics.cxx      - generate semantics
  #	sem-switch.cxx     - generate semantics, pbb switch version
  #
*************** do
*** 83,88 ****
--- 85,92 ----
      defs.h) fileopts="$fileopts -E tmp-defs-$$.h1" ;;
      decode.h) fileopts="$fileopts -T tmp-dec-$$.h1" ;;
      decode.cxx) fileopts="$fileopts -D tmp-dec-$$.cxx1" ;;
+     model.h) fileopts="$fileopts -N tmp-mod-$$.h1" ;;
+     model.cxx) fileopts="$fileopts -M tmp-mod-$$.cxx1" ;;
      semantics.cxx) fileopts="$fileopts -S tmp-sem-$$.cxx1" ;;
      sem-switch.cxx) fileopts="$fileopts -X tmp-semsw-$$.cxx1" ;;
      write.cxx) fileopts="$fileopts -W tmp-write-$$.cxx1" ;;
*************** do
*** 141,146 ****
--- 145,164 ----
  	    < tmp-dec-$$.cxx1 > tmp-dec-$$.cxx
  	${rootdir}/move-if-change tmp-dec-$$.cxx ${srcdir}/${fileprefix}decode.cxx
  	;;
+     model.h)
+ 	sed -e "s= at ARCH@=${ARCH}=g" -e "s= at arch@=${arch}=g" \
+ 	    -e "s= at CPU@=${CPU}=g" -e "s= at cpu@=${cpu}=g" \
+ 	    -e "s= at PREFIX@=${PREFIX}=g" -e "s=@"prefix"@=${prefix}=g" \
+ 	    < tmp-mod-$$.h1 > tmp-mod-$$.h
+ 	${rootdir}/move-if-change tmp-mod-$$.h ${srcdir}/${fileprefix}model.h
+ 	;;
+     model.cxx)
+ 	sed -e "s= at ARCH@=${ARCH}=g" -e "s= at arch@=${arch}=g" \
+ 	    -e "s= at CPU@=${CPU}=g" -e "s= at cpu@=${cpu}=g" \
+ 	    -e "s= at PREFIX@=${PREFIX}=g" -e "s=@"prefix"@=${prefix}=g" \
+ 	    < tmp-mod-$$.cxx1 > tmp-mod-$$.cxx
+ 	${rootdir}/move-if-change tmp-mod-$$.cxx ${srcdir}/${fileprefix}model.cxx
+ 	;;
      semantics.cxx)
  	sed -e "s= at ARCH@=${ARCH}=g" -e "s= at arch@=${arch}=g" \
  	    -e "s= at CPU@=${CPU}=g" -e "s= at cpu@=${cpu}=g" \
*************** rm -f tmp-semsw-$$.cxx1 tmp-semsw-$$.cxx
*** 173,177 ****
--- 191,197 ----
  rm -f tmp-write-$$.cxx1 tmp-write-$$.cxx
  rm -f tmp-dec-$$.h1 tmp-dec-$$.h
  rm -f tmp-dec-$$.cxx1 tmp-dec-$$.cxx
+ rm -f tmp-mod-$$.h1 tmp-mod-$$.h
+ rm -f tmp-mod-$$.cxx1 tmp-mod-$$.cxx
  
  exit 0
Index: sid/component/cgen-cpu/common-xml/interface.xml
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/common-xml/interface.xml,v
retrieving revision 1.5
diff -c -p -r1.5 interface.xml
*** sid/component/cgen-cpu/common-xml/interface.xml	29 Nov 2002 06:05:57 -0000	1.5
--- sid/component/cgen-cpu/common-xml/interface.xml	31 Mar 2003 19:42:03 -0000
***************
*** 28,33 ****
--- 28,35 ----
      <defattribute name="trace-extract?" category="setting" legalvalues="boolean" defaultvalue="false" behaviors="tracing" />
      <defattribute name="trace-filename" category="setting" legalvalues="string" defaultvalue="-" behaviors="tracing" />
      <defattribute name="trace-result?" category="setting" legalvalues="boolean" defaultvalue="false" behaviors="tracing" />
+     <defattribute name="trace-counter?" category="setting" legalvalues="boolean" defaultvalue="false" behaviors="tracing" />
+     <defattribute name="final-insn-count?" category="setting" legalvalues="boolean" defaultvalue="false" behaviors="tracing" />
      <defattribute name="engine-type" category="setting" legalvalues="scache or pbb" defaultvalue="pbb" behaviors="execution" />
      <defattribute name="insn-count" category="watchable register" legalvalues="number" behaviors="execution" />
      <defattribute name="step-insn-count" category="setting" legalvalues="number" defaultvalue="1" behaviors="execution" />
Index: sid/include/sidcpuutil.h
===================================================================
RCS file: /cvs/src/src/sid/include/sidcpuutil.h,v
retrieving revision 1.24
diff -c -p -r1.24 sidcpuutil.h
*** sid/include/sidcpuutil.h	15 Jan 2003 20:03:34 -0000	1.24
--- sid/include/sidcpuutil.h	31 Mar 2003 19:42:06 -0000
*************** namespace sidutil
*** 239,244 ****
--- 239,245 ----
      bool trace_disass_p;
      bool trace_semantics_p;
      bool trace_counter_p;
+     bool final_insn_count_p;
      bool enable_step_trap_p;
      cpu_trace_stream trace_stream;
  
*************** namespace sidutil
*** 307,312 ****
--- 308,316 ----
  	}
      }
  
+   public:
+     void update_total_latency (sid::host_int_8 latency) { this->total_latency += latency; }
+ 
    protected:
      virtual sid::host_int_8 latency_to_cycles (sid::host_int_8 num)
      {
*************** namespace sidutil
*** 417,422 ****
--- 421,427 ----
  	  << " " << this->trace_disass_p
  	  << " " << this->trace_semantics_p
  	  << " " << this->trace_counter_p
+ 	  << " " << this->final_insn_count_p
  	  // pins
  	  << " " << this->step_cycles_pin
  	  << " " << this->trap_type_pin
*************** namespace sidutil
*** 441,446 ****
--- 446,452 ----
  	  >> this->trace_disass_p
  	  >> this->trace_semantics_p
  	  >> this->trace_counter_p
+ 	  >> this->final_insn_count_p
  	  // pins
  	  >> this->step_cycles_pin
  	  >> this->trap_type_pin
*************** public:
*** 582,587 ****
--- 588,595 ----
  	add_attribute ("trace-result?", & this->trace_result_p, "setting");
  	this->trace_counter_p = false;
  	add_attribute ("trace-counter?", & this->trace_counter_p, "setting");
+ 	this->final_insn_count_p = false;
+ 	add_attribute ("final-insn-count?", & this->final_insn_count_p, "setting");
        }
  
      virtual ~basic_cpu() throw() {}
Index: sid/main/dynamic/commonCfg.cxx
===================================================================
RCS file: /cvs/src/src/sid/main/dynamic/commonCfg.cxx,v
retrieving revision 1.2
diff -c -p -r1.2 commonCfg.cxx
*** sid/main/dynamic/commonCfg.cxx	31 Jan 2003 16:48:03 -0000	1.2
--- sid/main/dynamic/commonCfg.cxx	31 Mar 2003 19:42:06 -0000
*************** void BoardCfg::final_insn_count ()
*** 1004,1009 ****
--- 1004,1010 ----
    assert (cpu);
    assert (sess->shutdown_seq);
    sess->shutdown_seq->add_output (0, cpu, "print-insn-summary!");
+   cpu->set (cpu, "final-insn-count?", "true");
  }
  
  void BoardCfg::trace_counter ()
Index: cgen/cpu/xstormy16.cpu
===================================================================
RCS file: /cvs/src/src/cgen/cpu/xstormy16.cpu,v
retrieving revision 1.8
diff -c -p -r1.8 xstormy16.cpu
*** cgen/cpu/xstormy16.cpu	21 Mar 2003 06:15:55 -0000	1.8
--- cgen/cpu/xstormy16.cpu	31 Mar 2003 19:41:48 -0000
***************
*** 41,46 ****
--- 41,47 ----
  
  (define-model
    (name xstormy16)
+   (mach xstormy16)
    (comment "Xstormy16 CPU core")
    (unit u-exec "Execution Unit" ()
  	1 1 ; issue done
Index: sid/component/cgen-cpu/xstormy16/Makefile.am
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/xstormy16/Makefile.am,v
retrieving revision 1.1
diff -c -p -r1.1 Makefile.am
*** sid/component/cgen-cpu/xstormy16/Makefile.am	17 Dec 2001 09:31:20 -0000	1.1
--- sid/component/cgen-cpu/xstormy16/Makefile.am	31 Mar 2003 20:29:59 -0000
*************** CXXFLAGS = $(TOP_CXXFLAGS)
*** 11,17 ****
  
  pkgdata_DATA = hw-cpu-xstormy16.txt
  
! libxstormy16_la_SOURCES = xstormy16.cxx xstormy16-decode.cxx xstormy16-sem.cxx
  libxstormy16_la_LDFLAGS =
  libxstormy16_la_LIBADD = xstormy16-asm.lo xstormy16-dis.lo xstormy16-opc.lo xstormy16-ibld.lo xstormy16-desc.lo
  
--- 11,17 ----
  
  pkgdata_DATA = hw-cpu-xstormy16.txt
  
! libxstormy16_la_SOURCES = xstormy16.cxx xstormy16-decode.cxx xstormy16-sem.cxx xstormy16-model.cxx
  libxstormy16_la_LDFLAGS =
  libxstormy16_la_LIBADD = xstormy16-asm.lo xstormy16-dis.lo xstormy16-opc.lo xstormy16-ibld.lo xstormy16-desc.lo
  
*************** cgen-all: $(CGEN_ALL)
*** 51,55 ****
  
  cgen-xstormy16:
  	$(SHELL) ../CGEN.sh cpu-decode $(srcdir) $(cgendir) "$(CGENFLAGS)" \
! 	xstormy16 "with-scache" xstormy16 xstormy16 xstormy16 xstormy16 "xstormy16-" \
! 	"desc.h cpu.h defs.h decode.h decode.cxx write.cxx semantics.cxx"
--- 51,55 ----
  
  cgen-xstormy16:
  	$(SHELL) ../CGEN.sh cpu-decode $(srcdir) $(cgendir) "$(CGENFLAGS)" \
! 	xstormy16 "with-scache with-profile=fn" xstormy16 xstormy16 xstormy16 xstormy16 "xstormy16-" \
! 	"desc.h cpu.h defs.h decode.h decode.cxx model.h model.cxx write.cxx semantics.cxx"
Index: sid/component/cgen-cpu/xstormy16/xstormy16.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/xstormy16/xstormy16.cxx,v
retrieving revision 1.3
diff -c -p -r1.3 xstormy16.cxx
*** sid/component/cgen-cpu/xstormy16/xstormy16.cxx	18 Feb 2003 22:57:29 -0000	1.3
--- sid/component/cgen-cpu/xstormy16/xstormy16.cxx	31 Mar 2003 20:30:00 -0000
*************** using namespace sidutil;
*** 19,25 ****
  using namespace xstormy16;
  
  xstormy16_cpu::xstormy16_cpu ()
!   :engine (32768) // XXX: tune size
  {
    for (unsigned i = 0; i < 16; ++i)
      {
--- 19,26 ----
  using namespace xstormy16;
  
  xstormy16_cpu::xstormy16_cpu ()
!   :engine (32768), // XXX: tune size
!    model (this)
  {
    for (unsigned i = 0; i < 16; ++i)
      {
*************** xstormy16_cpu::step_insns ()
*** 172,177 ****
--- 173,183 ----
                                 bfd_arch_xstormy16,
                                 BFD_ENDIAN_LITTLE, "xstormy16");
  	}
+       if (UNLIKELY (trace_counter_p || final_insn_count_p))
+ 	{
+ 	  this->model.model_insn_before (true);
+ 	  this->model.model_before (this, sem);
+ 	  }
        try
  	{
  	  sem->idesc->execute (this, sem);
*************** xstormy16_cpu::step_insns ()
*** 184,189 ****
--- 190,200 ----
        catch (cpu_exception& t)
  	{
  	  this->yield ();
+ 	}
+       if (UNLIKELY (trace_counter_p || final_insn_count_p))
+ 	{
+ 	  sid::host_int_4 cycles = this->model.model_after (this, sem);
+ 	  this->model.model_insn_after (true, cycles);
  	}
        if (trace_result_p)
  	this->end_trace ();
Index: sid/component/cgen-cpu/xstormy16/xstormy16.h
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/xstormy16/xstormy16.h,v
retrieving revision 1.2
diff -c -p -r1.2 xstormy16.h
*** sid/component/cgen-cpu/xstormy16/xstormy16.h	11 Jan 2002 07:25:03 -0000	1.2
--- sid/component/cgen-cpu/xstormy16/xstormy16.h	31 Mar 2003 20:30:00 -0000
***************
*** 8,13 ****
--- 8,14 ----
  #include "xstormy16-desc.h"
  #include "xstormy16-defs.h"
  #include "xstormy16-decode.h"
+ #include "xstormy16-model.h"
  
  namespace xstormy16
  {
*************** namespace xstormy16
*** 23,35 ****
  	}
      protected:
        USI syscall_trap_num;
- 
      };
  
    class xstormy16_cpu: public xstormy16_cpu_cgen, public cgen_bi_endian_cpu
      {
      private:
        scache_engine<xstormy16_scache> engine;
  
        void step_insns ();
        void flush_icache ();
--- 24,36 ----
  	}
      protected:
        USI syscall_trap_num;
      };
  
    class xstormy16_cpu: public xstormy16_cpu_cgen, public cgen_bi_endian_cpu
      {
      private:
        scache_engine<xstormy16_scache> engine;
+       xstormy16_xstormy16_model model;
  
        void step_insns ();
        void flush_icache ();
Index: sid/component/cgen-cpu/xstormy16/xstormy16-decode.h
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/xstormy16/xstormy16-decode.h,v
retrieving revision 1.3
diff -c -p -r1.3 xstormy16-decode.h
*** sid/component/cgen-cpu/xstormy16/xstormy16-decode.h	21 Mar 2003 06:16:29 -0000	1.3
--- sid/component/cgen-cpu/xstormy16/xstormy16-decode.h	31 Mar 2003 19:42:04 -0000
***************
*** 2,8 ****
  
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
  
  This file is part of the Red Hat simulators.
  
--- 2,8 ----
  
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.
  
  This file is part of the Red Hat simulators.
  
*************** struct xstormy16_scache {
*** 208,213 ****
--- 208,218 ----
    // argument buffer
    xstormy16_sem_fields fields;
  
+ 
+   // writeback flags
+   // Only used if profiling or parallel execution support enabled during
+   // file generation.
+   unsigned long long written;
  
  
    // decode given instruction
Index: sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx,v
retrieving revision 1.5
diff -c -p -r1.5 xstormy16-sem.cxx
*** sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx	21 Mar 2003 06:16:29 -0000	1.5
--- sid/component/cgen-cpu/xstormy16/xstormy16-sem.cxx	31 Mar 2003 19:42:06 -0000
***************
*** 2,8 ****
  
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
  
  This file is part of the Red Hat simulators.
  
--- 2,8 ----
  
  THIS FILE IS MACHINE GENERATED WITH CGEN.
  
! Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.
  
  This file is part of the Red Hat simulators.
  
*************** xstormy16_sem_x_invalid (xstormy16_cpu* 
*** 25,30 ****
--- 25,31 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 0;
  
*************** xstormy16_sem_movlmemimm (xstormy16_cpu*
*** 47,52 ****
--- 48,54 ----
  #define FLD(f) abuf->fields.sfmt_movlmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 57,68 ****
--- 59,72 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      HI opval = tmp_nvalue;
      current_cpu->SETMEMHI (pc, ANDSI (FLD (f_lmem8), 65534), opval);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (FLD (f_lmem8), 65534) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 74,91 ****
--- 78,98 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      QI opval = tmp_nvalue;
      current_cpu->SETMEMQI (pc, FLD (f_lmem8), opval);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) FLD (f_lmem8) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movhmemimm (xstormy16_cpu*
*** 99,104 ****
--- 106,112 ----
  #define FLD(f) abuf->fields.sfmt_movhmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 109,120 ****
--- 117,130 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      HI opval = tmp_nvalue;
      current_cpu->SETMEMHI (pc, ANDSI (FLD (f_hmem8), 65534), opval);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (FLD (f_hmem8), 65534) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 126,143 ****
--- 136,156 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      QI opval = tmp_nvalue;
      current_cpu->SETMEMQI (pc, FLD (f_hmem8), opval);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) FLD (f_hmem8) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movlgrmem (xstormy16_cpu* 
*** 151,156 ****
--- 164,170 ----
  #define FLD(f) abuf->fields.sfmt_movlgrmem.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 161,172 ****
--- 175,188 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rm), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 178,195 ****
--- 194,214 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rm), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movhgrmem (xstormy16_cpu* 
*** 203,208 ****
--- 222,228 ----
  #define FLD(f) abuf->fields.sfmt_movhgrmem.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 213,224 ****
--- 233,246 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rm), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 230,247 ****
--- 252,272 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rm), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movlmemgr (xstormy16_cpu* 
*** 255,260 ****
--- 280,286 ----
  #define FLD(f) abuf->fields.sfmt_movlgrmem.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 265,276 ****
--- 291,304 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      HI opval = tmp_nvalue;
      current_cpu->SETMEMHI (pc, ANDSI (FLD (f_lmem8), 65534), opval);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (FLD (f_lmem8), 65534) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 282,299 ****
--- 310,330 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      QI opval = tmp_nvalue;
      current_cpu->SETMEMQI (pc, FLD (f_lmem8), opval);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) FLD (f_lmem8) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movhmemgr (xstormy16_cpu* 
*** 307,312 ****
--- 338,344 ----
  #define FLD(f) abuf->fields.sfmt_movlgrmem.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 317,328 ****
--- 349,362 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      HI opval = tmp_nvalue;
      current_cpu->SETMEMHI (pc, ANDSI (FLD (f_lmem8), 65534), opval);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (FLD (f_lmem8), 65534) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 334,351 ****
--- 368,388 ----
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 65436), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      QI opval = tmp_nvalue;
      current_cpu->SETMEMQI (pc, FLD (f_lmem8), opval);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) FLD (f_lmem8) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrgri (xstormy16_cpu* c
*** 359,364 ****
--- 396,402 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 369,380 ****
--- 407,420 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 386,403 ****
--- 426,446 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrgripostinc (xstormy16
*** 411,416 ****
--- 454,460 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 422,433 ****
--- 466,479 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 439,450 ****
--- 485,498 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 458,463 ****
--- 506,512 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrgripredec (xstormy16_
*** 471,476 ****
--- 520,526 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 488,499 ****
--- 538,551 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 505,516 ****
--- 557,570 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 518,523 ****
--- 572,578 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrigr (xstormy16_cpu* c
*** 531,536 ****
--- 586,592 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 551,556 ****
--- 607,613 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 559,564 ****
--- 616,622 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, current_cpu->h_gr_get (FLD (f_Rs)), opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_gr_get (FLD (f_Rs)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 575,580 ****
--- 633,639 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgripostincgr (xstormy16
*** 588,593 ****
--- 647,653 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 608,613 ****
--- 668,674 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 616,621 ****
--- 677,683 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, current_cpu->h_gr_get (FLD (f_Rs)), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_gr_get (FLD (f_Rs)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 638,643 ****
--- 700,706 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgripredecgr (xstormy16_
*** 651,656 ****
--- 714,720 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 687,692 ****
--- 751,757 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 695,706 ****
--- 760,773 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, current_cpu->h_gr_get (FLD (f_Rs)), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) current_cpu->h_gr_get (FLD (f_Rs)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrgrii (xstormy16_cpu* 
*** 714,719 ****
--- 781,787 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 724,735 ****
--- 792,805 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 741,758 ****
--- 811,831 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrgriipostinc (xstormy1
*** 766,771 ****
--- 839,845 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 777,788 ****
--- 851,864 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 794,805 ****
--- 870,883 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 813,818 ****
--- 891,897 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrgriipredec (xstormy16
*** 826,831 ****
--- 905,911 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 843,854 ****
--- 923,936 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 860,871 ****
--- 942,955 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 873,878 ****
--- 957,963 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgriigr (xstormy16_cpu* 
*** 886,891 ****
--- 971,977 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 906,911 ****
--- 992,998 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 914,919 ****
--- 1001,1007 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, ADDSI (current_cpu->h_gr_get (FLD (f_Rs)), FLD (f_imm12)), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gr_get (FLD (f_Rs)), FLD (f_imm12)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 930,935 ****
--- 1018,1024 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgriipostincgr (xstormy1
*** 943,948 ****
--- 1032,1038 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 963,968 ****
--- 1053,1059 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 971,976 ****
--- 1062,1068 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, ADDSI (current_cpu->h_gr_get (FLD (f_Rs)), FLD (f_imm12)), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gr_get (FLD (f_Rs)), FLD (f_imm12)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 993,998 ****
--- 1085,1091 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgriipredecgr (xstormy16
*** 1006,1011 ****
--- 1099,1105 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1042,1047 ****
--- 1136,1142 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1050,1061 ****
--- 1145,1158 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, ADDSI (current_cpu->h_gr_get (FLD (f_Rs)), FLD (f_imm12)), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (current_cpu->h_gr_get (FLD (f_Rs)), FLD (f_imm12)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movgrgr (xstormy16_cpu* cu
*** 1069,1074 ****
--- 1166,1172 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_movwimm8 (xstormy16_cpu* c
*** 1102,1107 ****
--- 1200,1206 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_movwgrimm8 (xstormy16_cpu*
*** 1135,1140 ****
--- 1234,1240 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_movwgrimm16 (xstormy16_cpu
*** 1168,1173 ****
--- 1268,1274 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_movlowgr (xstormy16_cpu* c
*** 1201,1206 ****
--- 1302,1308 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_movhighgr (xstormy16_cpu* 
*** 1234,1239 ****
--- 1336,1342 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_movfgrgri (xstormy16_cpu* 
*** 1267,1272 ****
--- 1370,1376 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 1277,1288 ****
--- 1381,1394 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1294,1311 ****
--- 1400,1420 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgrgripostinc (xstormy1
*** 1319,1324 ****
--- 1428,1434 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 1330,1341 ****
--- 1440,1453 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1347,1358 ****
--- 1459,1472 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1366,1371 ****
--- 1480,1486 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgrgripredec (xstormy16
*** 1379,1384 ****
--- 1494,1500 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (FLD (f_op2m)) {
*** 1396,1407 ****
--- 1512,1525 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1413,1424 ****
--- 1531,1544 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1426,1431 ****
--- 1546,1552 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgrigr (xstormy16_cpu* 
*** 1439,1444 ****
--- 1560,1566 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1459,1464 ****
--- 1581,1587 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 6);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1467,1472 ****
--- 1590,1596 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, JOINHISI (current_cpu->h_gr_get (((UINT) 8)), current_cpu->h_gr_get (FLD (f_Rs))), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) JOINHISI (current_cpu->h_gr_get (((UINT) 8)), current_cpu->h_gr_get (FLD (f_Rs))) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1483,1488 ****
--- 1607,1613 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgripostincgr (xstormy1
*** 1496,1501 ****
--- 1621,1627 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1516,1521 ****
--- 1642,1648 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1524,1529 ****
--- 1651,1657 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, JOINHISI (current_cpu->h_gr_get (((UINT) 8)), current_cpu->h_gr_get (FLD (f_Rs))), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) JOINHISI (current_cpu->h_gr_get (((UINT) 8)), current_cpu->h_gr_get (FLD (f_Rs))) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1546,1551 ****
--- 1674,1680 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgripredecgr (xstormy16
*** 1559,1564 ****
--- 1688,1694 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1595,1600 ****
--- 1725,1731 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, tmp_nwhere, opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) tmp_nwhere << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (ANDSI (tmp_nwhere, 1)) {
*** 1603,1614 ****
--- 1734,1747 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, JOINHISI (current_cpu->h_gr_get (((UINT) 8)), current_cpu->h_gr_get (FLD (f_Rs))), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) JOINHISI (current_cpu->h_gr_get (((UINT) 8)), current_cpu->h_gr_get (FLD (f_Rs))) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgrgrii (xstormy16_cpu*
*** 1622,1627 ****
--- 1755,1761 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 1632,1643 ****
--- 1766,1779 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1649,1666 ****
--- 1785,1805 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgrgriipostinc (xstormy
*** 1674,1679 ****
--- 1813,1819 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 1685,1696 ****
--- 1825,1838 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 11);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1702,1713 ****
--- 1844,1857 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 11);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1721,1726 ****
--- 1865,1871 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgrgriipredec (xstormy1
*** 1734,1739 ****
--- 1879,1885 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 1751,1762 ****
--- 1897,1910 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 11);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1768,1779 ****
--- 1916,1929 ----
    {
      HI opval = tmp_nvalue;
      current_cpu->h_gr_set (FLD (f_Rdm), opval);
+     written |= (1ULL << 10);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << FLD (f_Rdm) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
    {
      SI opval = ORSI (ANDSI (current_cpu->h_gr_get (((UINT) 14)), 3996), ORSI (SLLSI (FLD (f_Rdm), 12), ORBI (ORBI (EQHI (ANDHI (tmp_nvalue, 255), 0), SLLHI (EQHI (tmp_nvalue, 0), 1)), ORHI (SLLHI (current_cpu->parity (tmp_nvalue), 5), SLLHI (LTQI (SRLHI (tmp_nvalue, MULSI (FLD (f_op2m), 8)), 0), 6)))));
      current_cpu->h_gr_set (((UINT) 14), opval);
+     written |= (1ULL << 11);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "gr" << '[' << ((UINT) 14) << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1781,1786 ****
--- 1931,1937 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgriigr (xstormy16_cpu*
*** 1794,1799 ****
--- 1945,1951 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 1802,1807 ****
--- 1954,1960 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, ANDSI (ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), 0xfffffffe), opval);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), 0xfffffffe) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1809,1814 ****
--- 1962,1968 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1825,1830 ****
--- 1979,1985 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgriipostincgr (xstormy
*** 1838,1843 ****
--- 1993,1999 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 1846,1851 ****
--- 2002,2008 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, ANDSI (ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), 0xfffffffe), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), 0xfffffffe) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1853,1858 ****
--- 2010,2016 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1875,1880 ****
--- 2033,2039 ----
    }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_movfgriipredecgr (xstormy1
*** 1888,1893 ****
--- 2047,2053 ----
  #define FLD(f) abuf->fields.sfmt_movfgrgrii.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (FLD (f_op2m)) {
*** 1912,1917 ****
--- 2072,2078 ----
    {
      HI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMHI (pc, ANDSI (ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), 0xfffffffe), opval);
+     written |= (1ULL << 8);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ANDSI (ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), 0xfffffffe) << dec << ']' << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (FLD (f_op2m)) {
*** 1919,1930 ****
--- 2080,2093 ----
    {
      QI opval = current_cpu->h_gr_get (FLD (f_Rdm));
      current_cpu->SETMEMQI (pc, ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)), opval);
+     written |= (1ULL << 9);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "memory" << '[' <<  "0x" << hex << (UDI) ADDSI (JOINHISI (current_cpu->h_Rb_get (FLD (f_Rb)), current_cpu->h_gr_get (FLD (f_Rs))), FLD (f_imm12)) << dec << ']' << ":=0x" << hex << (SI) opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_maskgrgr (xstormy16_cpu* c
*** 1938,1943 ****
--- 2101,2107 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_maskgrimm16 (xstormy16_cpu
*** 1971,1976 ****
--- 2135,2141 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_pushgr (xstormy16_cpu* cur
*** 2004,2009 ****
--- 2169,2175 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_popgr (xstormy16_cpu* curr
*** 2035,2040 ****
--- 2201,2207 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_swpn (xstormy16_cpu* curre
*** 2066,2071 ****
--- 2233,2239 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_swpb (xstormy16_cpu* curre
*** 2099,2104 ****
--- 2267,2273 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_swpw (xstormy16_cpu* curre
*** 2132,2137 ****
--- 2301,2307 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_andgrgr (xstormy16_cpu* cu
*** 2175,2180 ****
--- 2345,2351 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_andimm8 (xstormy16_cpu* cu
*** 2208,2213 ****
--- 2379,2385 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_andgrimm16 (xstormy16_cpu*
*** 2241,2246 ****
--- 2413,2419 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_orgrgr (xstormy16_cpu* cur
*** 2274,2279 ****
--- 2447,2453 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_orimm8 (xstormy16_cpu* cur
*** 2307,2312 ****
--- 2481,2487 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_orgrimm16 (xstormy16_cpu* 
*** 2340,2345 ****
--- 2515,2521 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_xorgrgr (xstormy16_cpu* cu
*** 2373,2378 ****
--- 2549,2555 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_xorimm8 (xstormy16_cpu* cu
*** 2406,2411 ****
--- 2583,2589 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_xorgrimm16 (xstormy16_cpu*
*** 2439,2444 ****
--- 2617,2623 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_notgr (xstormy16_cpu* curr
*** 2472,2477 ****
--- 2651,2657 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_addgrgr (xstormy16_cpu* cu
*** 2505,2510 ****
--- 2685,2691 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_addgrimm4 (xstormy16_cpu* 
*** 2540,2545 ****
--- 2721,2727 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_addimm8 (xstormy16_cpu* cu
*** 2575,2580 ****
--- 2757,2763 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_addgrimm16 (xstormy16_cpu*
*** 2610,2615 ****
--- 2793,2799 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_adcgrgr (xstormy16_cpu* cu
*** 2645,2650 ****
--- 2829,2835 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_adcgrimm4 (xstormy16_cpu* 
*** 2680,2685 ****
--- 2865,2871 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_adcimm8 (xstormy16_cpu* cu
*** 2715,2720 ****
--- 2901,2907 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_adcgrimm16 (xstormy16_cpu*
*** 2750,2755 ****
--- 2937,2943 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_subgrgr (xstormy16_cpu* cu
*** 2785,2790 ****
--- 2973,2979 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_subgrimm4 (xstormy16_cpu* 
*** 2820,2825 ****
--- 3009,3015 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_subimm8 (xstormy16_cpu* cu
*** 2855,2860 ****
--- 3045,3051 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_subgrimm16 (xstormy16_cpu*
*** 2890,2895 ****
--- 3081,3087 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_sbcgrgr (xstormy16_cpu* cu
*** 2925,2930 ****
--- 3117,3123 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_sbcgrimm4 (xstormy16_cpu* 
*** 2960,2965 ****
--- 3153,3159 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_sbcgrimm8 (xstormy16_cpu* 
*** 2995,3000 ****
--- 3189,3195 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_sbcgrimm16 (xstormy16_cpu*
*** 3030,3035 ****
--- 3225,3231 ----
  #define FLD(f) abuf->fields.sfmt_movwgrimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_incgrimm2 (xstormy16_cpu* 
*** 3065,3070 ****
--- 3261,3267 ----
  #define FLD(f) abuf->fields.sfmt_incgrimm2.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_decgrimm2 (xstormy16_cpu* 
*** 3098,3103 ****
--- 3295,3301 ----
  #define FLD(f) abuf->fields.sfmt_incgrimm2.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_rrcgrgr (xstormy16_cpu* cu
*** 3131,3136 ****
--- 3329,3335 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_rrcgrimm4 (xstormy16_cpu* 
*** 3171,3176 ****
--- 3370,3376 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_rlcgrgr (xstormy16_cpu* cu
*** 3211,3216 ****
--- 3411,3417 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_rlcgrimm4 (xstormy16_cpu* 
*** 3251,3256 ****
--- 3452,3458 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_shrgrgr (xstormy16_cpu* cu
*** 3291,3296 ****
--- 3493,3499 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_shrgrimm (xstormy16_cpu* c
*** 3326,3331 ****
--- 3529,3535 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_shlgrgr (xstormy16_cpu* cu
*** 3361,3366 ****
--- 3565,3571 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_shlgrimm (xstormy16_cpu* c
*** 3396,3401 ****
--- 3601,3607 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_asrgrgr (xstormy16_cpu* cu
*** 3431,3436 ****
--- 3637,3643 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_asrgrimm (xstormy16_cpu* c
*** 3466,3471 ****
--- 3673,3679 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_set1grimm (xstormy16_cpu* 
*** 3501,3506 ****
--- 3709,3715 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_set1grgr (xstormy16_cpu* c
*** 3534,3539 ****
--- 3743,3749 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_set1lmemimm (xstormy16_cpu
*** 3567,3572 ****
--- 3777,3783 ----
  #define FLD(f) abuf->fields.sfmt_set1lmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_set1hmemimm (xstormy16_cpu
*** 3600,3605 ****
--- 3811,3817 ----
  #define FLD(f) abuf->fields.sfmt_set1hmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_clr1grimm (xstormy16_cpu* 
*** 3633,3638 ****
--- 3845,3851 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_clr1grgr (xstormy16_cpu* c
*** 3666,3671 ****
--- 3879,3885 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_clr1lmemimm (xstormy16_cpu
*** 3699,3704 ****
--- 3913,3919 ----
  #define FLD(f) abuf->fields.sfmt_set1lmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_clr1hmemimm (xstormy16_cpu
*** 3732,3737 ****
--- 3947,3953 ----
  #define FLD(f) abuf->fields.sfmt_set1hmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_cbwgr (xstormy16_cpu* curr
*** 3765,3770 ****
--- 3981,3987 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_revgr (xstormy16_cpu* curr
*** 3798,3803 ****
--- 4015,4021 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_bccgrgr (xstormy16_cpu* cu
*** 3831,3836 ****
--- 4049,4055 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (tmp_tmp) {
*** 3918,3923 ****
--- 4137,4143 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 13);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (tmp_tmp) {
*** 3925,3930 ****
--- 4145,4151 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bccgrimm8 (xstormy16_cpu* 
*** 3938,3943 ****
--- 4159,4165 ----
  #define FLD(f) abuf->fields.sfmt_bccgrimm8.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (tmp_tmp) {
*** 4025,4030 ****
--- 4247,4253 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 13);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (tmp_tmp) {
*** 4032,4037 ****
--- 4255,4261 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bccimm16 (xstormy16_cpu* c
*** 4045,4050 ****
--- 4269,4275 ----
  #define FLD(f) abuf->fields.sfmt_bccimm16.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (tmp_tmp) {
*** 4132,4137 ****
--- 4357,4363 ----
    {
      USI opval = FLD (f_rel8_4);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 12);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
*************** if (tmp_tmp) {
*** 4139,4144 ****
--- 4365,4371 ----
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bngrimm4 (xstormy16_cpu* c
*** 4152,4157 ****
--- 4379,4385 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (EQSI (ANDSI (current_cpu->h_gr_get (
*** 4166,4177 ****
--- 4394,4407 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bngrgr (xstormy16_cpu* cur
*** 4185,4190 ****
--- 4415,4421 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (EQSI (ANDSI (current_cpu->h_gr_get (
*** 4199,4210 ****
--- 4430,4443 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bnlmemimm (xstormy16_cpu* 
*** 4218,4223 ****
--- 4451,4457 ----
  #define FLD(f) abuf->fields.sfmt_bnlmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (EQQI (ANDQI (current_cpu->GETMEMQI (
*** 4225,4235 ****
--- 4459,4471 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bnhmemimm (xstormy16_cpu* 
*** 4243,4248 ****
--- 4479,4485 ----
  #define FLD(f) abuf->fields.sfmt_bnhmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (EQQI (ANDQI (current_cpu->GETMEMQI (
*** 4250,4260 ****
--- 4487,4499 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bpgrimm4 (xstormy16_cpu* c
*** 4268,4273 ****
--- 4507,4513 ----
  #define FLD(f) abuf->fields.sfmt_bngrimm4.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (NESI (ANDSI (current_cpu->h_gr_get (
*** 4282,4293 ****
--- 4522,4535 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bpgrgr (xstormy16_cpu* cur
*** 4301,4306 ****
--- 4543,4549 ----
  #define FLD(f) abuf->fields.sfmt_bccgrgr.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (NESI (ANDSI (current_cpu->h_gr_get (
*** 4315,4326 ****
--- 4558,4571 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 5);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bplmemimm (xstormy16_cpu* 
*** 4334,4339 ****
--- 4579,4585 ----
  #define FLD(f) abuf->fields.sfmt_bnlmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (NEQI (ANDQI (current_cpu->GETMEMQI (
*** 4341,4351 ****
--- 4587,4599 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bphmemimm (xstormy16_cpu* 
*** 4359,4364 ****
--- 4607,4613 ----
  #define FLD(f) abuf->fields.sfmt_bnhmemimm.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** if (NEQI (ANDQI (current_cpu->GETMEMQI (
*** 4366,4376 ****
--- 4615,4627 ----
    {
      USI opval = FLD (f_rel12);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 4);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bcc (xstormy16_cpu* curren
*** 4384,4389 ****
--- 4635,4641 ----
  #define FLD(f) abuf->fields.sfmt_bcc.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** if (tmp_tmp) {
*** 4460,4471 ****
--- 4712,4725 ----
    {
      USI opval = FLD (f_rel8_2);
      current_cpu->branch (opval, npc, status);
+     written |= (1ULL << 7);
      if (UNLIKELY(current_cpu->trace_result_p))
        current_cpu->trace_stream << "pc" << ":=0x" << hex << opval << dec << "  ";
    }
  }
  }
  
+   abuf->written = written;
    current_cpu->done_cti_insn (npc, status);
    return status;
  #undef FLD
*************** xstormy16_sem_bgr (xstormy16_cpu* curren
*** 4479,4484 ****
--- 4733,4739 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_br (xstormy16_cpu* current
*** 4502,4507 ****
--- 4757,4763 ----
  #define FLD(f) abuf->fields.sfmt_br.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_jmp (xstormy16_cpu* curren
*** 4525,4530 ****
--- 4781,4787 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_jmpf (xstormy16_cpu* curre
*** 4548,4553 ****
--- 4805,4811 ----
  #define FLD(f) abuf->fields.sfmt_jmpf.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_callrgr (xstormy16_cpu* cu
*** 4571,4576 ****
--- 4829,4835 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_callrimm (xstormy16_cpu* c
*** 4608,4613 ****
--- 4867,4873 ----
  #define FLD(f) abuf->fields.sfmt_br.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_callgr (xstormy16_cpu* cur
*** 4645,4650 ****
--- 4905,4911 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_callfimm (xstormy16_cpu* c
*** 4682,4687 ****
--- 4943,4949 ----
  #define FLD(f) abuf->fields.sfmt_jmpf.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_icallrgr (xstormy16_cpu* c
*** 4719,4724 ****
--- 4981,4987 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_icallgr (xstormy16_cpu* cu
*** 4762,4767 ****
--- 5025,5031 ----
  #define FLD(f) abuf->fields.sfmt_jmp.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_icallfimm (xstormy16_cpu* 
*** 4805,4810 ****
--- 5069,5075 ----
  #define FLD(f) abuf->fields.sfmt_jmpf.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 4;
  
*************** xstormy16_sem_iret (xstormy16_cpu* curre
*** 4848,4853 ****
--- 5113,5119 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_ret (xstormy16_cpu* curren
*** 4885,4890 ****
--- 5151,5157 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_mul (xstormy16_cpu* curren
*** 4916,4921 ****
--- 5183,5189 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_div (xstormy16_cpu* curren
*** 4955,4960 ****
--- 5223,5229 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_sdiv (xstormy16_cpu* curre
*** 4996,5001 ****
--- 5265,5271 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_sdivlh (xstormy16_cpu* cur
*** 5037,5042 ****
--- 5307,5313 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_divlh (xstormy16_cpu* curr
*** 5080,5085 ****
--- 5351,5357 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_reset (xstormy16_cpu* curr
*** 5123,5128 ****
--- 5395,5401 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_nop (xstormy16_cpu* curren
*** 5141,5146 ****
--- 5414,5420 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_halt (xstormy16_cpu* curre
*** 5159,5164 ****
--- 5433,5439 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_hold (xstormy16_cpu* curre
*** 5177,5182 ****
--- 5452,5458 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_holdx (xstormy16_cpu* curr
*** 5195,5200 ****
--- 5471,5477 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_brk (xstormy16_cpu* curren
*** 5213,5218 ****
--- 5490,5496 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
*************** xstormy16_sem_syscall (xstormy16_cpu* cu
*** 5231,5236 ****
--- 5509,5515 ----
  #define FLD(f) abuf->fields.fmt_empty.f
    sem_status status = SEM_STATUS_NORMAL;
    xstormy16_scache* abuf = sem;
+   unsigned long long written = 0;
    PCADDR pc = abuf->addr;
    PCADDR npc = pc + 2;
  
/* Simulator model support for xstormy16.

THIS FILE IS MACHINE GENERATED WITH CGEN.

Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.

This file is part of the Red Hat simulators.


*/

#ifndef XSTORMY16_MODEL_H
#define XSTORMY16_MODEL_H

#include "cgen-cpu.h"
#include "cgen-model.h"

namespace xstormy16
{
using namespace cgen;

class xstormy16_xstormy16_model : public cgen_model
{
public:
  xstormy16_xstormy16_model (xstormy16_cpu *cpu);

  // Call the proper unit modelling function for the given insn.
  UINT model_before (xstormy16_cpu *current_cpu, xstormy16_scache* sem)
    {
      return (this->*(timing[sem->idesc->sem_index].model_before)) (current_cpu, sem);
    } 
  UINT model_after (xstormy16_cpu *current_cpu, xstormy16_scache* sem)
    {
      return (this->*(timing[sem->idesc->sem_index].model_after)) (current_cpu, sem);
    } 

// Function unit handlers
// To be overridden as needed.
  virtual UINT model_u_exec_before (xstormy16_cpu *cpu, const struct xstormy16_idesc *idesc, int unit_num)
    {
      return 0;
    }
  virtual UINT model_u_exec_after (xstormy16_cpu *cpu, const struct xstormy16_idesc *idesc, int unit_num, unsigned long long referenced)
    {
      return timing[idesc->sem_index].units[unit_num].done;
    }

protected:
  // These methods call the appropriate unit modeller(s) for each insn.
  UINT model_movlmemimm_before (xstormy16_cpu *current_cpu, xstormy16_scache *sem);
  UINT model_movlmemimm_after (xstormy16_cpu *current_cpu, xstormy16_scache *sem);
  UINT model_movhmemimm_before (xstormy16_cpu *current_cpu, xstormy16_scache *sem);
  UINT model_movhmemimm_after (xstormy16_cpu *current_cpu, xstormy16_scache *sem);

  // ---------------------------------------------------------
  // [snip] ... two functions for each insn as above ...
  // ---------------------------------------------------------

  /* Enum declaration for unit types.  */
typedef enum unit_number {
  UNIT_NONE, UNIT_U_EXEC, UNIT_MAX
} UNIT_NUMBER;

  struct unit {
    unit_number unit;
    UINT issue;
    UINT done;
  };

  #define MAX_UNITS (1)

  typedef UINT (xstormy16_xstormy16_model::*model_function) (xstormy16_cpu* current_cpu, xstormy16_scache* sem);

  struct insn_timing {
    // This is an integer that identifies this insn.
    UINT num;
    // Functions to handle insn-specific profiling.
    model_function model_before;
    model_function model_after;
    // Array of function units used by this insn.
    unit units[MAX_UNITS];
  };

  static const insn_timing timing[];
};

} // namespace xstormy16

#endif // XSTORMY16_MODEL_H
/* Simulator model support for xstormy16.

THIS FILE IS MACHINE GENERATED WITH CGEN.

Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.

This file is part of the Red Hat simulators.


*/


#include "xstormy16.h"

using namespace xstormy16; // FIXME: namespace organization still wip

/* The profiling data is recorded here, but is accessed via the profiling
   mechanism.  After all, this is information for profiling.  */

/* Model handlers for each insn.  */

xstormy16_xstormy16_model::xstormy16_xstormy16_model (xstormy16_cpu *cpu)
  : cgen_model (cpu)
{
}

UINT
xstormy16_xstormy16_model::model_movlmemimm_before (xstormy16_cpu *current_cpu, xstormy16_scache *sem)
{
#define FLD(f) abuf->fields.sfmt_movlmemimm.f
  const xstormy16_scache* abuf = sem;
  const xstormy16_idesc* idesc = abuf->idesc;
  int cycles = 0;
  {
    cycles += model_u_exec_before (current_cpu, idesc, 0);
  }
  return cycles;
#undef FLD
}

UINT
xstormy16_xstormy16_model::model_movlmemimm_after (xstormy16_cpu *current_cpu, xstormy16_scache *sem)
{
#define FLD(f) abuf->fields.sfmt_movlmemimm.f
  const xstormy16_scache* abuf = sem;
  const xstormy16_idesc* idesc = abuf->idesc;
  int cycles = 0;
  {
    int referenced = 0;
    unsigned long long insn_referenced = abuf->written;
    cycles += model_u_exec_after (current_cpu, idesc, 0, referenced);
  }
  return cycles;
#undef FLD
}

  // ---------------------------------------------------------
  // [snip] ... two functions for each insn as above ...
  // ---------------------------------------------------------

/* We assume UNIT_NONE == 0 because the tables don't always terminate
   entries with it.  */

/* Model timing data for `xstormy16'.  */

const xstormy16_xstormy16_model::insn_timing xstormy16_xstormy16_model::timing[] = {
  { XSTORMY16_INSN_X_INVALID, 0, 0, { { xstormy16_xstormy16_model::UNIT_U_EXEC, 1, 1 } } },
  { XSTORMY16_INSN_MOVLMEMIMM, & xstormy16_xstormy16_model::model_movlmemimm_before, & xstormy16_xstormy16_model::model_movlmemimm_after, { { xstormy16_xstormy16_model::UNIT_U_EXEC, 1, 1 } } },
  { XSTORMY16_INSN_MOVHMEMIMM, & xstormy16_xstormy16_model::model_movhmemimm_before, & xstormy16_xstormy16_model::model_movhmemimm_after, { { xstormy16_xstormy16_model::UNIT_U_EXEC, 1, 1 } } },

  // ---------------------------------------------------------
  // [snip] ... one entry for each insn, as above
  // ---------------------------------------------------------

};

// cgen-model.h  -*- C++ -*-

// Copyright (C) 2003 Red Hat.
// This file is part of SID and is licensed under the GPL.
// See the file COPYING.SID for conditions for redistribution.

#ifndef CGEN_MODEL_H
#define CGEN_MODEL_H

#include "cgen-cpu.h"

namespace cgen
{

class cgen_model
{
public:
  cgen_model (cgen_bi_endian_cpu *c) : cpu (c) {}

  // To be overridden as needed. Call before each insn is executed. first_p is
  // true when the insn is the first of a group of parallel insns.
  virtual void model_insn_before (bool first_p = true) {}

  // To be overridden as needed. Call after each insn is executed. last_p is
  // true when the insn is the first of a group of parallel insns. cycles is the
  // number of cycles used by each particular insn.
  virtual void model_insn_after (bool last_p = true, sid::host_int_4 cycles = 1)
    {
      if (last_p && cycles > 0)
	cpu->update_total_latency (cycles - 1);
    }

protected:
  cgen_bi_endian_cpu *cpu;
};

} // namespace cgen

#endif /* CGEN_MODEL_H */
2003-03-27  Dave Brolley  <brolley at redhat dot com>

	* sidcpuutil.h (final_insn_count_p): New member of basic_cpu.
	(update_total_latency): New method of basic_cpu.
	(stream_state): Output final_insn_count_p.
	(destream_state): Input final_insn_count_p.
	(basic_cpu): Add attribute final-insn-count.

2003-03-27  Dave Brolley  <brolley at redhat dot com>

	* commonCfg.cxx (final_insn_count): Set cpu attribute 'final-insn-count'.

2003-03-27  Dave Brolley  <brolley at redhat dot com>

	* CGEN.sh.in: Implement generation of model.cxx and model.h
	* cgen-model.h: New file.
	* common-xml/interface.xml: Document trace-counter and
	final-insn-count.


2003-03-27  Dave Brolley  <brolley at redhat dot com>

	* sidcpuutil.h (final_insn_count_p): New member of basic_cpu.
	(update_total_latency): New method of basic_cpu.
	(stream_state): Output final_insn_count_p.
	(destream_state): Input final_insn_count_p.
	(basic_cpu): Add attribute final-insn-count.

2003-03-27  Dave Brolley  <brolley at redhat dot com>

	* commonCfg.cxx (final_insn_count): Set cpu attribute 'final-insn-count'.

2003-03-27  Dave Brolley  <brolley at redhat dot com>

	* CGEN.sh.in: Implement generation of model.cxx and model.h
	* cgen-model.h: New file.
	* common-xml/interface.xml: Document trace-counter and
	final-insn-count.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]