Semantics of the
We use the 20 bits of the immediate as
the high bits of an unsigned 21-bit integer,
whose low bit is 0 (i.e. the immediate measures multiples of 2);
the unsigned 21-bit integer is sign-extended to 32 bits,
obtaining an offset.
We add the offset to the address of the instruction,
which is passed as the
Function:
(defun exec32-jal (rd imm pc stat) (declare (xargs :guard (and (ubyte5p rd) (ubyte20p imm) (ubyte32p pc) (state32p stat)))) (let ((__function__ 'exec32-jal)) (declare (ignorable __function__)) (b* ((offset (loghead 32 (logext 21 (ash (ubyte20-fix imm) 1)))) (pc (ubyte32-fix pc)) (target-pc (+ pc offset)) (next-pc (+ pc 4)) (stat (write32-xreg rd next-pc stat)) (stat (write32-pc target-pc stat))) stat)))
Theorem:
(defthm state32p-of-exec32-jal (b* ((new-stat (exec32-jal rd imm pc stat))) (state32p new-stat)) :rule-classes :rewrite)
Theorem:
(defthm exec32-jal-of-ubyte5-fix-rd (equal (exec32-jal (ubyte5-fix rd) imm pc stat) (exec32-jal rd imm pc stat)))
Theorem:
(defthm exec32-jal-ubyte5-equiv-congruence-on-rd (implies (ubyte5-equiv rd rd-equiv) (equal (exec32-jal rd imm pc stat) (exec32-jal rd-equiv imm pc stat))) :rule-classes :congruence)
Theorem:
(defthm exec32-jal-of-ubyte20-fix-imm (equal (exec32-jal rd (ubyte20-fix imm) pc stat) (exec32-jal rd imm pc stat)))
Theorem:
(defthm exec32-jal-ubyte20-equiv-congruence-on-imm (implies (acl2::ubyte20-equiv imm imm-equiv) (equal (exec32-jal rd imm pc stat) (exec32-jal rd imm-equiv pc stat))) :rule-classes :congruence)
Theorem:
(defthm exec32-jal-of-ubyte32-fix-pc (equal (exec32-jal rd imm (ubyte32-fix pc) stat) (exec32-jal rd imm pc stat)))
Theorem:
(defthm exec32-jal-ubyte32-equiv-congruence-on-pc (implies (acl2::ubyte32-equiv pc pc-equiv) (equal (exec32-jal rd imm pc stat) (exec32-jal rd imm pc-equiv stat))) :rule-classes :congruence)
Theorem:
(defthm exec32-jal-of-state32-fix-stat (equal (exec32-jal rd imm pc (state32-fix stat)) (exec32-jal rd imm pc stat)))
Theorem:
(defthm exec32-jal-state32-equiv-congruence-on-stat (implies (state32-equiv stat stat-equiv) (equal (exec32-jal rd imm pc stat) (exec32-jal rd imm pc stat-equiv))) :rule-classes :congruence)