(comment "16 bit immediate")
(attrs)
(type h-uint)
- (index f-imm16)
+ (index f-imm16)
(handlers (parse "immediate16"))
)
; Useful macros.
; THe Z8, Z16, PT, and S flags of the PSW.
-(define-pmacro (basic-psw value)
+(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 HI value) 6))))
+ (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)
+(define-pmacro (set-psw Rd index value ws)
(sequence ((HI nvalue))
(set nvalue value)
(set (reg HI h-gr index) nvalue)
(set psw (or (and psw #x0F9C)
(or (sll index 12)
- (basic-psw nvalue))))))
+ (basic-psw nvalue ws))))))
; Update the PSW for destination register Rd.
-(define-pmacro (set-psw-nowrite index value)
+(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))))))
+ (basic-psw nvalue ws))))))
; Update the PSW for destination non-register dest, set dest to value.
-(define-pmacro (set-mem-psw dest value)
+(define-pmacro (set-mem-psw dest value ws)
(sequence ((HI nvalue))
(set nvalue value)
(set psw (or (and psw #xFF9C)
- (basic-psw nvalue)))
+ (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)
- (sequence ((HI nvalue))
+(define-pmacro (set-psw-carry Rd index value carry ws)
+ (sequence ((HI nvalue) (HI newpsw))
(set nvalue value)
- (set (reg HI h-gr index) nvalue)
- (set psw (or (or (and psw #x0F98)
- (sll carry 2))
+ (set newpsw (or (or (and psw #x0F98)
+ (sll (and carry #x1) 2))
(or (sll index 12)
- (basic-psw nvalue))))))
+ (basic-psw nvalue ws))))
+ (set (reg HI h-gr index) nvalue)
+ (set psw newpsw)
+ ))
; The all-purpose addition operation.
(define-pmacro (set-psw-add Rd index a b c)
(sequence ((HI value) (HI newpsw))
(set value (addc a b c))
(set newpsw (or (or (and psw #x0F80)
- (basic-psw value))
+ (basic-psw value 1))
(or (or (sll HI (add-oflag HI a b c) 4)
(sll HI (add-cflag HI a b c) 2))
(or (and (srl HI (addc HI (and a #xF) (and b #xF) c)
(sequence ((HI value))
(set value (sub a b))
(set psw (or (or (and psw #x0F80)
- (basic-psw value))
+ (basic-psw value 1))
(or (or (sll HI (sub-oflag HI a b 0) 4)
(sll HI (sub-cflag HI a b 0) 2))
(or (and (srl HI (sub HI (and a #xF) (and b #xF))
(sequence ((HI value) (HI newpsw))
(set value (subc a b c))
(set newpsw (or (or (and psw #x0F80)
- (basic-psw value))
+ (basic-psw value 1))
(or (or (sll HI (sub-oflag HI a b c) 4)
(sll HI (sub-cflag HI a b c) 2))
(or (and (srl HI (subc HI (and a #xF) (and b #xF) c)
(or (sll SI c 31)
(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))))
+ (set-psw-carry (reg HI h-gr index) index (trunc HI tmpfoo) (and (srl tmpfoo 16) 1) 1)))
-; We have to be careful to get the right group of 16 shifts from the above.
+; A 17-bit rotate-right operation
(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)))
- )
+ (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)))
\f
; Move Operations
("mov$ws2 $lmem8,#$imm16")
(+ 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)))
+ (set-mem-psw (mem HI (and lmem8 #xFFFE)) imm16 ws2)
+ (set-mem-psw (mem QI lmem8) (and imm16 #xFF) ws2))
()
)
(dni movhmemimm
("mov$ws2 $hmem8,#$imm16")
(+ 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)))
+ (set-mem-psw (mem HI (and hmem8 #xFFFE)) imm16 ws2)
+ (set-mem-psw (mem QI hmem8) (and imm16 #xFF) ws2))
()
)
("mov$ws2 $Rm,$lmem8")
(+ 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)))
+ (set-psw Rm (index-of Rm) (alignfix-mem lmem8) ws2)
+ (set-psw Rm (index-of Rm) (mem QI lmem8) ws2))
()
)
(dni movhgrmem
("mov$ws2 $Rm,$hmem8")
(+ 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)))
+ (set-psw Rm (index-of Rm) (alignfix-mem hmem8) ws2)
+ (set-psw Rm (index-of Rm) (mem QI hmem8) ws2))
()
)
("mov$ws2 $lmem8,$Rm")
(+ OP1_9 Rm ws2 lmem8)
(if ws2
- (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm)
- (set-mem-psw (mem QI lmem8) Rm))
+ (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm ws2)
+ (set-mem-psw (mem QI lmem8) Rm ws2))
()
)
(dni movhmemgr
("mov$ws2 $hmem8,$Rm")
(+ OP1_B Rm ws2 hmem8)
(if ws2
- (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm)
- (set-mem-psw (mem QI lmem8) Rm))
+ (set-mem-psw (mem HI (and lmem8 #xFFFE)) Rm ws2)
+ (set-mem-psw (mem QI lmem8) Rm ws2))
()
)
("mov$ws2 $Rdm,($Rs)")
(+ 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))))
+ (set-psw Rdm (index-of Rdm) (alignfix-mem Rs) ws2)
+ (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs)) ws2))
()
)
(+ OP1_6 OP2A_0 ws2 Rs OP4M_0 Rdm)
(sequence ()
(if ws2
- (set-psw Rdm (index-of Rdm) (alignfix-mem Rs))
- (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs))))
+ (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))))
()
)
(sequence ()
(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)))))
+ (set-psw Rdm (index-of Rdm) (alignfix-mem Rs) ws2)
+ (set-psw Rdm (index-of Rdm) (and #xFF (mem QI Rs)) ws2)))
()
)
(if ws2
(set-alignfix-mem Rs Rdm)
(set (mem QI Rs) Rdm))
- (set-psw-nowrite (index-of Rdm) Rdm))
+ (set-psw-nowrite (index-of Rdm) Rdm ws2))
()
)
(if ws2
(set-alignfix-mem Rs Rdm)
(set (mem QI Rs) Rdm))
- (set-psw-nowrite (index-of Rdm) Rdm)
+ (set-psw-nowrite (index-of Rdm) Rdm ws2)
(set Rs (add Rs (add ws2 1))))
()
)
(+ OP1_6 OP2A_A ws2 Rs OP4M_0 Rdm)
(sequence ()
(set Rs (sub Rs (add ws2 1)))
- (set-psw-nowrite (index-of Rdm) Rdm)
+ (set-psw-nowrite (index-of Rdm) Rdm ws2)
(if ws2
(set-alignfix-mem Rs Rdm)
(set (mem QI Rs) Rdm)))
("mov$ws2 $Rdm,($Rs,$imm12)")
(+ 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)))))
+ (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))
()
)
(+ OP1_6 OP2A_0 ws2 Rs OP4M_1 Rdm OP5_0 imm12)
(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-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))))
()
)
(sequence ()
(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))))))
+ (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)))
()
)
(if ws2
(set-alignfix-mem (add Rs imm12) Rdm)
(set (mem QI (add Rs imm12)) Rdm))
- (set-psw-nowrite (index-of Rdm) Rdm))
+ (set-psw-nowrite (index-of Rdm) Rdm ws2))
()
)
(if ws2
(set-alignfix-mem (add Rs imm12) Rdm)
(set (mem QI (add Rs imm12)) Rdm))
- (set-psw-nowrite (index-of Rdm) Rdm)
+ (set-psw-nowrite (index-of Rdm) Rdm ws2)
(set Rs (add Rs 1)))
()
)
(+ OP1_6 OP2A_A ws2 Rs OP4M_1 Rdm OP5_0 imm12)
(sequence ()
(set Rs (sub Rs 1))
- (set-psw-nowrite (index-of Rdm) Rdm)
+ (set-psw-nowrite (index-of Rdm) Rdm ws2)
(if ws2
(set-alignfix-mem (add Rs imm12) Rdm)
(set (mem QI (add Rs imm12)) Rdm)))
()
("mov $Rd,$Rs")
(+ OP1_4 OP2_6 Rs Rd)
- (set-psw Rd (index-of Rd) Rs)
+ (set-psw Rd (index-of Rd) Rs 1)
()
)
()
("mov.w Rx,#$imm8")
(+ OP1_4 OP2_7 imm8)
- (set-psw (reg HI h-gr Rpsw) Rpsw imm8)
+ (set-psw (reg HI h-gr Rpsw) Rpsw imm8 1)
()
)
()
("mov.w $Rm,#$imm8small")
(+ OP1_2 Rm OP2M_1 imm8small)
- (set-psw Rm (index-of Rm) imm8small)
+ (set-psw Rm (index-of Rm) imm8small 1)
()
)
()
("mov.w $Rd,#$imm16")
(+ OP1_3 OP2_1 OP3_3 Rd imm16)
- (set-psw Rd (index-of Rd) imm16)
+ (set-psw Rd (index-of Rd) imm16 1)
()
)
()
("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)))
+ (set-psw Rd (index-of Rd) (or (and Rd #xFF00) (and (reg HI h-gr Rpsw) #xFF)) 0)
()
)
()
("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)))
+ (set-psw Rd (index-of Rd) (or (and Rd #x00FF) (and (reg HI h-gr Rpsw) #xFF00)) 1)
()
)
("movf$ws2 $Rdm,($Rs)")
(+ 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)))))
+ (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))
()
)
(+ OP1_6 OP2A_4 ws2 Rs OP4M_0 Rdm)
(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-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))))
()
)
(sequence ()
(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))))))
+ (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)))
()
)
(if ws2
(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-psw-nowrite (index-of Rdm) Rdm ws2))
()
)
(if ws2
(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-psw-nowrite (index-of Rdm) Rdm ws2)
(set Rs (add Rs (add ws2 1))))
()
)
("movf$ws2 (--$Rs),$Rdm")
(+ OP1_6 OP2A_E ws2 Rs OP4M_0 Rdm)
(sequence ()
- (set-psw-nowrite (index-of Rdm) Rdm)
+ (set-psw-nowrite (index-of Rdm) Rdm ws2)
(set Rs (sub Rs (add ws2 1)))
(if ws2
(set-alignfix-mem (join SI HI R8 Rs) Rdm)
("movf$ws2 $Rdm,($Rb,$Rs,$imm12)")
(+ 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)))))
+ (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))
()
)
(+ OP1_6 OP2A_4 ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
(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-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))))
()
)
(sequence ()
(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))))))
+ (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 (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-psw-nowrite (index-of Rdm) Rdm ws2))
()
)
(if ws2
(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-psw-nowrite (index-of Rdm) Rdm ws2)
(set Rs (add Rs (add ws2 1))))
()
)
(+ OP1_6 OP2A_E ws2 Rs OP4M_1 Rdm OP5A_0 Rb imm12)
(sequence ()
(set Rs (sub Rs 1))
- (set-psw-nowrite (index-of Rdm) Rdm)
+ (set-psw-nowrite (index-of Rdm) Rdm ws2)
(if ws2
(set (mem HI (and (add (join SI HI Rb Rs) imm12) #xFFFFFFFE)) Rdm)
(set (mem QI (add (join SI HI Rb Rs) imm12)) Rdm)))
()
("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)))
+ (set-psw Rd (index-of Rd) (or HI (and HI Rd (inv HI Rs)) (and (reg HI h-gr Rpsw) Rs)) 1)
()
)
()
("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)))
+ (set-psw Rd (index-of Rd) (or (and Rd (inv imm16)) (and (reg HI h-gr Rpsw) imm16)) 1)
()
)
\f
(+ OP1_3 OP2_0 OP3_9 Rd)
(set-psw Rd (index-of Rd) (or (or (and (sll Rd 4) #xF0)
(and (srl Rd 4) #x0F))
- (and Rd #xFF00)))
+ (and Rd #xFF00)) 0)
()
)
()
("swpb $Rd")
(+ OP1_3 OP2_0 OP3_8 Rd)
- (set-psw Rd (index-of Rd) (or (sll Rd 8) (srl Rd 8)))
+ (set-psw Rd (index-of Rd) (or (sll Rd 8) (srl Rd 8)) 1)
()
)
(sequence ((HI foo))
(set foo Rs)
(set Rs Rd)
- (set-psw Rd (index-of Rd) foo))
+ (set-psw Rd (index-of Rd) foo 1))
()
)
\f
()
("and $Rd,$Rs")
(+ OP1_4 OP2_0 Rs Rd)
- (set-psw Rd (index-of Rd) (and Rd Rs))
+ (set-psw Rd (index-of Rd) (and Rd Rs) 1)
()
)
()
("and Rx,#$imm8")
(+ OP1_4 OP2_1 imm8)
- (set-psw (reg HI h-gr Rpsw) Rpsw (and (reg HI h-gr Rpsw) imm8))
+ (set-psw (reg HI h-gr Rpsw) Rpsw (and (reg HI h-gr Rpsw) imm8) 1)
()
)
()
("and $Rd,#$imm16")
(+ OP1_3 OP2_1 OP3_0 Rd imm16)
- (set-psw Rd (index-of Rd) (and Rd imm16))
+ (set-psw Rd (index-of Rd) (and Rd imm16) 1)
()
)
()
("or $Rd,$Rs")
(+ OP1_4 OP2_2 Rs Rd)
- (set-psw Rd (index-of Rd) (or Rd Rs))
+ (set-psw Rd (index-of Rd) (or Rd Rs) 1)
()
)
()
("or Rx,#$imm8")
(+ OP1_4 OP2_3 imm8)
- (set-psw (reg HI h-gr Rpsw) Rpsw (or (reg HI h-gr Rpsw) imm8))
+ (set-psw (reg HI h-gr Rpsw) Rpsw (or (reg HI h-gr Rpsw) imm8) 1)
()
)
()
("or $Rd,#$imm16")
(+ OP1_3 OP2_1 OP3_1 Rd imm16)
- (set-psw Rd (index-of Rd) (or Rd imm16))
+ (set-psw Rd (index-of Rd) (or Rd imm16) 1)
()
)
()
("xor $Rd,$Rs")
(+ OP1_4 OP2_4 Rs Rd)
- (set-psw Rd (index-of Rd) (xor Rd Rs))
+ (set-psw Rd (index-of Rd) (xor Rd Rs) 1)
()
)
()
("xor Rx,#$imm8")
(+ OP1_4 OP2_5 imm8)
- (set-psw (reg HI h-gr Rpsw) Rpsw (xor (reg HI h-gr Rpsw) imm8))
+ (set-psw (reg HI h-gr Rpsw) Rpsw (xor (reg HI h-gr Rpsw) imm8) 1)
()
)
()
("xor $Rd,#$imm16")
(+ OP1_3 OP2_1 OP3_2 Rd imm16)
- (set-psw Rd (index-of Rd) (xor Rd imm16))
+ (set-psw Rd (index-of Rd) (xor Rd imm16) 1)
()
)
()
("not $Rd")
(+ OP1_3 OP2_0 OP3_B Rd)
- (set-psw Rd (index-of Rd) (inv Rd))
+ (set-psw Rd (index-of Rd) (inv Rd) 1)
()
)
\f
()
("inc $Rd,#$imm2")
(+ OP1_3 OP2_0 OP3A_0 imm2 Rd)
- (set-psw Rd (index-of Rd) (add Rd (add imm2 1)))
+ (set-psw Rd (index-of Rd) (add Rd (add imm2 1)) 1)
()
)
()
("dec $Rd,#$imm2")
(+ OP1_3 OP2_0 OP3A_1 imm2 Rd)
- (set-psw Rd (index-of Rd) (sub Rd (add imm2 1)))
+ (set-psw Rd (index-of Rd) (sub Rd (add imm2 1)) 1)
()
)
\f
(set-psw-carry Rd (index-of Rd)
(srl Rd (and Rs #xF))
(and SI (if SI (eq (and Rs #xF) 0)
- Rd
+ psw-cy
(srl Rd (sub (and Rs #xF) 1)))
- 1))
+ 1) 1)
()
)
(set-psw-carry Rd (index-of Rd)
(srl Rd imm4)
(and SI (if SI (eq imm4 0)
- Rd
+ psw-cy
(srl Rd (sub imm4 1)))
- 1))
+ 1) 1)
()
)
(set-psw-carry Rd (index-of Rd)
(sll Rd (and Rs #xF))
(srl SI (if SI (eq (and Rs #xF) 0)
- Rd
+ (sll psw-cy 15)
(sll Rd (sub (and Rs #xF) 1)))
- 15))
+ 15) 1)
()
)
(set-psw-carry Rd (index-of Rd)
(sll Rd imm4)
(srl SI (if SI (eq imm4 0)
- Rd
+ (sll psw-cy 15)
(sll Rd (sub imm4 1)))
- 15))
+ 15) 1)
()
)
(set-psw-carry Rd (index-of Rd)
(sra HI Rd (and Rs #xF))
(and SI (if SI (eq (and Rs #xF) 0)
- Rd
+ psw-cy
(srl Rd (sub (and Rs #xF) 1)))
- 1))
+ 1) 1)
()
)
(set-psw-carry Rd (index-of Rd)
(sra HI Rd imm4)
(and SI (if SI (eq imm4 0)
- Rd
+ psw-cy
(srl Rd (sub imm4 1)))
- 1))
+ 1) 1)
()
)
\f
()
("set1 $Rd,#$imm4")
(+ OP1_0 OP2_9 imm4 Rd)
- (set-psw Rd (index-of Rd) (or Rd (sll 1 imm4)))
+ (set-psw Rd (index-of Rd) (or Rd (sll 1 imm4)) 1)
()
)
()
("set1 $Rd,$Rs")
(+ OP1_0 OP2_B Rs Rd)
- (set-psw Rd (index-of Rd) (or Rd (sll 1 (and Rs #xF))))
+ (set-psw Rd (index-of Rd) (or Rd (sll 1 (and Rs #xF))) 1)
()
)
()
("set1 $lmem8,#$imm3")
(+ OP1_E imm3 OP2M_1 lmem8)
- (set-mem-psw (mem QI lmem8) (or (mem QI lmem8) (sll 1 imm3)))
+ (set-mem-psw (mem QI lmem8) (or (mem QI lmem8) (sll 1 imm3)) 0)
()
)
(dni set1hmemimm
()
("set1 $hmem8,#$imm3")
(+ OP1_F imm3 OP2M_1 hmem8)
- (set-mem-psw (mem QI hmem8) (or (mem QI hmem8) (sll 1 imm3)))
+ (set-mem-psw (mem QI hmem8) (or (mem QI hmem8) (sll 1 imm3)) 0)
()
)
()
("clr1 $Rd,#$imm4")
(+ OP1_0 OP2_8 imm4 Rd)
- (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 imm4))))
+ (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 imm4))) 1)
()
)
()
("clr1 $Rd,$Rs")
(+ OP1_0 OP2_A Rs Rd)
- (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 (and Rs #xF)))))
+ (set-psw Rd (index-of Rd) (and Rd (inv (sll 1 (and Rs #xF)))) 1)
()
)
()
("clr1 $lmem8,#$imm3")
(+ OP1_E imm3 OP2M_0 lmem8)
- (set-mem-psw (mem QI lmem8) (and (mem QI lmem8) (inv (sll 1 imm3))))
+ (set-mem-psw (mem QI lmem8) (and (mem QI lmem8) (inv (sll 1 imm3))) 0)
()
)
(dni clr1hmemimm
()
("clr1 $hmem8,#$imm3")
(+ OP1_F imm3 OP2M_0 hmem8)
- (set-mem-psw (mem QI hmem8) (and (mem QI hmem8) (inv (sll 1 imm3))))
+ (set-mem-psw (mem QI hmem8) (and (mem QI hmem8) (inv (sll 1 imm3))) 0)
()
)
()
("cbw $Rd")
(+ OP1_3 OP2_0 OP3_A Rd)
- (set-psw Rd (index-of Rd) (ext HI (trunc QI Rd)))
+ (set-psw Rd (index-of Rd) (ext HI (trunc QI Rd)) 1)
()
)
(or (srl (and Rd #x2000) 11)
(or (srl (and Rd #x4000) 13)
(srl (and Rd #x8000) 15))))))))))))))))
- )
+ 1)
()
)
(sequence ((SI value))
(set value (mul SI (and SI R0 #xFFFF) (and SI R2 #xFFFF)))
(set psw (or (and psw #xFF9C)
- (basic-psw (trunc HI value))))
+ (basic-psw (trunc HI value) 1)))
(set R0 (trunc HI value))
(set R1 (trunc HI (srl value 16))))
()
(+ (f-op #x00C0))
(sequence ()
(set R1 (umod R0 R2))
- (set-mem-psw R0 (udiv R0 R2)))
+ (set-mem-psw R0 (udiv R0 R2) 1))
()
)
(dni sdiv
(+ (f-op #x00C8))
(sequence ()
(set R1 (mod HI R0 R2))
- (set-mem-psw R0 (div HI R0 R2)))
+ (set-mem-psw R0 (div HI R0 R2) 1))
()
)
(dni sdivlh
(sequence ((SI value))
(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)))))
+ (set-mem-psw R0 (div SI value (ext SI (trunc HI R2))) 1))
()
)
(dni divlh
(sequence ((SI value))
(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)))
+ (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) ())
(dni halt "halt" () ("halt") (+ (f-op #x0008)) (c-call VOID "do_halt") ())