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 write32-mem-ubyte16-lendian (addr val stat) (declare (xargs :guard (and (integerp addr) (ubyte16p val) (state32p stat)))) (let ((__function__ 'write32-mem-ubyte16-lendian)) (declare (ignorable __function__)) (b* ((val (ubyte16-fix val)) (b0 (logand val 255)) (b1 (ash val -8)) (stat (write32-mem-ubyte8 addr b0 stat)) (stat (write32-mem-ubyte8 (1+ (ifix addr)) b1 stat))) stat)))
Theorem:
(defthm state32p-of-write32-mem-ubyte16-lendian (b* ((new-stat (write32-mem-ubyte16-lendian addr val stat))) (state32p new-stat)) :rule-classes :rewrite)
Theorem:
(defthm write32-mem-ubyte16-lendian-of-ifix-addr (equal (write32-mem-ubyte16-lendian (ifix addr) val stat) (write32-mem-ubyte16-lendian addr val stat)))
Theorem:
(defthm write32-mem-ubyte16-lendian-int-equiv-congruence-on-addr (implies (acl2::int-equiv addr addr-equiv) (equal (write32-mem-ubyte16-lendian addr val stat) (write32-mem-ubyte16-lendian addr-equiv val stat))) :rule-classes :congruence)
Theorem:
(defthm write32-mem-ubyte16-lendian-of-ubyte16-fix-val (equal (write32-mem-ubyte16-lendian addr (ubyte16-fix val) stat) (write32-mem-ubyte16-lendian addr val stat)))
Theorem:
(defthm write32-mem-ubyte16-lendian-ubyte16-equiv-congruence-on-val (implies (acl2::ubyte16-equiv val val-equiv) (equal (write32-mem-ubyte16-lendian addr val stat) (write32-mem-ubyte16-lendian addr val-equiv stat))) :rule-classes :congruence)
Theorem:
(defthm write32-mem-ubyte16-lendian-of-state32-fix-stat (equal (write32-mem-ubyte16-lendian addr val (state32-fix stat)) (write32-mem-ubyte16-lendian addr val stat)))
Theorem:
(defthm write32-mem-ubyte16-lendian-state32-equiv-congruence-on-stat (implies (state32-equiv stat stat-equiv) (equal (write32-mem-ubyte16-lendian addr val stat) (write32-mem-ubyte16-lendian addr val stat-equiv))) :rule-classes :congruence)