-// --- movem <rlist>,ea -- movem ea,<rlist> --------------------------------------------------------
-//
-
-int m_movem(WORD inst, WORD siz) {
- VALUE eval;
- WORD i;
- WORD w;
- WORD rmask;
-
- if(siz & SIZB) return(error("bad size suffix"));
-
- if(siz == SIZL) inst |= 0x0040;
-
- if(*tok == '#') { // Handle #<expr>,ea
- ++tok;
- if(abs_expr(&eval) != OK) return(0);
- if(eval >= 0x10000L) return(error(range_error));
- rmask = (WORD)eval;
- goto immed1;
- }
-
- if(*tok >= KW_D0 && *tok <= KW_A7) { // <rlist>,ea
- if(reglist(&rmask) < 0) return(0);
-
- immed1:
-
- if(*tok++ != ',') return(error("missing comma"));
- if(amode(0) < 0) return(0);
- inst |= am0 | a0reg;
-
- if(!(amsktab[am0] & (C_ALTCTRL|M_APREDEC)))
- return(error("invalid addressing mode"));
-
- // If APREDEC, reverse register mask
- if(am0 == APREDEC) {
- w = rmask;
- rmask = 0;
- for(i = 0x8000; i; i >>= 1, w >>= 1)
- rmask = (WORD)((rmask << 1) | w & 1);
- }
- } else { // ea,<rlist>
- if(amode(0) < 0) return(0);
- inst |= 0x0400 | am0 | a0reg;
- if(*tok++ != ',') return(error("missing comma"));
- if(*tok == EOL) return(error("missing register list"));
-
- if(*tok == '#') { // ea,#<expr>
- ++tok;
- if(abs_expr(&eval) != OK) return(0);
- if(eval >= 0x10000) return(error(range_error));
- rmask = (WORD)eval;
- } else
- if(reglist(&rmask) < 0) return(0);
-
- if(!(amsktab[am0] & (C_CTRL|M_APOSTINC)))
- return(error("invalid addressing mode"));
- }
-
- D_word(inst);
- D_word(rmask);
- ea0gen(siz);
-
- return(0);
+// movem <rlist>,ea -- movem ea,<rlist>
+//
+int m_movem(WORD inst, WORD siz)
+{
+ VALUE eval;
+ WORD i;
+ WORD w;
+ WORD rmask;
+
+ if (siz & SIZB)
+ return error("bad size suffix");
+
+ if (siz == SIZL)
+ inst |= 0x0040;
+
+ if (*tok == '#')
+ { // Handle #<expr>,ea
+ ++tok;
+
+ if (abs_expr(&eval) != OK)
+ return 0;
+
+ if (eval >= 0x10000L)
+ return error(range_error);
+
+ rmask = (WORD)eval;
+ goto immed1;
+ }
+
+ if (*tok >= KW_D0 && *tok <= KW_A7)
+ { // <rlist>,ea
+ if (reglist(&rmask) < 0)
+ return 0;
+
+immed1:
+ if (*tok++ != ',')
+ return error("missing comma");
+
+ if (amode(0) < 0)
+ return 0;
+
+ inst |= am0 | a0reg;
+
+ if (!(amsktab[am0] & (C_ALTCTRL|M_APREDEC)))
+ return error("invalid addressing mode");
+
+ // If APREDEC, reverse register mask
+ if (am0 == APREDEC)
+ {
+ w = rmask;
+ rmask = 0;
+
+ for(i=0x8000; i; i>>=1, w>>=1)
+ rmask = (WORD)((rmask << 1) | w & 1);
+ }
+ }
+ else
+ { // ea,<rlist>
+ if (amode(0) < 0)
+ return 0;
+
+ inst |= 0x0400 | am0 | a0reg;
+
+ if (*tok++ != ',')
+ return error("missing comma");
+
+ if (*tok == EOL)
+ return error("missing register list");
+
+ if (*tok == '#')
+ { // ea,#<expr>
+ ++tok;
+
+ if (abs_expr(&eval) != OK)
+ return 0;
+
+ if (eval >= 0x10000)
+ return error(range_error);
+
+ rmask = (WORD)eval;
+ }
+ else if (reglist(&rmask) < 0)
+ return 0;
+
+ if (!(amsktab[am0] & (C_CTRL|M_APOSTINC)))
+ return error("invalid addressing mode");
+ }
+
+ D_word(inst);
+ D_word(rmask);
+ ea0gen(siz);
+
+ return 0;