Loading a program into the model's memory.
(load-program-into-memory n64-bytes-lst x86) → (mv * x86)
Note on dealing with linear addresses emitted by GCC/LLVM:
GCC and LLVM might not always output addresses satisfying our
definition of canonical-address-p (i.e., essentially
if (canonical-address-p (n64-to-i64 address)) address = (n64-to-i64 address) else error!
Function:
(defun load-program-into-memory (n64-bytes-lst x86) (declare (xargs :stobjs (x86))) (declare (xargs :guard (n64p-byte-alistp n64-bytes-lst))) (let ((__function__ 'load-program-into-memory)) (declare (ignorable __function__)) (cond ((endp n64-bytes-lst) (mv nil x86)) (t (b* ((n64-addr (caar n64-bytes-lst)) (byte (cdar n64-bytes-lst)) ((mv flg addr) (let ((i48-addr (n64-to-i64 n64-addr))) (if (canonical-address-p i48-addr) (mv nil i48-addr) (mv t n64-addr)))) ((when flg) (mv (cons 'load-program-into-memory 'non-canonical-address) x86)) ((mv flg x86) (wml08 addr byte x86)) ((when flg) (mv (cons 'load-program-into-memory 'wml08-error) x86))) (load-program-into-memory (cdr n64-bytes-lst) x86))))))
Theorem:
(defthm x86p-mv-nth-1-load-program-into-memory (implies (x86p x86) (x86p (mv-nth 1 (load-program-into-memory n64-program-lst x86)))))