(herald (assembler ppc_mem) (env t (assembler as_open) (assembler ppc_machine) (assembler ppc_format)) (syntax-table tas-ppc-syntax-table)) ;;;; PowerPC Instruction Set: Memory Instructions ;;; Copyright (C) 2005, Taylor Campbell ;;; All rights reserved. ;;; See the LICENCE file for details. ;;; ---------------- ;;; Integer memory access ;;; Load instructions (define-d@r-memory-op lbz #b100010 #b0001010111) ;Byte (define-d@r-memory-op lbzu #b100011 #b0001110111) ;Byte & Update (define-d@r-memory-op lhz #b101000 #b0100010111) ;Halfword (define-d@r-memory-op lhzu #b101001 #b0100110111) ;Halfword & Update (define-d@r-memory-op lwz #b100000 #b0000010111) ;Word (define-d@r-memory-op lwzu #b100001 #b0000110111) ;Word & Update (define-d@r-memory-op lha #b101010 #b0101010111) ;Halfword Algebraic (define-d@r-memory-op lhau #b101011 #b0101110111) (define-ppc-op (load width rD ea) (case width ((byte) (ppc/lbz rD ea)) ((halfword) (ppc/lhz rD ea)) ((word) (ppc/lwz rD ea)) (else (ppc/load (error "illegal PPC load width ~S" width) rD ea)))) (define-ppc-op (load&update width rD ea) (case width ((byte) (ppc/lbzu rD ea)) ((halfword) (ppc/lhzu rD ea)) ((word) (ppc/lwzu rD ea)) (else (ppc/load&update (error "illegal PPC load width ~S" width) rD ea)))) ;;; Store instructions (define-d@r-memory-op stb #b100110 #b0011010111) (define-d@r-memory-op stbu #b100111 #b0011110111) (define-d@r-memory-op sth #b101100 #b0110010111) (define-d@r-memory-op sthu #b101101 #b0110110111) (define-d@r-memory-op stw #b100100 #b0010010111) (define-d@r-memory-op stwu #b100101 #b0010110111) (define-ppc-op (store width rS ea) (case width ((byte) (ppc/stb rS ea)) ((halfword) (ppc/sth rS ea)) ((word) (ppc/stw rS ea)) (else (ppc/store (error "illegal PPC store width ~S" width) rS ea)))) (define-ppc-op (store&update width rS ea) (case width ((byte) (ppc/stbu rS ea)) ((halfword) (ppc/sthu rS ea)) ((word) (ppc/stwu rS ea)) (else (ppc/store&update (error "illegal PPC store width ~S" width) rS ea)))) ;;; Load & store with byte-reverse instructions (define-reg-d@r-memory-op lhbrx #b1100010110) ;Halfword (define-reg-d@r-memory-op lwbrx #b1000010110) ;Word (define-ppc-op (lbrx width rD ea) (case width ((halfword) (ppc/lhbrx rD ea)) ((word) (ppc/lwbrx rD ea)) (else (ppc/lbrx (error "illegal PPC load byte-reverse width ~S" width) rD ea)))) (define-reg-d@r-memory-op sthbrx #b1110010110) ;Halfword (define-reg-d@r-memory-op stwbrx #b1010010110) ;Word (define-ppc-op (stbrx width rS ea) (case width ((halfword) (ppc/sthbrx rS ea)) ((word) (ppc/stwbrx rS ea)) (else (ppc/stbrx (error "illegal PPC store byte-reverse width ~S" width) rS ea)))) ;;; Load & store multiple instructions (define-imm-d@r-memory-op lmw #b101110) (define-imm-d@r-memory-op stmw #b101111) ;;; Floating-point memory access (define-d@r-memory-op lfd #b110010 #b1001010111) ;Double (define-d@r-memory-op lfdu #b110011 #b1001110111) ;Double & Update (define-d@r-memory-op lfs #b110000 #b1000010111) ;Single (define-d@r-memory-op lfsu #b110001 #b1000110111) ;Single & Update (define-ppc-op (load-float width rD ea) (case width ((double) (ppc/lfd rD ea)) ((single) (ppc/lfs rD ea)) (else (ppc/load-float (error "illegal PPC float load width ~S" width) rD ea)))) (define-ppc-op (load-float&update width rD ea) (case width ((double) (ppc/lfdu rD ea)) ((single) (ppc/lfsu rD ea)) (else (ppc/load-float&update (error "illegal PPC float load width ~S" width) rD ea)))) (define-d@r-memory-op stfd #b110100 #b1011010111) ;Double (define-d@r-memory-op stfdu #b110101 #b1011110111) ;Double & Update (define-d@r-memory-op stfs #b110000 #b1010010111) ;Single (define-d@r-memory-op stfsu #b110001 #b1010110111) ;Single & Update (define-ppc-op (store-float width rS ea) (case width ((double) (ppc/stfd rS ea)) ((single) (ppc/stfs rS ea)) (else (ppc/store-float (error "illegal PPC float store width ~S" width) rS ea)))) (define-ppc-op (store-float&update width rS ea) (case width ((double) (ppc/stfdu rS ea)) ((single) (ppc/stfsu rS ea)) (else (ppc/store-float&update (error "illegal PPC float store width ~S" width) rS ea)))) (define-reg-d@r-memory-op stfiwx #b1111010111) ;Store FP as Int. Word