- pos = 0;
- while (opcstr[pos] && !isspace((unsigned)opcstr[pos])) {
- if (opcstr[pos] == '.') {
- pos++;
- switch (opcstr[pos]) {
-
- case 'B': sz = sz_byte; break;
- case 'W': sz = sz_word; break;
- case 'L': sz = sz_long; break;
- case 'z':
- switch (bitval[bitz]) {
- case 0: sz = sz_byte; break;
- case 1: sz = sz_word; break;
- case 2: sz = sz_long; break;
- default: abort();
- }
- break;
- default: abort();
- }
- } else {
- mnemonic[mnp] = opcstr[pos];
- if (mnemonic[mnp] == 'f') {
- find = -1;
- switch (bitval[bitf]) {
- case 0: mnemonic[mnp] = 'R'; break;
- case 1: mnemonic[mnp] = 'L'; break;
- default: abort();
- }
- }
- mnp++;
- }
- pos++;
- }
- mnemonic[mnp] = 0;
-
- /* now, we have read the mnemonic and the size */
- while (opcstr[pos] && isspace((unsigned)opcstr[pos]))
- pos++;
-
- /* A goto a day keeps the D******a away. */
- if (opcstr[pos] == 0)
- goto endofline;
-
- /* parse the source address */
- usesrc = 1;
- switch (opcstr[pos++]) {
- case 'D':
- srcmode = Dreg;
- switch (opcstr[pos++]) {
- case 'r': srcreg = bitval[bitr]; srcgather = 1; srcpos = bitpos[bitr]; break;
- case 'R': srcreg = bitval[bitR]; srcgather = 1; srcpos = bitpos[bitR]; break;
- default: abort();
- }
-
- break;
- case 'A':
- srcmode = Areg;
- switch (opcstr[pos++]) {
- case 'r': srcreg = bitval[bitr]; srcgather = 1; srcpos = bitpos[bitr]; break;
- case 'R': srcreg = bitval[bitR]; srcgather = 1; srcpos = bitpos[bitR]; break;
- default: abort();
- }
- switch (opcstr[pos]) {
- case 'p': srcmode = Apdi; pos++; break;
- case 'P': srcmode = Aipi; pos++; break;
- }
- break;
- case 'L':
- srcmode = absl;
- break;
- case '#':
- switch (opcstr[pos++]) {
- case 'z': srcmode = imm; break;
- case '0': srcmode = imm0; break;
- case '1': srcmode = imm1; break;
- case '2': srcmode = imm2; break;
- case 'i': srcmode = immi; srcreg = (int32_t)(int8_t)bitval[biti];
- if (CPU_EMU_SIZE < 4) {
- /* Used for branch instructions */
- srctype = 1;
- srcgather = 1;
- srcpos = bitpos[biti];
- }
- break;
- case 'j': srcmode = immi; srcreg = bitval[bitj];
- if (CPU_EMU_SIZE < 3) {
- /* 1..8 for ADDQ/SUBQ and rotshi insns */
- srcgather = 1;
- srctype = 3;
- srcpos = bitpos[bitj];
- }
- break;
- case 'J': srcmode = immi; srcreg = bitval[bitJ];
- if (CPU_EMU_SIZE < 5) {
- /* 0..15 */
- srcgather = 1;
- srctype = 2;
- srcpos = bitpos[bitJ];
- }
- break;
- case 'k': srcmode = immi; srcreg = bitval[bitk];
- if (CPU_EMU_SIZE < 3) {
- srcgather = 1;
- srctype = 4;
- srcpos = bitpos[bitk];
- }
- break;
- case 'K': srcmode = immi; srcreg = bitval[bitK];
- if (CPU_EMU_SIZE < 5) {
- /* 0..15 */
- srcgather = 1;
- srctype = 5;
- srcpos = bitpos[bitK];
+ wordsizes sz = sz_long;
+ int srcgather = 0, dstgather = 0;
+ int usesrc = 0, usedst = 0;
+ int srctype = 0;
+ int srcpos = -1, dstpos = -1;
+
+ amodes srcmode = am_unknown, destmode = am_unknown;
+ int srcreg = -1, destreg = -1;
+
+ for(i=0; i<lastbit; i++)
+ bitcnt[i] = bitval[i] = 0;
+
+ vmsk = 1 << id.n_variable;
+
+ for(i=0, msk=0x8000; i<16; i++, msk >>= 1)
+ {
+ if (!(msk & id.mask))
+ {
+ int currbit = id.bitpos[bitno++];
+ int bit_set;
+ vmsk >>= 1;
+ bit_set = (variants & vmsk ? 1 : 0);
+
+ if (bit_set)
+ opc |= msk;
+
+ bitpos[currbit] = 15 - i;
+ bitcnt[currbit]++;
+ bitval[currbit] <<= 1;
+ bitval[currbit] |= bit_set;
+ }