PPU fixed-point and floating-point loads and stores.
0/1 a fixed bit, name a field, a bit the decoder ignores
ld rt (ds ds) ra
Load Doubleword
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 | 0 | rt | ra | ds | 0 | 0 | |||||||||||||||||||||
(defppu ld ((58 6) "rt:5 ra:5 ds:14" (0 2)) (:asm "ld" rt (ds ds) ra) (:doc "Load Doubleword")
(setf (gpr rt) (mem-read 64 (ea-ds ra ds))))
ldu rt (ds ds) ra
Load Doubleword with Update
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 | 0 | rt | ra | ds | 0 | 1 | |||||||||||||||||||||
(defppu ldu ((58 6) "rt:5 ra:5 ds:14" (1 2)) (:asm "ldu" rt (ds ds) ra)
(:doc "Load Doubleword with Update")
(let ((ea (ea-dsu ra ds))) (setf (gpr rt) (mem-read 64 ea)) (setf (gpr ra) ea)))
lwa rt (ds ds) ra
Load Word Algebraic
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 | 0 | rt | ra | ds | 1 | 0 | |||||||||||||||||||||
(defppu lwa ((58 6) "rt:5 ra:5 ds:14" (2 2)) (:asm "lwa" rt (ds ds) ra) (:doc "Load Word Algebraic")
(setf (gpr rt) (wrap 64 (sext 32 (mem-read 32 (ea-ds ra ds))))))
std rs (ds ds) ra
Store Doubleword
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 | 0 | rs | ra | ds | 0 | 0 | |||||||||||||||||||||
(defppu std ((62 6) "rs:5 ra:5 ds:14" (0 2)) (:asm "std" rs (ds ds) ra) (:doc "Store Doubleword")
(mem-write 64 (ea-ds ra ds) (gpr rs)))
stdu rs (ds ds) ra
Store Doubleword with Update
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 | 0 | rs | ra | ds | 0 | 1 | |||||||||||||||||||||
(defppu stdu ((62 6) "rs:5 ra:5 ds:14" (1 2)) (:asm "stdu" rs (ds ds) ra)
(:doc "Store Doubleword with Update")
(let ((ea (ea-dsu ra ds))) (mem-write 64 ea (gpr rs)) (setf (gpr ra) ea)))
stdx rs ra rb
Store Doubleword Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |||||||||||||
(defppu stdx ((31 6) "rs:5 ra:5 rb:5" (149 10) ".") (:asm "stdx" rs ra rb) (:doc "Store Doubleword Indexed")
(mem-write 64 (ea-x ra rb) (gpr rs)))
stdux rs ra rb
Store Doubleword with Update Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | |||||||||||||
(defppu stdux ((31 6) "rs:5 ra:5 rb:5" (181 10) ".") (:asm "stdux" rs ra rb)
(:doc "Store Doubleword with Update Indexed")
(let ((ea (ea-xu ra rb))) (mem-write 64 ea (gpr rs)) (setf (gpr ra) ea)))
lhbrx rt ra rb
Load Halfword Byte-Reverse Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rt | ra | rb | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | |||||||||||||
(defppu lhbrx ((31 6) "rt:5 ra:5 rb:5" (790 10) ".") (:asm "lhbrx" rt ra rb)
(:doc "Load Halfword Byte-Reverse Indexed")
(setf (gpr rt) (bswap 16 (mem-read 16 (ea-x ra rb)))))
lwbrx rt ra rb
Load Word Byte-Reverse Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rt | ra | rb | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | |||||||||||||
(defppu lwbrx ((31 6) "rt:5 ra:5 rb:5" (534 10) ".") (:asm "lwbrx" rt ra rb)
(:doc "Load Word Byte-Reverse Indexed")
(setf (gpr rt) (bswap 32 (mem-read 32 (ea-x ra rb)))))
ldbrx rt ra rb
Load Doubleword Byte-Reverse Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rt | ra | rb | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | |||||||||||||
(defppu ldbrx ((31 6) "rt:5 ra:5 rb:5" (532 10) ".") (:asm "ldbrx" rt ra rb)
(:doc "Load Doubleword Byte-Reverse Indexed")
(setf (gpr rt) (bswap 64 (mem-read 64 (ea-x ra rb)))))
sthbrx rs ra rb
Store Halfword Byte-Reverse Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | |||||||||||||
(defppu sthbrx ((31 6) "rs:5 ra:5 rb:5" (918 10) ".") (:asm "sthbrx" rs ra rb)
(:doc "Store Halfword Byte-Reverse Indexed")
(mem-write 16 (ea-x ra rb) (bswap 16 (wrap 16 (gpr rs)))))
stwbrx rs ra rb
Store Word Byte-Reverse Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | |||||||||||||
(defppu stwbrx ((31 6) "rs:5 ra:5 rb:5" (662 10) ".") (:asm "stwbrx" rs ra rb)
(:doc "Store Word Byte-Reverse Indexed")
(mem-write 32 (ea-x ra rb) (bswap 32 (wrap 32 (gpr rs)))))
stdbrx rs ra rb
Store Doubleword Byte-Reverse Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | |||||||||||||
(defppu stdbrx ((31 6) "rs:5 ra:5 rb:5" (660 10) ".") (:asm "stdbrx" rs ra rb)
(:doc "Store Doubleword Byte-Reverse Indexed")
(mem-write 64 (ea-x ra rb) (bswap 64 (gpr rs))))
lmw rt d ra
Load Multiple Word
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 | 0 | rt | ra | d | |||||||||||||||||||||||
(defppu lmw ((46 6) "rt:5 ra:5 d:16") (:asm "lmw" rt d ra) (:doc "Load Multiple Word")
(let ((ea (ea-d ra d)) (r rt))
(loop
(setf (gpr r) (mem-read 32 ea))
(when (= r 31) (return))
(setq r (+ r 1) ea (wrap 64 (+ ea 4))))))
stmw rs d ra
Store Multiple Word
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 | 1 | rs | ra | d | |||||||||||||||||||||||
(defppu stmw ((47 6) "rs:5 ra:5 d:16") (:asm "stmw" rs d ra) (:doc "Store Multiple Word")
(let ((ea (ea-d ra d)) (r rs))
(loop
(mem-write 32 ea (gpr r))
(when (= r 31) (return))
(setq r (+ r 1) ea (wrap 64 (+ ea 4))))))
lswi rt ra nb
Load String Word Immediate
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rt | ra | nb | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | |||||||||||||
(defppu lswi ((31 6) "rt:5 ra:5 nb:5" (597 10) ".") (:asm "lswi" rt ra nb)
(:doc "Load String Word Immediate")
(load-string rt (gpr0 ra) (if (= nb 0) 32 nb)))
lswx rt ra rb
Load String Word Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rt | ra | rb | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |||||||||||||
(defppu lswx ((31 6) "rt:5 ra:5 rb:5" (533 10) ".") (:asm "lswx" rt ra rb)
(:doc "Load String Word Indexed")
(load-string rt (ea-x ra rb) (xer-count)))
stswi rs ra nb
Store String Word Immediate
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | nb | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | |||||||||||||
(defppu stswi ((31 6) "rs:5 ra:5 nb:5" (725 10) ".") (:asm "stswi" rs ra nb)
(:doc "Store String Word Immediate")
(store-string rs (gpr0 ra) (if (= nb 0) 32 nb)))
stswx rs ra rb
Store String Word Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |||||||||||||
(defppu stswx ((31 6) "rs:5 ra:5 rb:5" (661 10) ".") (:asm "stswx" rs ra rb)
(:doc "Store String Word Indexed")
(store-string rs (ea-x ra rb) (xer-count)))
lwarx rt ra rb
Load Word And Reserve Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rt | ra | rb | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | |||||||||||||
(defppu lwarx ((31 6) "rt:5 ra:5 rb:5" (20 10) ".") (:asm "lwarx" rt ra rb)
(:doc "Load Word And Reserve Indexed")
(let ((ea (ea-x ra rb))) (setf (gpr rt) (reserve ea (mem-read 32 ea)))))
ldarx rt ra rb
Load Doubleword And Reserve Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rt | ra | rb | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | |||||||||||||
(defppu ldarx ((31 6) "rt:5 ra:5 rb:5" (84 10) ".") (:asm "ldarx" rt ra rb)
(:doc "Load Doubleword And Reserve Indexed")
(let ((ea (ea-x ra rb))) (setf (gpr rt) (reserve ea (mem-read 64 ea)))))
stwcx. rs ra rb
Store Word Conditional Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | ||||||||||||
(defppu stwcx. ((31 6) "rs:5 ra:5 rb:5" (150 10) "1") (:asm "stwcx." rs ra rb)
(:doc "Store Word Conditional Indexed")
(store-conditional 32 (ea-x ra rb) (gpr rs)))
stdcx. rs ra rb
Store Doubleword Conditional Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | rs | ra | rb | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | ||||||||||||
(defppu stdcx. ((31 6) "rs:5 ra:5 rb:5" (214 10) "1") (:asm "stdcx." rs ra rb)
(:doc "Store Doubleword Conditional Indexed")
(store-conditional 64 (ea-x ra rb) (gpr rs)))
dcbz ra rb
Data Cache Block set to Zero
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | ra | rb | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | ||||||||||||||
(defppu dcbz ((31 6) "..... ra:5 rb:5" (1014 10) ".") (:asm "dcbz" ra rb)
(:doc "Data Cache Block set to Zero")
(let ((base (logand (ea-x ra rb) (wrap 64 (cache-line-mask)))))
(dotimes (i (cache-line-words)) (mem-write 64 (+ base (* 8 i)) 0))))
stfiwx frs ra rb
Store Floating-Point as Integer Word Indexed
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 | 1 | frs | ra | rb | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | |||||||||||||
(defppu stfiwx ((31 6) "frs:5 ra:5 rb:5" (983 10) ".") (:asm "stfiwx" frs ra rb)
(:doc "Store Floating-Point as Integer Word Indexed")
(mem-write 32 (ea-x ra rb) (fpr frs)))
(defmacro ea-d) source(defmacro ea-d (ra d) `(wrap 64 (+ (gpr0 ,ra) (sext 16 ,d))))(defmacro ea-du) source(defmacro ea-du (ra d) `(wrap 64 (+ (gpr ,ra) (sext 16 ,d))))(defmacro ea-ds) source(defmacro ea-ds (ra ds) `(wrap 64 (+ (gpr0 ,ra) (sext 16 (ash ,ds 2)))))(defmacro ea-dsu) source(defmacro ea-dsu (ra ds) `(wrap 64 (+ (gpr ,ra) (sext 16 (ash ,ds 2)))))(defmacro ea-x) source(defmacro ea-x (ra rb) `(wrap 64 (+ (gpr0 ,ra) (gpr ,rb))))(defmacro ea-xu) source(defmacro ea-xu (ra rb) `(wrap 64 (+ (gpr ,ra) (gpr ,rb))))(defmacro def-int-loads) source(defmacro def-int-loads ((d du x xu) dop xop width sign doc)
(let ((val (if sign `(wrap 64 (sext ,width (mem-read ,width ea))) `(mem-read ,width ea))))
`(progn
,@(when d
`((defppu ,d ((,dop 6) "rt:5 ra:5 d:16") (:asm ,(ppu-mnemonic d) rt d ra) (:doc ,doc)
(let ((ea (ea-d ra d))) (setf (gpr rt) ,val)))))
,@(when du
`((defppu ,du ((,(1+ dop) 6) "rt:5 ra:5 d:16") (:asm ,(ppu-mnemonic du) rt d ra)
(:doc ,(concatenate 'string doc " with Update"))
(let ((ea (ea-du ra d))) (setf (gpr rt) ,val) (setf (gpr ra) ea)))))
(defppu ,x ((31 6) "rt:5 ra:5 rb:5" (,xop 10) ".") (:asm ,(ppu-mnemonic x) rt ra rb)
(:doc ,(concatenate 'string doc " Indexed"))
(let ((ea (ea-x ra rb))) (setf (gpr rt) ,val)))
,@(when xu
`((defppu ,xu ((31 6) "rt:5 ra:5 rb:5" (,(+ xop 32) 10) ".") (:asm ,(ppu-mnemonic xu) rt ra rb)
(:doc ,(concatenate 'string doc " with Update Indexed"))
(let ((ea (ea-xu ra rb))) (setf (gpr rt) ,val) (setf (gpr ra) ea))))))))(defmacro def-int-stores) source(defmacro def-int-stores ((d du x xu) dop xop width doc)
`(progn
(defppu ,d ((,dop 6) "rs:5 ra:5 d:16") (:asm ,(ppu-mnemonic d) rs d ra) (:doc ,doc)
(mem-write ,width (ea-d ra d) (gpr rs)))
(defppu ,du ((,(1+ dop) 6) "rs:5 ra:5 d:16") (:asm ,(ppu-mnemonic du) rs d ra)
(:doc ,(concatenate 'string doc " with Update"))
(let ((ea (ea-du ra d))) (mem-write ,width ea (gpr rs)) (setf (gpr ra) ea)))
(defppu ,x ((31 6) "rs:5 ra:5 rb:5" (,xop 10) ".") (:asm ,(ppu-mnemonic x) rs ra rb)
(:doc ,(concatenate 'string doc " Indexed"))
(mem-write ,width (ea-x ra rb) (gpr rs)))
(defppu ,xu ((31 6) "rs:5 ra:5 rb:5" (,(+ xop 32) 10) ".") (:asm ,(ppu-mnemonic xu) rs ra rb)
(:doc ,(concatenate 'string doc " with Update Indexed"))
(let ((ea (ea-xu ra rb))) (mem-write ,width ea (gpr rs)) (setf (gpr ra) ea)))))(defmacro load-string) source(defmacro load-string (rt ea n)
`(let ((r (wrap 5 (- ,rt 1))) (a ,ea) (k 0))
(dotimes (i ,n)
(when (= k 0) (setq r (wrap 5 (+ r 1))) (setf (gpr r) 0))
(setf (gpr r) (logior (gpr r) (ash (mem-read 8 a) (- 24 (* 8 k)))))
(setq a (wrap 64 (+ a 1)) k (wrap 2 (+ k 1))))))(defmacro store-string) source(defmacro store-string (rs ea n)
`(let ((r (wrap 5 (- ,rs 1))) (a ,ea) (k 0))
(dotimes (i ,n)
(when (= k 0) (setq r (wrap 5 (+ r 1))))
(mem-write 8 a (bit-field (gpr r) (- 24 (* 8 k)) 8))
(setq a (wrap 64 (+ a 1)) k (wrap 2 (+ k 1))))))(defmacro reserve) source(defmacro reserve (ea value)
`(progn (setf (ppu-reserve-addr cpu) ,ea (ppu-reserve-data cpu) ,value (ppu-reserve-valid cpu) 1)
(ppu-reserve-data cpu)))(defmacro store-conditional) source(defmacro store-conditional (n ea value)
(let ((a (gensym "EA")) (ok (gensym "OK"))
(shift (- (integer-length (1- (ppc-model-value :reservation))))))
`(let* ((,a ,ea)
(,ok (and (= (ppu-reserve-valid cpu) 1)
(= (ash ,a ,shift) (ash (ppu-reserve-addr cpu) ,shift))
(= (mem-read ,n ,a) (wrap ,n (ppu-reserve-data cpu))))))
(when ,ok (mem-write ,n ,a ,value))
(setf (ppu-reserve-valid cpu) 0)
(set-cr-field 0 (logior (ash (b2i ,ok) 1) (xer-so))))))(defmacro cache-line-mask) source(defmacro cache-line-mask () (lognot (1- (ppc-model-value :cache-line))))(defmacro cache-line-words) source(defmacro cache-line-words () (floor (ppc-model-value :cache-line) 8))(defun single->double) source(defun single->double (s)
(declare (type (unsigned-byte 32) s))
(if (fnan-p :f32 s)
(logior (ash (fsign :f32 s) 63) #x7FF0000000000000 (ash (bit-field s 0 23) 29))
(fcvt :f64 :f32 :rne s)))(defun double->single-store) source(defun double->single-store (d)
(declare (type (unsigned-byte 64) d))
(let ((e (bit-field d 52 11)))
(if (or (> e 896) (fzero-p :f64 d))
(logior (ash (bit-field d 62 2) 30) (bit-field d 29 30))
(let ((shift (- 897 e))) ; >= 1
(logior (ash (fsign :f64 d) 31)
(if (> shift 24) 0
(bit-field (ash (logior (ash 1 52) (bit-field d 0 52)) (- shift)) 29 23)))))))(defmacro def-fp-ldst) source(defmacro def-fp-ldst ((d du x xu) dop xop doc load-p width)
(flet ((body (ea-form update)
`(let ((ea ,ea-form))
,(if load-p
(if (= width 32)
`(setf (fpr frt) (single->double (mem-read 32 ea)))
`(setf (fpr frt) (mem-read 64 ea)))
(if (= width 32)
`(mem-write 32 ea (double->single-store (fpr frt)))
`(mem-write 64 ea (fpr frt))))
,@(when update `((setf (gpr ra) ea))))))
`(progn
(defppu ,d ((,dop 6) "frt:5 ra:5 d:16") (:asm ,(ppu-mnemonic d) frt d ra) (:doc ,doc)
,(body '(ea-d ra d) nil))
(defppu ,du ((,(1+ dop) 6) "frt:5 ra:5 d:16") (:asm ,(ppu-mnemonic du) frt d ra)
(:doc ,(concatenate 'string doc " with Update"))
,(body '(ea-du ra d) t))
(defppu ,x ((31 6) "frt:5 ra:5 rb:5" (,xop 10) ".") (:asm ,(ppu-mnemonic x) frt ra rb)
(:doc ,(concatenate 'string doc " Indexed"))
,(body '(ea-x ra rb) nil))
(defppu ,xu ((31 6) "frt:5 ra:5 rb:5" (,(+ xop 32) 10) ".") (:asm ,(ppu-mnemonic xu) frt ra rb)
(:doc ,(concatenate 'string doc " with Update Indexed"))
,(body '(ea-xu ra rb) t)))))Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.