Read an unsigned 16-bit little endian integer from memory.
We read the byte at the given address, and the byte at the address just after, which could be 0 if the given address is the last one in the space. We put the two bytes together in little endian order.
Function:
(defun read32-mem-ubyte16-lendian (addr stat) (declare (xargs :guard (and (integerp addr) (state32p stat)))) (let ((__function__ 'read32-mem-ubyte16-lendian)) (declare (ignorable __function__)) (b* ((b0 (read32-mem-ubyte8 addr stat)) (b1 (read32-mem-ubyte8 (1+ (ifix addr)) stat))) (+ b0 (ash b1 8)))))
Theorem:
(defthm ubyte16p-of-read32-mem-ubyte16-lendian (b* ((val (read32-mem-ubyte16-lendian addr stat))) (ubyte16p val)) :rule-classes :rewrite)
Theorem:
(defthm read32-mem-ubyte16-lendian-of-ifix-addr (equal (read32-mem-ubyte16-lendian (ifix addr) stat) (read32-mem-ubyte16-lendian addr stat)))
Theorem:
(defthm read32-mem-ubyte16-lendian-int-equiv-congruence-on-addr (implies (acl2::int-equiv addr addr-equiv) (equal (read32-mem-ubyte16-lendian addr stat) (read32-mem-ubyte16-lendian addr-equiv stat))) :rule-classes :congruence)
Theorem:
(defthm read32-mem-ubyte16-lendian-of-state32-fix-stat (equal (read32-mem-ubyte16-lendian addr (state32-fix stat)) (read32-mem-ubyte16-lendian addr stat)))
Theorem:
(defthm read32-mem-ubyte16-lendian-state32-equiv-congruence-on-stat (implies (state32-equiv stat stat-equiv) (equal (read32-mem-ubyte16-lendian addr stat) (read32-mem-ubyte16-lendian addr stat-equiv))) :rule-classes :congruence)