Date: Fri, 17 Oct 1997 19:39:35 +1100 From: Bill Currie Subject: djasm patches To: djgpp-workers AT delorie DOT com Message-id: <199710170636.TAA27205@teleng1.tait.co.nz gatekeeper.tait.co.nz> Organization: Tait Electronics Limited MIME-version: 1.0 Content-type: Multipart/Mixed; boundary=Message-Boundary-27543 Comments: Authenticated sender is Precedence: bulk --Message-Boundary-27543 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Yup, I've been hacking djasm some more. Two new instructions callfd cseg:offs32 jmpfd cseg:offs32 plus a bugfix: baseless 32 bit addressing instructions (eg [eax+eax*2]) were broken, causing me some serious headaches. I found I may have to go through all the 32 bit immediate operands to check that they are being relocated properly. They probably are, but I want to be certain. I hope the "/source/..." in the diff line doesn't cause problems, but the diff is relative to $(DJDIR). Bill -- Leave others their otherness. --Message-Boundary-27543 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Text from file 'djasm.patch' *** src/stub/djasm.y Sat Sep 27 00:51:26 1997 --- /source/kernel/djasm.y Fri Oct 17 17:13:44 1997 *************** *** 205,214 **** %token BITTEST GROUP3 GROUP3B GROUP3D GROUP3W GROUP6 GROUP7 STRUCT %token ALIGN ARPL %token BOUND BSS BSF BSR ! %token CALL CALLF COPYRIGHT %token DB DD DEC DECB DECD DECW DUP DW ENDS ENTER %token IN INC INCB INCD INCW INT INCLUDE ! %token JMPW JMPB JMPF %token LAR LEA LINKCOFF LSL %token MOV MOVB MOVD MOVW %token IMUL IMULB IMULD IMULW --- 205,214 ---- %token BITTEST GROUP3 GROUP3B GROUP3D GROUP3W GROUP6 GROUP7 STRUCT %token ALIGN ARPL %token BOUND BSS BSF BSR ! %token CALL CALLF CALLFD COPYRIGHT %token DB DD DEC DECB DECD DECW DUP DW ENDS ENTER %token IN INC INCB INCD INCW INT INCLUDE ! %token JMPW JMPB JMPF JMPFD %token LAR LEA LINKCOFF LSL %token MOV MOVB MOVD MOVW %token IMUL IMULB IMULD IMULW *************** *** 345,350 **** --- 345,351 ---- {"bts", BITTEST, 5}, {"call", CALL, NO_ATTR}, {"callf", CALLF, NO_ATTR}, + {"callfd", CALLFD, NO_ATTR}, {"cmp", ARITH2, 7}, {"cmpb", ARITH2B, 7}, {"cmpd", ARITH2D, 7}, *************** *** 440,445 **** --- 441,447 ---- {"jmp", JMPB, NO_ATTR}, {"jmpf", JMPF, NO_ATTR}, + {"jmpfd", JMPFD, NO_ATTR}, {"jmpl", JMPW, NO_ATTR}, {"lar", LAR, NO_ATTR}, {"lds", LXS, 0xc5}, *************** *** 734,739 **** --- 736,742 ---- | CALL ID { emitb(0xe8); emits($2,0,REL_16); $2->type |= SYM_code; } | CALLF regmem { emitb(0xff); reg(3); } | CALLF const ':' constID { emitb(0x9a); emits($4.sym,$4.ofs,REL_abs); emitw($2); } + | CALLFD const ':' constID { emitb(0x66); emitb(0x9a); emits($4.sym,$4.ofs,REL_abs32); emitw($2); } | COPYRIGHT STRING { strbuf[strbuflen] = 0; add_copyright(strbuf); } | RCS_ID { strbuf[strbuflen] = 0; add_rcs_ident(strbuf); } *************** *** 820,825 **** --- 823,829 ---- | JMPB ID { emitb(0xeb); emits($2,0,REL_8); $2->type |= SYM_code; } | JMPF regmem { emitb(0xff); reg(5); } | JMPF const ':' constID { emitb(0xea); emits($4.sym,$4.ofs,REL_abs); emitw($2); } + | JMPFD const ':' constID { emitb(0x66); emitb(0xea); emits($4.sym,$4.ofs,REL_abs32); emitw($2); } | LAR REG16 ',' REG16 { emitb(0x0f); emitb(0x02); modrm(3, $4, $2); } | LAR REG16 ',' regmem { emitb(0x0f); emitb(0x02); reg($2); } *************** *** 1947,1958 **** mbyte|=(sib<<8)|004; needsib=1; } } else { int sib=(005 )| (findreg((_modrm.addr32>>8 )&0xff)<<3)| (findscl((_modrm.addr32>>16)&0x0f)<<6); mbyte|=(sib<<8)|004; ! if (nooffset(mbyte|0200,1)) return; } } else { --- 1951,1967 ---- mbyte|=(sib<<8)|004; needsib=1; } + if (nooffset(mbyte,needsib)) + return; + mbyte|=0200; } else { int sib=(005 )| (findreg((_modrm.addr32>>8 )&0xff)<<3)| (findscl((_modrm.addr32>>16)&0x0f)<<6); + mbyte&=070; mbyte|=(sib<<8)|004; ! needsib=1; ! if (nooffset(mbyte,1)) return; } } else { *************** *** 1968,1977 **** fprintf(stderr,"%s:%d: Invalid registers in R/M\n", inname, lineno); total_errors ++; } } - if (nooffset(mbyte,needsib)) - return; - mbyte|=0200; } v = _modrm.offset; --- 1977,1986 ---- fprintf(stderr,"%s:%d: Invalid registers in R/M\n", inname, lineno); total_errors ++; } + if (nooffset(mbyte,needsib)) + return; + mbyte|=0200; } } v = _modrm.offset; *************** *** 1986,1992 **** p = (Patch *)malloc(sizeof(Patch)); p->next = s->patches; s->patches = p; ! p->location = pc+1; /* ALL bytes emitted below, accounts for yet to be emitted mbyte */ p->lineno = lineno; p->rel = _modrm.addr32 ? REL_abs32 : REL_abs; _modrm.regs=0; /* force offset field to be full size (2/4 bytes rather than 1) */ --- 1995,2001 ---- p = (Patch *)malloc(sizeof(Patch)); p->next = s->patches; s->patches = p; ! p->location = pc+1+needsib; /* ALL bytes emitted below, accounts for yet to be emitted mbyte */ p->lineno = lineno; p->rel = _modrm.addr32 ? REL_abs32 : REL_abs; _modrm.regs=0; /* force offset field to be full size (2/4 bytes rather than 1) */ --Message-Boundary-27543--