From d97dea2e3fc4ed351a45e056137ad7fae7a59547 Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Tue, 29 Nov 2016 16:29:42 -0500 Subject: [PATCH] Add a description of how immediate actions should be encoded. Also sets the action list type to unsigned short (uint16_t) which I think is the most appropriate type for s390x (x86 uses uint8_t and other platforms use uint32_t). --- dynasm/dasm_s390x.h | 4 ++-- dynasm/dasm_s390x.lua | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dynasm/dasm_s390x.h b/dynasm/dasm_s390x.h index b327e7a6..254db8b8 100644 --- a/dynasm/dasm_s390x.h +++ b/dynasm/dasm_s390x.h @@ -9,7 +9,7 @@ #include #include -#define DASM_ARCH "s390" +#define DASM_ARCH "s390x" #ifndef DASM_EXTERN #define DASM_EXTERN(a,b,c,d) 0 @@ -49,7 +49,7 @@ enum { #define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos)) /* Action list type. */ -typedef const unsigned int *dasm_ActList; +typedef const unsigned short *dasm_ActList; /* Per-section structure. */ typedef struct dasm_Section { diff --git a/dynasm/dasm_s390x.lua b/dynasm/dasm_s390x.lua index 556f7fe4..c73e317e 100644 --- a/dynasm/dasm_s390x.lua +++ b/dynasm/dasm_s390x.lua @@ -970,6 +970,19 @@ local function parse_template(params, template, nparams, pos) end end + + -- TODO + -- 12-bit displacements (DISP12) and 16-bit immediates (IMM16) can be put at + -- one of two locations relative to the end of the instruction. + -- To make decoding easier we should insert the actions for these immediately + -- after the halfword they modify. + -- For example, take the instruction ahik, which is laid out as follows (each + -- char is 4 bits): + -- o = op code, r = register, i = immediate + -- oorr iiii 00oo + -- This should be emitted as oorr, followed by the immediate action, followed by + -- 00oo. + wputpos(pos, op) end function op_template(params, template, nparams)