Write an unsigned 16-bit little endian integer to memory.
We decompose the integer into bytes, and we write the low one at the given address, and the high one at the address just after that, which could be 0 if the given address is the last one in the space.
Function:
(defun write64-mem-ubyte16-lendian (addr val stat) (declare (xargs :guard (and (integerp addr) (ubyte16p val) (state64p stat)))) (let ((__function__ 'write64-mem-ubyte16-lendian)) (declare (ignorable __function__)) (b* ((val (ubyte16-fix val)) (b0 (logand val 255)) (b1 (ash val -8)) (stat (write64-mem-ubyte8 addr b0 stat)) (stat (write64-mem-ubyte8 (1+ (ifix addr)) b1 stat))) stat)))
Theorem:
(defthm state64p-of-write64-mem-ubyte16-lendian (b* ((new-stat (write64-mem-ubyte16-lendian addr val stat))) (state64p new-stat)) :rule-classes :rewrite)
Theorem:
(defthm write64-mem-ubyte16-lendian-of-ifix-addr (equal (write64-mem-ubyte16-lendian (ifix addr) val stat) (write64-mem-ubyte16-lendian addr val stat)))
Theorem:
(defthm write64-mem-ubyte16-lendian-int-equiv-congruence-on-addr (implies (acl2::int-equiv addr addr-equiv) (equal (write64-mem-ubyte16-lendian addr val stat) (write64-mem-ubyte16-lendian addr-equiv val stat))) :rule-classes :congruence)
Theorem:
(defthm write64-mem-ubyte16-lendian-of-ubyte16-fix-val (equal (write64-mem-ubyte16-lendian addr (ubyte16-fix val) stat) (write64-mem-ubyte16-lendian addr val stat)))
Theorem:
(defthm write64-mem-ubyte16-lendian-ubyte16-equiv-congruence-on-val (implies (acl2::ubyte16-equiv val val-equiv) (equal (write64-mem-ubyte16-lendian addr val stat) (write64-mem-ubyte16-lendian addr val-equiv stat))) :rule-classes :congruence)
Theorem:
(defthm write64-mem-ubyte16-lendian-of-state64-fix-stat (equal (write64-mem-ubyte16-lendian addr val (state64-fix stat)) (write64-mem-ubyte16-lendian addr val stat)))
Theorem:
(defthm write64-mem-ubyte16-lendian-state64-equiv-congruence-on-stat (implies (state64-equiv stat stat-equiv) (equal (write64-mem-ubyte16-lendian addr val stat) (write64-mem-ubyte16-lendian addr val stat-equiv))) :rule-classes :congruence)