Convert an unsigned 8-bit byte to two hexadecimal digit characters.
(ubyte8=>hexchars byte) → (mv hi-char lo-char)
The most significant digit comes first, followed by the least significant one. If the byte is below 16, the first digit is zero. The hexadecimal digits above 9 are uppercase letters.
Function:
(defun ubyte8=>hexchars (byte) (declare (xargs :guard (unsigned-byte-p 8 byte))) (let ((__function__ 'ubyte8=>hexchars)) (declare (ignorable __function__)) (b* ((byte (mbe :logic (unsigned-byte-fix 8 byte) :exec byte))) (mv (str::hex-digit-to-char (floor byte 16)) (str::hex-digit-to-char (mod byte 16))))))
Theorem:
(defthm hex-digit-char-p-of-ubyte8=>hexchars.hi-char (b* (((mv ?hi-char ?lo-char) (ubyte8=>hexchars byte))) (str::hex-digit-char-p hi-char)) :rule-classes :rewrite)
Theorem:
(defthm hex-digit-char-p-of-ubyte8=>hexchars.lo-char (b* (((mv ?hi-char ?lo-char) (ubyte8=>hexchars byte))) (str::hex-digit-char-p lo-char)) :rule-classes :rewrite)
Theorem:
(defthm mv-nth-0-of-ubyte8=>hexchars-of-unsigned-byte-fix (equal (mv-nth 0 (ubyte8=>hexchars (unsigned-byte-fix 8 byte))) (mv-nth 0 (ubyte8=>hexchars byte))))
Theorem:
(defthm mv-nth-1-of-ubyte8=>hexchars-of-unsigned-byte-fix (equal (mv-nth 1 (ubyte8=>hexchars (unsigned-byte-fix 8 byte))) (mv-nth 1 (ubyte8=>hexchars byte))))