I have found this while working on my machine desscription,
and I could reproduce this with a small synthetic testcase, attached as
foo.cpu. I've put tis file into the cgen/cpu directory, and
then with the cgen directory as the cwd, invoked guile and evaluated:
(load "dev.scm")
(load-sim)
(cload #:arch "foo" #:machs "foo")
(cgen-decode.c)
note that the expected value to check entire_insn against is 0x1324,
but generated test is:
if ((entire_insn & 0xffff) == 0x12424)
------------------------------------------------------------------------
(include "simplify.inc")
(define-arch
(name foo) ; name of cpu family
(comment "")
(default-alignment aligned)
(insn-lsb0? #f)
(machs foo)
(isas foo)
)
(define-isa
(name foo)
; The default size of an instruction in bits
(default-insn-bitsize 16)
(base-insn-bitsize 16)
(default-insn-word-bitsize 16)
)
(define-cpu
(name foo)
(comment "")
(endian either)
(word-bitsize 16)
; Generated files have an "f" suffix.
(file-transform "f")
)
(define-mach
(name foo)
(comment "")
(cpu foo)
)
(dnf f-a "op a" () 0 4)
(dnf f-b "op a" () 4 4)
(dnf f-c "op a" () 8 4)
(dnf f-d "op a" () 12 4)
(dnmf f-ac "op ac" () UINT
(f-a f-c)
(sequence () ; insert
(set (ifield f-c) (and (ifield f-ac) (const 15)))
(set (ifield f-a) (srl (ifield f-ac) (const 4)))
)
(sequence () ; extract
(set (ifield f-ac) (or (ifield f-c) (sll (ifield f-a) 4)))
)
)
(define-pmacro (dni xname xcomment xsyntax xformat xattrs xsemantics)
(define-insn
(name xname)
(comment xcomment)
(.splice attrs (.unsplice xattrs))
(syntax xsyntax)
(format xformat)
(semantics xsemantics)
)
)
(dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
(dni
swi
""
"swi"
(+ (f-ac 18) (f-b 3) (f-d 4))
()
(sequence ()
(set pc (c-call SI "foo_trap" pc 0)))
)