]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/ng_assembly/num/word16.ma
freescale porting
[helm.git] / helm / software / matita / contribs / ng_assembly / num / word16.ma
index df45e02a725aa93aaef11732dbb00114383cd45b..80281eeea6d64064dbfa4b208a4834adbd32b3c2 100755 (executable)
@@ -28,6 +28,8 @@ include "num/byte8.ma".
 
 ndefinition word16 ≝ comp_num byte8.
 ndefinition mk_word16 ≝ λb1,b2.mk_comp_num byte8 b1 b2.
+ndefinition ext_word16 ≝ λb2.mk_comp_num byte8 〈x0,x0〉 b2.
+ndefinition ext2_word16 ≝ λe2.mk_comp_num byte8 〈x0,x0〉 〈x0,e2〉.
 
 (* \langle \rangle *)
 notation "〈x:y〉" non associative with precedence 80
@@ -63,10 +65,24 @@ ndefinition xor_w16 ≝ fop2_cn ? xor_b8.
 (* operatore Most Significant Bit *)
 ndefinition getMSB_w16 ≝ getOPH_cn ? getMSB_b8.
 ndefinition setMSB_w16 ≝ setOPH_cn ? setMSB_b8.
+ndefinition clrMSB_w16 ≝ setOPH_cn ? clrMSB_b8.
 
 (* operatore Least Significant Bit *)
 ndefinition getLSB_w16 ≝ getOPL_cn ? getLSB_b8.
 ndefinition setLSB_w16 ≝ setOPL_cn ? setLSB_b8.
+ndefinition clrLSB_w16 ≝ setOPL_cn ? clrLSB_b8.
+
+(* operatore estensione unsigned *)
+ndefinition extu_w16 ≝ λb2.〈〈x0,x0〉:b2〉.
+ndefinition extu2_w16 ≝ λe2.〈〈x0,x0〉:〈x0,e2〉〉.
+
+(* operatore estensione signed *)
+ndefinition exts_w16 ≝
+λb2.〈(match getMSB_b8 b2 with
+      [ true ⇒ 〈xF,xF〉 | false ⇒ 〈x0,x0〉 ]):b2〉.
+ndefinition exts2_w16 ≝
+λe2.(match getMSB_ex e2 with
+      [ true ⇒ 〈〈xF,xF〉:〈xF,e2〉〉 | false ⇒ 〈〈x0,x0〉:〈x0,e2〉〉 ]).
 
 (* operatore rotazione destra con carry *)
 ndefinition rcr_w16 ≝ opcr_cn ? rcr_b8.