[patch] xstormy16: fix carry, sign, other flags.

DJ Delorie <[email protected]>
Newsgroups gmane.comp.emulators.sid.devel,gmane.comp.tools.cgen.devel
Message-ID <[email protected]>
More tweaks to get PSW right.

Index: cgen/ChangeLog
2003-03-21  DJ Delorie  <[email protected]>

	* cpu/xstormy16.cpu (basic-psw): New argument ws (wordsize),
	which indicates if the sign flag is set from bit 15 or 7.
	Adjust all callers.
	(set-psw): New argument ws, propogate it.
	(set-psw-nowrite): Likewise.
	(set-mem-psw): Likewise.
	(set-psw-carry): Likewise.  Use temporaries to prevent
	prematurely overwriting needed inputs.
	(set-psw-rrotate17): Fix logic.
	(shrgrgr): Preserve carry for zero-bit shifts.
	(shrgrimm): Likewise.
	(shlgrgr): Likewise.
	(shlgrimm): Likewise.
	(asrgrgr): Likewise.
	(asrgrimm): Likewise.
	(reset): New.

Index: sid/component/cgen-cpu/xstormy16/ChangeLog
2003-03-21  DJ Delorie  <[email protected]>

	* xstormy16-decode.cxx: Regenerate.
	* xstormy16-decode.h: Regenerate.
	* xstormy16-sem.cxx: Regenerate.
	* xstormy16-write.cxx: Regenerate.
  
Index: cgen/cpu/xstormy16.cpu
===================================================================
RCS file: /cvs/src/src/cgen/cpu/xstormy16.cpu,v
retrieving revision 1.7
diff -p -2 -r1.7  cgen/cpu/xstormy16.cpu
*** cgen/cpu/xstormy16.cpu	6 Mar 2003 00:34:06 -0000	1.7
--- cgen/cpu/xstormy16.cpu	21 Mar 2003 02:35:40 -0000
***************
*** 381,393 ****
  
  ; THe Z8, Z16, PT, and S flags of the PSW.
! (define-pmacro (basic-psw value)
    (or (or (zflag (and value #xFF))
  	  (sll HI (zflag HI value) 1))
        (or (sll HI (c-call BI "parity" value) 5)
! 	  (sll HI (nflag HI value) 6))))
  
  
  ; Update the PSW for destination register Rd, set Rd to value.
! (define-pmacro (set-psw Rd index value)
    (sequence ((HI nvalue))
      (set nvalue value)
--- 381,393 ----
  
  ; THe Z8, Z16, PT, and S flags of the PSW.
! (define-pmacro (basic-psw value ws)
    (or (or (zflag (and value #xFF))
  	  (sll HI (zflag HI value) 1))
        (or (sll HI (c-call BI "parity" value) 5)
! 	  (sll HI (nflag QI (srl value (mul ws 8))) 6))))
  
  
  ; Update the PSW for destination register Rd, set Rd to value.
! (define-pmacro (set-psw Rd index value ws)
    (sequence ((HI nvalue))
      (set nvalue value)
***************
*** 395,425 ****
      (set psw (or (and psw #x0F9C)
  		 (or (sll index 12)
! 		     (basic-psw nvalue))))))
  
  ; Update the PSW for destination register Rd.
! (define-pmacro (set-psw-nowrite index value)
    (sequence ((HI nvalue))
      (set nvalue value)
      (set psw (or (and psw #x0F9C)
  		 (or (sll index 12)
! 		     (basic-psw nvalue))))))
  
  ; Update the PSW for destination non-register dest, set dest to value.
! (define-pmacro (set-mem-psw dest value)
    (sequence ((HI nvalue))
      (set nvalue value)
      (set psw (or (and psw #xFF9C)
! 		 (basic-psw nvalue)))
      (set dest nvalue)))
  
  ; Update the PSW as with set-psw, but also set the carry flag.
! (define-pmacro (set-psw-carry Rd index value carry)
!   (sequence ((HI nvalue))
      (set nvalue value)
!     (set (reg HI h-gr index) nvalue)
!     (set psw (or (or (and psw #x0F98)
! 		     (sll carry 2))
  		 (or (sll index 12)
! 		     (basic-psw nvalue))))))
  
  ; The all-purpose addition operation.
--- 395,427 ----
      (set psw (or (and psw #x0F9C)
  		 (or (sll index 12)
! 		     (basic-psw nvalue ws))))))
  
  ; Update the PSW for destination register Rd.
! (define-pmacro (set-psw-nowrite index value ws)
    (sequence ((HI nvalue))
      (set nvalue value)
      (set psw (or (and psw #x0F9C)
  		 (or (sll index 12)
! 		     (basic-psw nvalue ws))))))
  
  ; Update the PSW for destination non-register dest, set dest to value.
! (define-pmacro (set-mem-psw dest value ws)
    (sequence ((HI nvalue))
      (set nvalue value)
      (set psw (or (and psw #xFF9C)
! 		 (basic-psw nvalue ws)))
      (set dest nvalue)))
  
  ; Update the PSW as with set-psw, but also set the carry flag.
! (define-pmacro (set-psw-carry Rd index value carry ws)
!   (sequence ((HI nvalue) (HI newpsw))
      (set nvalue value)
!     (set newpsw (or (or (and psw #x0F98)
! 		     (sll (and carry #x1) 2))
  		 (or (sll index 12)
! 		     (basic-psw nvalue ws))))
!     (set (reg HI h-gr index) nvalue)
!     (set psw newpsw)
!     ))
  
  ; The all-purpose addition operation.
***************
*** 428,432 ****
      (set value (addc a b c))
      (set newpsw (or (or (and psw #x0F80)
! 			(basic-psw value))
  		    (or (or (sll HI (add-oflag HI a b c) 4)
  			    (sll HI (add-cflag HI a b c) 2))
--- 430,434 ----
      (set value (addc a b c))
      (set newpsw (or (or (and psw #x0F80)
! 			(basic-psw value 1))
  		    (or (or (sll HI (add-oflag HI a b c) 4)
  			    (sll HI (add-cflag HI a b c) 2))
***************
*** 444,448 ****
      (set value (sub a b))
      (set psw (or (or (and psw #x0F80)
! 		     (basic-psw value))
  		 (or (or (sll HI (sub-oflag HI a b 0) 4)
  			 (sll HI (sub-cflag HI a b 0) 2))
--- 446,450 ----
      (set value (sub a b))
      (set psw (or (or (and psw #x0F80)
! 		     (basic-psw value 1))
  		 (or (or (sll HI (sub-oflag HI a b 0) 4)
  			 (sll HI (sub-cflag HI a b 0) 2))
***************
*** 458,462 ****
      (set value (subc a b c))
      (set newpsw (or (or (and psw #x0F80)
! 		     (basic-psw value))
  		 (or (or (sll HI (sub-oflag HI a b c) 4)
  			 (sll HI (sub-cflag HI a b c) 2))
--- 460,464 ----
      (set value (subc a b c))
      (set newpsw (or (or (and psw #x0F80)
! 		     (basic-psw value 1))
  		 (or (or (sll HI (sub-oflag HI a b c) 4)
  			 (sll HI (sub-cflag HI a b c) 2))
***************
*** 476,485 ****
  		     (sll SI c 16))))
      (set tmpfoo (rol tmpfoo (and rot #x1F)))
!     (set-psw-carry (reg HI h-gr index) index (trunc HI tmpfoo) (and (srl tmpfoo 16) 1))))
  
! ; We have to be careful to get the right group of 16 shifts from the above.
  (define-pmacro (set-psw-rrotate17 Rd index src c rot)
!   (set-psw-rotate17 Rd index src c (sub 47 (mod (add (and rot #xf) 15) 17)))
!   )
  
  
--- 478,491 ----
  		     (sll SI c 16))))
      (set tmpfoo (rol tmpfoo (and rot #x1F)))
!     (set-psw-carry (reg HI h-gr index) index (trunc HI tmpfoo) (and (srl tmpfoo 16) 1) 1)))
  
! ; A 17-bit rotate-right operation
  (define-pmacro (set-psw-rrotate17 Rd index src c rot)
!   (sequence ((SI tmpfoo))
!     (set tmpfoo (or (or (and (sll SI src 17) #xFFFE0000) 
! 		     src)
! 		 (sll SI c 16)))
!     (set tmpfoo (ror tmpfoo (and rot #x0F)))
!     (set-psw-carry (reg HI h-gr index) index (trunc HI tmpfoo) (and (srl tmpfoo 16) 1) 1)))
  
  
***************
*** 511,516 ****
       (+ OP1_7 OP2A_8 ws2 lmem8 imm16)
       (if ws2
! 	 (set-mem-psw (mem HI (and lmem8 #xFFFE)) imm16)
! 	 (set-mem-psw (mem QI lmem8) (and imm16 #xFF)))
       ()
  )
--- 517,522 ----
       (+ OP1_7 OP2A_8 ws2 lmem8 imm16)
       (if ws2
! 	 (set-mem-psw (mem HI (and lmem8 #xFFFE)) imm16 ws2)
! 	 (set-mem-psw (mem QI lmem8) (and imm16 #xFF) ws2))
       ()
  )
***************
*** 521,526 ****
       (+ OP1_7 OP2A_A ws2 hmem8 imm16)
       (if ws2
! 	 (set-mem-psw (mem HI (and hmem8 #xFFFE)) imm16)
! 	 (set-mem-psw (mem QI hmem8) (and imm16 #xFF)))
       ()
  )
--- 527,532 ----
       (+ OP1_7 OP2A_A ws2 hmem8 imm16)
       (if ws2
! 	 (set-mem-psw (mem HI (and hmem8 #xFFFE)) imm16 ws2)
! 	 (set-mem-psw (mem QI hmem8) (and imm16 #xFF) ws2))
       ()
  )
***************
*** 532,537 ****
       (+ OP1_8 Rm ws2 lmem8)
       (if ws2 
! 	 (set-psw Rm (index-of Rm) (alignfix-mem lmem8))
! 	 (set-psw Rm (index-of Rm) (mem QI lmem8)))
       ()
  )
--- 538,543 ----
       (+ OP1_8 Rm ws2 lmem8)
       (if ws2 
! 	 (set-psw Rm (index-of Rm) (alignfix-mem lmem8) ws2)
! 	 (set-psw Rm (index-of Rm) (mem QI lmem8) ws2))
       ()
  )
***************
*** 542,547 ****
       (+ OP1_A Rm ws2 hmem8)
       (if ws2 
! 	 (set-psw Rm (index-of Rm) (alignfix-mem hmem8))
! 	 (set-psw Rm (index-of Rm) (mem QI hmem8)))
       ()
  )
--- 548,553 ----
       (+ OP1_A Rm ws2 hmem8)
       (if ws2 
! 	 (set-psw Rm (index-of Rm) (alignfix-mem hmem8) ws2)
! 	 (set-psw Rm (index-of Rm) (mem QI hmem8) ws2))
       ()
  )
***************
*** 553,558 ****
       (+ OP1_9 Rm ws2 lmem8)
       (if ws2 
! 	 (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm)
! 	 (set-mem-psw (mem QI lmem8) Rm))
       ()
  )
--- 559,564 ----
       (+ OP1_9 Rm ws2 lmem8)
       (if ws2 
! 	 (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm ws2)
! 	 (set-mem-psw (mem QI lmem8) Rm ws2))
       ()
  )
***************
*** 563,568 ****
       (+ OP1_B Rm ws2 hmem8)
       (if ws2 
! 	 (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm)
! 	 (set-mem-psw (mem QI lmem8) Rm))
       ()
  )
--- 569,574 ----
       (+ OP1_B Rm ws2 hmem8)
       (if ws2 
! 	 (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm ws2)
! 	 (set-mem-psw (mem QI lmem8) Rm ws2))
       ()
  )
***************
*** 574,579 ****
       (+ OP1_7 OP2A_0 ws2 Rs OP4M_0 Rdm)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem Rs))
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs))))
       ()
  )
--- 580,585 ----
       (+ OP1_7 OP2A_0 ws2 Rs OP4M_0 Rdm)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem Rs) ws2)
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs)) ws2))
       ()
  )
***************
*** 586,591 ****
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem Rs))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs))))
  	       (set Rs (add Rs (add 1 ws2))))
       ()
--- 592,597 ----
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem Rs) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs)) ws2))
  	       (set Rs (add Rs (add 1 ws2))))
       ()
***************
*** 600,605 ****
  	       (set Rs (sub Rs (add 1 ws2)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem Rs))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs)))))
       ()
  )
--- 606,611 ----
  	       (set Rs (sub Rs (add 1 ws2)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem Rs) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs)) ws2)))
       ()
  )
***************
*** 614,618 ****
  		   (set-alignfix-mem Rs Rdm)
  		   (set (mem QI Rs) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm))
       ()
  )
--- 620,624 ----
  		   (set-alignfix-mem Rs Rdm)
  		   (set (mem QI Rs) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2))
       ()
  )
***************
*** 627,631 ****
  		   (set-alignfix-mem Rs Rdm)
  		   (set (mem QI Rs) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (set Rs (add Rs (add ws2 1))))
       ()
--- 633,637 ----
  		   (set-alignfix-mem Rs Rdm)
  		   (set (mem QI Rs) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (set Rs (add Rs (add ws2 1))))
       ()
***************
*** 639,643 ****
       (sequence ()
  	       (set Rs (sub Rs (add ws2 1)))
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (if ws2
  		   (set-alignfix-mem Rs Rdm)
--- 645,649 ----
       (sequence ()
  	       (set Rs (sub Rs (add ws2 1)))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (if ws2
  		   (set-alignfix-mem Rs Rdm)
***************
*** 652,657 ****
       (+ OP1_7 OP2A_0 ws2 Rs OP4M_1 Rdm OP5_0 imm12)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem (add Rs imm12)))
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add Rs imm12)))))
       ()
  )
--- 658,663 ----
       (+ OP1_7 OP2A_0 ws2 Rs OP4M_1 Rdm OP5_0 imm12)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem (add Rs imm12)) ws2)
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add Rs imm12))) ws2))
       ()
  )
***************
*** 664,669 ****
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add Rs imm12)))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add Rs imm12)))))
  	       (set Rs (add Rs (add ws2 1))))
       ()
--- 670,675 ----
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add Rs imm12)) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add Rs imm12))) ws2))
  	       (set Rs (add Rs (add ws2 1))))
       ()
***************
*** 678,683 ****
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add Rs imm12)))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add Rs imm12))))))
       ()
  )
--- 684,689 ----
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add Rs imm12)) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add Rs imm12))) ws2)))
       ()
  )
***************
*** 692,696 ****
  		   (set-alignfix-mem (add Rs imm12) Rdm)
  		   (set (mem QI (add Rs imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm))
       ()
  )
--- 698,702 ----
  		   (set-alignfix-mem (add Rs imm12) Rdm)
  		   (set (mem QI (add Rs imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2))
       ()
  )
***************
*** 705,709 ****
  		   (set-alignfix-mem (add Rs imm12) Rdm)
  		   (set (mem QI (add Rs imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (set Rs (add Rs 1)))
       ()
--- 711,715 ----
  		   (set-alignfix-mem (add Rs imm12) Rdm)
  		   (set (mem QI (add Rs imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (set Rs (add Rs 1)))
       ()
***************
*** 717,721 ****
       (sequence ()
  	       (set Rs (sub Rs 1))
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (if ws2
  		   (set-alignfix-mem (add Rs imm12) Rdm)
--- 723,727 ----
       (sequence ()
  	       (set Rs (sub Rs 1))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (if ws2
  		   (set-alignfix-mem (add Rs imm12) Rdm)
***************
*** 729,733 ****
       ("mov $Rd,$Rs")
       (+ OP1_4 OP2_6 Rs Rd)
!      (set-psw Rd (index-of Rd) Rs)
       ()
  )
--- 735,739 ----
       ("mov $Rd,$Rs")
       (+ OP1_4 OP2_6 Rs Rd)
!      (set-psw Rd (index-of Rd) Rs 1)
       ()
  )
***************
*** 745,749 ****
       ("mov.w Rx,#$imm8")
       (+ OP1_4 OP2_7 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw imm8)
       ()
  )
--- 751,755 ----
       ("mov.w Rx,#$imm8")
       (+ OP1_4 OP2_7 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw imm8 1)
       ()
  )
***************
*** 761,765 ****
       ("mov.w $Rm,#$imm8small")
       (+ OP1_2 Rm OP2M_1 imm8small)
!      (set-psw Rm (index-of Rm) imm8small)
       ()
  )
--- 767,771 ----
       ("mov.w $Rm,#$imm8small")
       (+ OP1_2 Rm OP2M_1 imm8small)
!      (set-psw Rm (index-of Rm) imm8small 1)
       ()
  )
***************
*** 777,781 ****
       ("mov.w $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_3 Rd imm16)
!      (set-psw Rd (index-of Rd) imm16)
       ()
  )
--- 783,787 ----
       ("mov.w $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_3 Rd imm16)
!      (set-psw Rd (index-of Rd) imm16 1)
       ()
  )
***************
*** 786,790 ****
       ("mov.b $Rd,RxL")
       (+ OP1_3 OP2_0 OP3_C Rd)
!      (set-psw Rd (index-of Rd) (or (and Rd #xFF00) (and (reg HI h-gr Rpsw) #xFF)))
       ()
  )
--- 792,796 ----
       ("mov.b $Rd,RxL")
       (+ OP1_3 OP2_0 OP3_C Rd)
!      (set-psw Rd (index-of Rd) (or (and Rd #xFF00) (and (reg HI h-gr Rpsw) #xFF)) 0)
       ()
  )
***************
*** 795,799 ****
       ("mov.b $Rd,RxH")
       (+ OP1_3 OP2_0 OP3_D Rd)
!      (set-psw Rd (index-of Rd) (or (and Rd #x00FF) (and (reg HI h-gr Rpsw) #xFF00)))
       ()
  )
--- 801,805 ----
       ("mov.b $Rd,RxH")
       (+ OP1_3 OP2_0 OP3_D Rd)
!      (set-psw Rd (index-of Rd) (or (and Rd #x00FF) (and (reg HI h-gr Rpsw) #xFF00)) 1)
       ()
  )
***************
*** 805,810 ****
       (+ OP1_7 OP2A_4 ws2 Rs OP4M_0 Rdm)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem (or (sll SI R8 16) Rs)))
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (or (sll SI R8 16) Rs)))))
       ()
  )
--- 811,816 ----
       (+ OP1_7 OP2A_4 ws2 Rs OP4M_0 Rdm)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem (or (sll SI R8 16) Rs)) ws2)
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (or (sll SI R8 16) Rs))) ws2))
       ()
  )
***************
*** 817,822 ****
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (join SI HI R8 Rs)))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (join SI HI R8 Rs)))))
  	       (set Rs (add Rs (add ws2 1))))
       ()
--- 823,828 ----
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (join SI HI R8 Rs)) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (join SI HI R8 Rs))) ws2))
  	       (set Rs (add Rs (add ws2 1))))
       ()
***************
*** 831,836 ****
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (join SI HI R8 Rs)))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (join SI HI R8 Rs))))))
       ()
  )
--- 837,842 ----
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (join SI HI R8 Rs)) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (join SI HI R8 Rs))) ws2)))
       ()
  )
***************
*** 845,849 ****
  		   (set-alignfix-mem (join SI HI R8 Rs) Rdm)
  		   (set (mem QI (join SI HI R8 Rs)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm))
       ()
  )
--- 851,855 ----
  		   (set-alignfix-mem (join SI HI R8 Rs) Rdm)
  		   (set (mem QI (join SI HI R8 Rs)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2))
       ()
  )
***************
*** 858,862 ****
  		   (set-alignfix-mem (join SI HI R8 Rs) Rdm)
  		   (set (mem QI (join SI HI R8 Rs)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (set Rs (add Rs (add ws2 1))))
       ()
--- 864,868 ----
  		   (set-alignfix-mem (join SI HI R8 Rs) Rdm)
  		   (set (mem QI (join SI HI R8 Rs)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (set Rs (add Rs (add ws2 1))))
       ()
***************
*** 869,873 ****
       (+ OP1_6 OP2A_E ws2 Rs OP4M_0 Rdm)
       (sequence ()
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
--- 875,879 ----
       (+ OP1_6 OP2A_E ws2 Rs OP4M_0 Rdm)
       (sequence ()
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
***************
*** 883,888 ****
       (+ OP1_7 OP2A_4 ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)))
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12)))))
       ()
  )
--- 889,894 ----
       (+ OP1_7 OP2A_4 ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
       (if ws2
! 	 (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)) ws2)
! 	 (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12))) ws2))
       ()
  )
***************
*** 895,900 ****
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12)))))
  	       (set Rs (add Rs (add ws2 1))))
       ()
--- 901,906 ----
       (sequence ()
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12))) ws2))
  	       (set Rs (add Rs (add ws2 1))))
       ()
***************
*** 909,914 ****
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)))
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12))))))
       ()
  )
--- 915,920 ----
  	       (set Rs (sub Rs (add ws2 1)))
  	       (if ws2
! 		   (set-psw Rdm (index-of Rdm) (alignfix-mem (add (join SI HI Rb Rs) imm12)) ws2)
! 		   (set-psw Rdm (index-of Rdm) (and #xFF (mem QI (add (join SI HI Rb Rs) imm12))) ws2)))
       ()
  )
***************
*** 924,928 ****
  			Rdm)
  		   (set (mem QI (add (join SI HI Rb Rs) imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm))
       ()
  )
--- 930,934 ----
  			Rdm)
  		   (set (mem QI (add (join SI HI Rb Rs) imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2))
       ()
  )
***************
*** 938,942 ****
  		   (set (mem HI (and (add (join SI HI Rb Rs) imm12) #xFFFFFFFE)) Rdm)
  		   (set (mem QI (add (join SI HI Rb Rs) imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (set Rs (add Rs (add ws2 1))))
       ()
--- 944,948 ----
  		   (set (mem HI (and (add (join SI HI Rb Rs) imm12) #xFFFFFFFE)) Rdm)
  		   (set (mem QI (add (join SI HI Rb Rs) imm12)) Rdm))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (set Rs (add Rs (add ws2 1))))
       ()
***************
*** 950,954 ****
       (sequence ()
  	       (set Rs (sub Rs 1))
! 	       (set-psw-nowrite (index-of Rdm) Rdm)
  	       (if ws2
  		   (set (mem HI (and (add (join SI HI Rb Rs) imm12) #xFFFFFFFE)) Rdm)
--- 956,960 ----
       (sequence ()
  	       (set Rs (sub Rs 1))
! 	       (set-psw-nowrite (index-of Rdm) Rdm ws2)
  	       (if ws2
  		   (set (mem HI (and (add (join SI HI Rb Rs) imm12) #xFFFFFFFE)) Rdm)
***************
*** 962,966 ****
       ("mask $Rd,$Rs")
       (+ OP1_3 OP2_3 Rs Rd)
!      (set-psw Rd (index-of Rd) (or HI (and HI Rd (inv HI Rs)) (and (reg HI h-gr Rpsw) Rs)))
       ()
  )
--- 968,972 ----
       ("mask $Rd,$Rs")
       (+ OP1_3 OP2_3 Rs Rd)
!      (set-psw Rd (index-of Rd) (or HI (and HI Rd (inv HI Rs)) (and (reg HI h-gr Rpsw) Rs)) 1)
       ()
  )
***************
*** 971,975 ****
       ("mask $Rd,#$imm16")
       (+ OP1_3 OP2_0 OP3_E Rd imm16)
!      (set-psw Rd (index-of Rd) (or (and Rd (inv imm16)) (and (reg HI h-gr Rpsw) imm16)))
       ()
  )
--- 977,981 ----
       ("mask $Rd,#$imm16")
       (+ OP1_3 OP2_0 OP3_E Rd imm16)
!      (set-psw Rd (index-of Rd) (or (and Rd (inv imm16)) (and (reg HI h-gr Rpsw) imm16)) 1)
       ()
  )
***************
*** 1006,1010 ****
       (set-psw Rd (index-of Rd) (or (or (and (sll Rd 4) #xF0)
  			 (and (srl Rd 4) #x0F))
! 		     (and Rd #xFF00)))
       ()
  )
--- 1012,1016 ----
       (set-psw Rd (index-of Rd) (or (or (and (sll Rd 4) #xF0)
  			 (and (srl Rd 4) #x0F))
! 		     (and Rd #xFF00)) 0)
       ()
  )
***************
*** 1015,1019 ****
       ("swpb $Rd")
       (+ OP1_3 OP2_0 OP3_8 Rd)
!      (set-psw Rd (index-of Rd) (or (sll Rd 8) (srl Rd 8)))
       ()
  )
--- 1021,1025 ----
       ("swpb $Rd")
       (+ OP1_3 OP2_0 OP3_8 Rd)
!      (set-psw Rd (index-of Rd) (or (sll Rd 8) (srl Rd 8)) 1)
       ()
  )
***************
*** 1027,1031 ****
  	       (set foo Rs)
  	       (set Rs Rd)
! 	       (set-psw Rd (index-of Rd) foo))
       ()
  )
--- 1033,1037 ----
  	       (set foo Rs)
  	       (set Rs Rd)
! 	       (set-psw Rd (index-of Rd) foo 1))
       ()
  )
***************
*** 1037,1041 ****
       ("and $Rd,$Rs")
       (+ OP1_4 OP2_0 Rs Rd)
!      (set-psw Rd (index-of Rd) (and Rd Rs))
       ()
  )
--- 1043,1047 ----
       ("and $Rd,$Rs")
       (+ OP1_4 OP2_0 Rs Rd)
!      (set-psw Rd (index-of Rd) (and Rd Rs) 1)
       ()
  )
***************
*** 1046,1050 ****
       ("and Rx,#$imm8")
       (+ OP1_4 OP2_1 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw (and (reg HI h-gr Rpsw) imm8))
       ()
  )
--- 1052,1056 ----
       ("and Rx,#$imm8")
       (+ OP1_4 OP2_1 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw (and (reg HI h-gr Rpsw) imm8) 1)
       ()
  )
***************
*** 1055,1059 ****
       ("and $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_0 Rd imm16)
!      (set-psw Rd (index-of Rd) (and Rd imm16))
       ()
  )
--- 1061,1065 ----
       ("and $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_0 Rd imm16)
!      (set-psw Rd (index-of Rd) (and Rd imm16) 1)
       ()
  )
***************
*** 1064,1068 ****
       ("or $Rd,$Rs")
       (+ OP1_4 OP2_2 Rs Rd)
!      (set-psw Rd (index-of Rd) (or Rd Rs))
       ()
  )
--- 1070,1074 ----
       ("or $Rd,$Rs")
       (+ OP1_4 OP2_2 Rs Rd)
!      (set-psw Rd (index-of Rd) (or Rd Rs) 1)
       ()
  )
***************
*** 1073,1077 ****
       ("or Rx,#$imm8")
       (+ OP1_4 OP2_3 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw (or (reg HI h-gr Rpsw) imm8))
       ()
  )
--- 1079,1083 ----
       ("or Rx,#$imm8")
       (+ OP1_4 OP2_3 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw (or (reg HI h-gr Rpsw) imm8) 1)
       ()
  )
***************
*** 1082,1086 ****
       ("or $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_1 Rd imm16)
!      (set-psw Rd (index-of Rd) (or Rd imm16))
       ()
  )
--- 1088,1092 ----
       ("or $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_1 Rd imm16)
!      (set-psw Rd (index-of Rd) (or Rd imm16) 1)
       ()
  )
***************
*** 1091,1095 ****
       ("xor $Rd,$Rs")
       (+ OP1_4 OP2_4 Rs Rd)
!      (set-psw Rd (index-of Rd) (xor Rd Rs))
       ()
  )
--- 1097,1101 ----
       ("xor $Rd,$Rs")
       (+ OP1_4 OP2_4 Rs Rd)
!      (set-psw Rd (index-of Rd) (xor Rd Rs) 1)
       ()
  )
***************
*** 1100,1104 ****
       ("xor Rx,#$imm8")
       (+ OP1_4 OP2_5 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw (xor (reg HI h-gr Rpsw) imm8))
       ()
  )
--- 1106,1110 ----
       ("xor Rx,#$imm8")
       (+ OP1_4 OP2_5 imm8)
!      (set-psw (reg HI h-gr Rpsw) Rpsw (xor (reg HI h-gr Rpsw) imm8) 1)
       ()
  )
***************
*** 1109,1113 ****
       ("xor $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_2 Rd imm16)
!      (set-psw Rd (index-of Rd) (xor Rd imm16))
       ()
  )
--- 1115,1119 ----
       ("xor $Rd,#$imm16")
       (+ OP1_3 OP2_1 OP3_2 Rd imm16)
!      (set-psw Rd (index-of Rd) (xor Rd imm16) 1)
       ()
  )
***************
*** 1118,1122 ****
       ("not $Rd")
       (+ OP1_3 OP2_0 OP3_B Rd)
!      (set-psw Rd (index-of Rd) (inv Rd))
       ()
  )
--- 1124,1128 ----
       ("not $Rd")
       (+ OP1_3 OP2_0 OP3_B Rd)
!      (set-psw Rd (index-of Rd) (inv Rd) 1)
       ()
  )
***************
*** 1279,1283 ****
       ("inc $Rd,#$imm2")
       (+ OP1_3 OP2_0 OP3A_0 imm2 Rd)
!      (set-psw Rd (index-of Rd) (add Rd (add imm2 1)))
       ()
  )
--- 1285,1289 ----
       ("inc $Rd,#$imm2")
       (+ OP1_3 OP2_0 OP3A_0 imm2 Rd)
!      (set-psw Rd (index-of Rd) (add Rd (add imm2 1)) 1)
       ()
  )
***************
*** 1295,1299 ****
       ("dec $Rd,#$imm2")
       (+ OP1_3 OP2_0 OP3A_1 imm2 Rd)
!      (set-psw Rd (index-of Rd) (sub Rd (add imm2 1)))
       ()
  )
--- 1301,1305 ----
       ("dec $Rd,#$imm2")
       (+ OP1_3 OP2_0 OP3A_1 imm2 Rd)
!      (set-psw Rd (index-of Rd) (sub Rd (add imm2 1)) 1)
       ()
  )
***************
*** 1344,1350 ****
  		    (srl Rd (and Rs #xF)) 
  		    (and SI (if SI (eq (and Rs #xF) 0)
! 			     Rd
  			     (srl Rd (sub (and Rs #xF) 1)))
! 			 1))
       ()
  )
--- 1350,1356 ----
  		    (srl Rd (and Rs #xF)) 
  		    (and SI (if SI (eq (and Rs #xF) 0)
! 			     psw-cy
  			     (srl Rd (sub (and Rs #xF) 1)))
! 			 1) 1)
       ()
  )
***************
*** 1358,1364 ****
  		    (srl Rd imm4) 
  		    (and SI (if SI (eq imm4 0)
! 			     Rd
  			     (srl Rd (sub imm4 1)))
! 			 1))
       ()
  )
--- 1364,1370 ----
  		    (srl Rd imm4) 
  		    (and SI (if SI (eq imm4 0)
! 			     psw-cy
  			     (srl Rd (sub imm4 1)))
! 			 1) 1)
       ()
  )
***************
*** 1372,1378 ****
  		    (sll Rd (and Rs #xF)) 
  		    (srl SI (if SI (eq (and Rs #xF) 0)
! 			     Rd
  			     (sll Rd (sub (and Rs #xF) 1)))
! 			 15))
       ()
  )
--- 1378,1384 ----
  		    (sll Rd (and Rs #xF)) 
  		    (srl SI (if SI (eq (and Rs #xF) 0)
! 			     (sll psw-cy 15)
  			     (sll Rd (sub (and Rs #xF) 1)))
! 			 15) 1)
       ()
  )
***************
*** 1386,1392 ****
  		    (sll Rd imm4) 
  		    (srl SI (if SI (eq imm4 0)
! 			     Rd
  			     (sll Rd (sub imm4 1)))
! 			 15))
       ()
  )
--- 1392,1398 ----
  		    (sll Rd imm4) 
  		    (srl SI (if SI (eq imm4 0)
! 			     (sll psw-cy 15)
  			     (sll Rd (sub imm4 1)))
! 			 15) 1)
       ()
  )
***************
*** 1400,1406 ****
  		    (sra HI Rd (and Rs #xF)) 
  		    (and SI (if SI (eq (and Rs #xF) 0)
! 			     Rd
  			     (srl Rd (sub (and Rs #xF) 1)))
! 			 1))
       ()
  )
--- 1406,1412 ----
  		    (sra HI Rd (and Rs #xF)) 
  		    (and SI (if SI (eq (and Rs #xF) 0)
! 			     psw-cy
  			     (srl Rd (sub (and Rs #xF) 1)))
! 			 1) 1)
       ()
  )
***************
*** 1414,1420 ****
  		    (sra HI Rd imm4) 
  		    (and SI (if SI (eq imm4 0)
! 			     Rd
  			     (srl Rd (sub imm4 1)))
! 			 1))
       ()
  )
--- 1420,1426 ----
  		    (sra HI Rd imm4) 
  		    (and SI (if SI (eq imm4 0)
! 			     psw-cy
  			     (srl Rd (sub imm4 1)))
! 			 1) 1)
       ()
  )
***************
*** 1426,1430 ****
       ("set1 $Rd,#$imm4")
       (+ OP1_0 OP2_9 imm4 Rd)
!      (set-psw Rd (index-of Rd) (or Rd (sll 1 imm4)))
       ()
  )
--- 1432,1436 ----
       ("set1 $Rd,#$imm4")
       (+ OP1_0 OP2_9 imm4 Rd)
!      (set-psw Rd (index-of Rd) (or Rd (sll 1 imm4)) 1)
       ()
  )
***************
*** 1435,1439 ****
       ("set1 $Rd,$Rs")
       (+ OP1_0 OP2_B Rs Rd)
!      (set-psw Rd (index-of Rd) (or Rd (sll 1 (and Rs #xF))))
       ()
  )
--- 1441,1445 ----
       ("set1 $Rd,$Rs")
       (+ OP1_0 OP2_B Rs Rd)
!      (set-psw Rd (index-of Rd) (or Rd (sll 1 (and Rs #xF))) 1)
       ()
  )
***************
*** 1444,1448 ****
       ("set1 $lmem8,#$imm3")
       (+ OP1_E imm3 OP2M_1 lmem8)
!      (set-mem-psw (mem QI lmem8) (or (mem QI lmem8) (sll 1 imm3)))
       ()
  )
--- 1450,1454 ----
       ("set1 $lmem8,#$imm3")
       (+ OP1_E imm3 OP2M_1 lmem8)
!      (set-mem-psw (mem QI lmem8) (or (mem QI lmem8) (sll 1 imm3)) 0)
       ()
  )
***************
*** 1452,1456 ****
       ("set1 $hmem8,#$imm3")
       (+ OP1_F imm3 OP2M_1 hmem8)
!      (set-mem-psw (mem QI hmem8) (or (mem QI hmem8) (sll 1 imm3)))
       ()
  )
--- 1458,1462 ----
       ("set1 $hmem8,#$imm3")
       (+ OP1_F imm3 OP2M_1 hmem8)
!      (set-mem-psw (mem QI hmem8) (or (mem QI hmem8) (sll 1 imm3)) 0)
       ()
  )
***************
*** 1461,1465 ****
       ("clr1 $Rd,#$imm4")
       (+ OP1_0 OP2_8 imm4 Rd)
!      (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 imm4))))
       ()
  )
--- 1467,1471 ----
       ("clr1 $Rd,#$imm4")
       (+ OP1_0 OP2_8 imm4 Rd)
!      (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 imm4))) 1)
       ()
  )
***************
*** 1470,1474 ****
       ("clr1 $Rd,$Rs")
       (+ OP1_0 OP2_A Rs Rd)
!      (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 (and Rs #xF)))))
       ()
  )
--- 1476,1480 ----
       ("clr1 $Rd,$Rs")
       (+ OP1_0 OP2_A Rs Rd)
!      (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 (and Rs #xF)))) 1)
       ()
  )
***************
*** 1479,1483 ****
       ("clr1 $lmem8,#$imm3")
       (+ OP1_E imm3 OP2M_0 lmem8)
!      (set-mem-psw (mem QI lmem8) (and (mem QI lmem8) (inv (sll 1 imm3))))
       ()
  )
--- 1485,1489 ----
       ("clr1 $lmem8,#$imm3")
       (+ OP1_E imm3 OP2M_0 lmem8)
!      (set-mem-psw (mem QI lmem8) (and (mem QI lmem8) (inv (sll 1 imm3))) 0)
       ()
  )
***************
*** 1487,1491 ****
       ("clr1 $hmem8,#$imm3")
       (+ OP1_F imm3 OP2M_0 hmem8)
!      (set-mem-psw (mem QI hmem8) (and (mem QI hmem8) (inv (sll 1 imm3))))
       ()
  )
--- 1493,1497 ----
       ("clr1 $hmem8,#$imm3")
       (+ OP1_F imm3 OP2M_0 hmem8)
!      (set-mem-psw (mem QI hmem8) (and (mem QI hmem8) (inv (sll 1 imm3))) 0)
       ()
  )
***************
*** 1498,1502 ****
       ("cbw $Rd")
       (+ OP1_3 OP2_0 OP3_A Rd)
!      (set-psw Rd (index-of Rd) (ext HI (trunc QI Rd)))
       ()
  )
--- 1504,1508 ----
       ("cbw $Rd")
       (+ OP1_3 OP2_0 OP3_A Rd)
!      (set-psw Rd (index-of Rd) (ext HI (trunc QI Rd)) 1)
       ()
  )
***************
*** 1524,1528 ****
         (or (srl (and Rd #x4000) 13)
             (srl (and Rd #x8000) 15))))))))))))))))
!      )
       ()
  )
--- 1530,1534 ----
         (or (srl (and Rd #x4000) 13)
             (srl (and Rd #x8000) 15))))))))))))))))
!        1)
       ()
  )
***************
*** 1833,1837 ****
  	       (set value (mul SI (and SI R0 #xFFFF) (and SI R2 #xFFFF)))
  	       (set psw (or (and psw #xFF9C)
! 			    (basic-psw (trunc HI value))))
  	       (set R0 (trunc HI value))
  	       (set R1 (trunc HI (srl value 16))))
--- 1839,1843 ----
  	       (set value (mul SI (and SI R0 #xFFFF) (and SI R2 #xFFFF)))
  	       (set psw (or (and psw #xFF9C)
! 			    (basic-psw (trunc HI value) 1)))
  	       (set R0 (trunc HI value))
  	       (set R1 (trunc HI (srl value 16))))
***************
*** 1845,1849 ****
       (sequence ()
  	       (set R1 (umod R0 R2))
! 	       (set-mem-psw R0 (udiv R0 R2)))
       ()
  )
--- 1851,1855 ----
       (sequence ()
  	       (set R1 (umod R0 R2))
! 	       (set-mem-psw R0 (udiv R0 R2) 1))
       ()
  )
***************
*** 1855,1859 ****
       (sequence ()
  	       (set R1 (mod HI R0 R2))
! 	       (set-mem-psw R0 (div HI R0 R2)))
       ()
  )
--- 1861,1865 ----
       (sequence ()
  	       (set R1 (mod HI R0 R2))
! 	       (set-mem-psw R0 (div HI R0 R2) 1))
       ()
  )
***************
*** 1866,1870 ****
  	       (set value (add SI (sll SI (and SI R1 #xffff) #x10) (and SI R0 #xffff)))
  	       (set R1 (mod SI value (ext SI (trunc HI R2))))
! 	       (set-mem-psw R0 (div SI value (ext SI (trunc HI R2)))))
       ()
  )
--- 1872,1876 ----
  	       (set value (add SI (sll SI (and SI R1 #xffff) #x10) (and SI R0 #xffff)))
  	       (set R1 (mod SI value (ext SI (trunc HI R2))))
! 	       (set-mem-psw R0 (div SI value (ext SI (trunc HI R2))) 1))
       ()
  )
***************
*** 1877,1885 ****
  	       (set value (add SI (sll SI (and SI R1 #xffff) #x10) (and SI R0 #xffff)))
  	       (set R1 (umod SI value R2))
! 	       (set-mem-psw R0 (udiv SI value R2)))
       ()
  )
  
  ; System Control
  
  (dni nop "nop" () ("nop") (+ (f-op #x0000)) (nop) ())
--- 1883,1895 ----
  	       (set value (add SI (sll SI (and SI R1 #xffff) #x10) (and SI R0 #xffff)))
  	       (set R1 (umod SI value R2))
! 	       (set-mem-psw R0 (udiv SI value R2) 1))
       ()
  )
  
  ; System Control
+ 
+ ; added per sanyo's req -- eq to nop for the moment, but can 
+ ; add function later
+ (dni reset "reset" () ("reset") (+ (f-op #x000f)) (nop) ())
  
  (dni nop "nop" () ("nop") (+ (f-op #x0000)) (nop) ())
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.