Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes register assignments in p-code semantics #1455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions plugins/arm/semantics/arm-bits.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
(set-flags r x y))
(set$ rd r))))

(defun logandnot (rd rn)
(logand rd (lnot rn)))

(defmacro shift-with-carry (shift rd rn rm cnd)
(when (condition-holds cnd)
(let ((r (cast-signed (word-width) rn)))
Expand Down Expand Up @@ -61,4 +58,5 @@

(defmacro setw (reg val)
"(set Wx V) sets a Wx register clearing the upper 32 bits."
(set$ (alias-base-register reg) val))
(set$ (alias-base-register reg)
(cast-unsigned (word-width) val)))
5 changes: 4 additions & 1 deletion plugins/ghidra/semantics/pcode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
(defmacro set# (typ dst src)
(if (is-symbol typ)
(store-word (cast-word dst) src)
(set$ dst src)))
(let ((typ (coerce (word-width dst) typ)))
(set$ dst (logor
(logandnot dst (- (lshift 1 typ) 1))
(cast-unsigned (word-width dst) src))))))

(defmacro get# (typ src)
(if (is-symbol typ) (load-word (cast-word src))
Expand Down
4 changes: 4 additions & 0 deletions plugins/primus_lisp/semantics/bits.lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
(in-package core)

(defun logandnot (rd rn)
"(logandnot X Y) is X & ~Y, i.e., X and complement of Y"
(logand rd (lnot rn)))

(defun msb (x)
"(msb X) is the most significant bit of X."
(select (- (word-width x) 1) x))
Expand Down