Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!THINK.COM!taylor From: taylor@THINK.COM Newsgroups: gnu.gdb.bug Subject: GDB (ns32k) prints 3rd operand to cmpm/movm wrong Message-ID: <8906110201.AA00324@pozzo> Date: 11 Jun 89 02:01:17 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 95 On the ns32k, the value stored in memory for the 3rd operand of the cmpm/movm instructions is: (3rd operand - 1) * i where i is the integer length (1, 2, or 4). Thus the reverse computation needs to be done when disassembling the instruction. GDB doesn't. It also doesn't recognize the 2nd argument to the deid and meid instructions. Here are the changes to fix both: RCS file: RCS/ns32k-opcode.h,v retrieving revision 1.4 diff -c1 -r1.4 ns32k-opcode.h *** /tmp/,RCSt1000272 Sat Jun 10 21:44:04 1989 --- ns32k-opcode.h Sat Jun 10 21:29:09 1989 *************** *** 44,46 **** --- 44,48 ---- * Q : quad-word + * A : address * d : displacement + * b : 3rd operand of cmpm or movm instruction * q : quick *************** *** 136,140 **** { "cmpd", 6,16, 0x07, "1D2D" }, ! { "cmpmb", 14,24, 0x04ce, "1A2A3d" }, ! { "cmpmw", 14,24, 0x05ce, "1A2A3d" }, ! { "cmpmd", 14,24, 0x07ce, "1A2A3d" }, { "cmpqb", 7,16, 0x1c, "2B1q" }, --- 138,142 ---- { "cmpd", 6,16, 0x07, "1D2D" }, ! { "cmpmb", 14,24, 0x04ce, "1A2A3b" }, ! { "cmpmw", 14,24, 0x05ce, "1A2A3b" }, ! { "cmpmd", 14,24, 0x07ce, "1A2A3b" }, { "cmpqb", 7,16, 0x1c, "2B1q" }, *************** *** 220,224 **** { "movlf", 14,24, 0x163e, "1L2F" }, ! { "movmb", 14,24, 0x00ce, "1A2A3d" }, ! { "movmw", 14,24, 0x01ce, "1A2A3d" }, ! { "movmd", 14,24, 0x03ce, "1A2A3d" }, { "movqb", 7,16, 0x5c, "2B1q" }, --- 222,226 ---- { "movlf", 14,24, 0x163e, "1L2F" }, ! { "movmb", 14,24, 0x00ce, "1A2A3b" }, ! { "movmw", 14,24, 0x01ce, "1A2A3b" }, ! { "movmd", 14,24, 0x03ce, "1A2A3b" }, { "movqb", 7,16, 0x5c, "2B1q" }, =================================================================== RCS file: RCS/ns32k-pinsn.c,v retrieving revision 1.3 diff -c1 -r1.3 ns32k-pinsn.c *** /tmp/,RCSt1000272 Sat Jun 10 21:44:06 1989 --- ns32k-pinsn.c Sat Jun 10 21:24:45 1989 *************** *** 386,387 **** --- 386,388 ---- int index; + int size; *************** *** 394,395 **** --- 395,397 ---- case 'D': + case 'Q': case 'A': *************** *** 529,530 **** --- 531,553 ---- sprintf (result, "%d", get_displacement (buffer, aoffsetp)); + break; + case 'b': + Ivalue = get_displacement (buffer, aoffsetp); + /* + * Warning!! HACK ALERT! + * Operand type 'b' is only used by the cmp{b,w,d} and + * movm{b,w,d} instructions; we need to know whether + * it's a `b' or `w' or `d' instruction; and for both + * cmpm and movm it's stored at the same place so we + * just grab two bits of the opcode and look at it... + * + */ + size = bit_extract(buffer, ioffset-6, 2); + if (size == 0) /* 00 => b */ + size = 1; + else if (size == 1) /* 01 => w */ + size = 2; + else + size = 4; /* 11 => d */ + + sprintf (result, "%d", (Ivalue / size) + 1); break;