Sender: bill AT taniwha DOT tssc DOT co DOT nz Message-ID: <36F5CF26.AEED9A67@taniwha.tssc.co.nz> Date: Mon, 22 Mar 1999 17:03:34 +1200 From: Bill Currie X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.2.3 i486) MIME-Version: 1.0 To: "djgpp-workers AT delorie DOT com" Subject: djasm shift semi bug + proposal Content-Type: multipart/mixed; boundary="------------ABA82994AEC1D2A34C4FF857" Reply-To: djgpp-workers AT delorie DOT com This is a multi-part message in MIME format. --------------ABA82994AEC1D2A34C4FF857 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit (:Oh no, it's the dreaded djasm hacker that won't go away!:) There was an error in djasm's handling of Intel's `sh[lr]d' instruction (I believe it was my fault, but I can't remember if I added shld support to djasm or not). Anyway, it meant that support for, eg `shld [mem],cl' or `shld [mem],4' could not be added due to a name clash. Then again, the grammar could have taken care of the problem (sh[lr]d uses 3 ooperands, but sh[lr] uses 2), but I didn't like the idea of overloading the meaning of the mnemonic, so Intel's sh[lr]d has been changed to sh[lr]dl (for `long') and I added support for {sh,ro,sa}[lr][bwd] (I hope my use of wildcards isn't getting too confusing). Interestingly, sar[bwd] has been there for a while. I would like this patch to get in before too many people start using djasm (yeah, right, who but me actually *uses* it???), ie before 2.03. On a different issue, I would like to propose making djasm, if not a separate project, at least have it's own directory (eg src/djasm) rather than living in src/stub. I actually enjoy working on djasm, an having it in its own directory makes sense to *me*. Things I am planning on doing with djasm: o finish omf support (do you still want that, DJ?) o enums o better symbol handling (allow forward references in most expressions) o better section support (first stage, being able to swap between .text, .data and .bss at will, later maybe `real' segment support (esp 16/32 bit control)) o finalise instruction support for 486 o pentium* instructions I can imagine people flaming me with `but we have nasm' (probably not on this list, but still...). Well, I still plan on working on an elf loader stub (and lib? or will the one from Linux be suitable? (it's LGPL)), and I'm still working on my lfn driver (almost there). Bill -- Leave others their otherness. --------------ABA82994AEC1D2A34C4FF857 Content-Type: text/plain; charset=us-ascii; name="djasm.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="djasm.diff" *** src/stub/djasm.y Wed Jul 29 05:14:32 1998 --- ../djasm/djasm.y Mon Mar 22 15:05:27 1999 *************** *** 227,233 **** %token ARITH2 ARITH2B ARITH2D ARITH2W %token LXS MOVSZX MOVSZXB MOVSZXW %token JCC JCCL JCXZ LOOP SETCC ! %token SHIFT SHLRD %token ONEBYTE TWOBYTE ASCADJ %token BITTEST GROUP3 GROUP3B GROUP3D GROUP3W GROUP6 GROUP7 STRUCT %token ALIGN ARPL --- 226,232 ---- %token ARITH2 ARITH2B ARITH2D ARITH2W %token LXS MOVSZX MOVSZXB MOVSZXW %token JCC JCCL JCXZ LOOP SETCC ! %token SHIFT SHIFTB SHIFTD SHIFTW SHLRD %token ONEBYTE TWOBYTE ASCADJ %token BITTEST GROUP3 GROUP3B GROUP3D GROUP3W GROUP6 GROUP7 STRUCT %token ALIGN ARPL *************** *** 517,530 **** --- 516,544 ---- {"pushw", PUSHW, NO_ATTR}, {"pushd", PUSHD, NO_ATTR}, {"rcl", SHIFT, 2}, + {"rclb", SHIFTB, 2}, + {"rcld", SHIFTD, 2}, + {"rclw", SHIFTW, 2}, {"rcr", SHIFT, 3}, + {"rcrb", SHIFTB, 3}, + {"rcrd", SHIFTD, 3}, + {"rcrw", SHIFTW, 3}, {"ret", RET, NO_ATTR}, {"retd", RETD, NO_ATTR}, {"retf", RETF, NO_ATTR}, {"retfd", RETFD, NO_ATTR}, {"rol", SHIFT, 0}, + {"rolb", SHIFTB, 0}, + {"rold", SHIFTD, 0}, + {"rolw", SHIFTW, 0}, {"ror", SHIFT, 1}, + {"rorb", SHIFTB, 1}, + {"rord", SHIFTD, 1}, + {"rorw", SHIFTW, 1}, {"sar", SHIFT, 7}, + {"sarb", SHIFTB, 7}, + {"sard", SHIFTD, 7}, + {"sarw", SHIFTW, 7}, {"sbb", ARITH2, 3}, {"sbbb", ARITH2B, 3}, {"sbbd", ARITH2D, 3}, *************** *** 565,574 **** {"sidt", GROUP7, 1}, {"sldt", GROUP6, 0}, {"sal", SHIFT, 4}, {"shl", SHIFT, 4}, ! {"shld", SHLRD, 0xa4}, {"shr", SHIFT, 5}, ! {"shrd", SHLRD, 0xac}, {"smsw", GROUP7, 4}, {"str", GROUP6, 1}, {"sub", ARITH2, 5}, --- 579,597 ---- {"sidt", GROUP7, 1}, {"sldt", GROUP6, 0}, {"sal", SHIFT, 4}, + {"salb", SHIFTB, 4}, + {"sald", SHIFTD, 4}, + {"salw", SHIFTW, 4}, {"shl", SHIFT, 4}, ! {"shlb", SHIFTB, 4}, ! {"shld", SHIFTD, 4}, ! {"shlw", SHIFTW, 4}, ! {"shldl", SHLRD, 0xa4}, {"shr", SHIFT, 5}, ! {"shrb", SHIFTB, 5}, ! {"shrd", SHIFTD, 5}, ! {"shrw", SHIFTW, 5}, ! {"shrdl", SHLRD, 0xac}, {"smsw", GROUP7, 4}, {"str", GROUP6, 1}, {"sub", ARITH2, 5}, *************** *** 997,1006 **** --- 1020,1035 ---- | SHIFT REG8 ',' const { emitb($4 == 1 ? 0xd0 : 0xc0); modrm(3, $1, $2); if ($4 != 1) emitb($4); } | SHIFT REG8 ',' REG8 { if ($4 != 1) djerror ("Non-constant shift count must be `cl'"); emitb(0xd2); modrm(3, $1, $2); } + | SHIFTB regmem ',' const { emitb($4 == 1 ? 0xd0 : 0xc0); reg($1); if ($4 != 1) emitb($4); } + | SHIFTB regmem ',' REG8 { if ($4 != 1) djerror ("Non-constant shift count must be `cl'"); emitb(0xd2); reg($1); } | SHIFT REG16 ',' const { emitb($4 == 1 ? 0xd1 : 0xc1); modrm(3, $1, $2); if ($4 != 1) emitb($4); } | SHIFT REG16 ',' REG8 { if ($4 != 1) djerror ("Non-constant shift count must be `cl'"); emitb(0xd3); modrm(3, $1, $2); } + | SHIFTW regmem ',' const { emitb($4 == 1 ? 0xd1 : 0xc1); reg($1); if ($4 != 1) emitb($4); } + | SHIFTW regmem ',' REG8 { if ($4 != 1) djerror ("Non-constant shift count must be `cl'"); emitb(0xd3); reg($1); } | SHIFT REG32 ',' const { emitb(0x66); emitb($4 == 1 ? 0xd1 : 0xc1); modrm(3, $1, $2); if ($4 != 1) emitb($4); } | SHIFT REG32 ',' REG8 { if ($4 != 1) djerror ("Non-constant shift count must be `cl'"); emitb(0x66); emitb(0xd3); modrm(3, $1, $2); } + | SHIFTD regmem ',' const { emitb(0x66); emitb($4 == 1 ? 0xd1 : 0xc1); reg($1); if ($4 != 1) emitb($4); } + | SHIFTD regmem ',' REG8 { if ($4 != 1) djerror ("Non-constant shift count must be `cl'"); emitb(0x66); emitb(0xd3); reg($1); } | SHLRD REG16 ',' REG16 ',' const { emitb(0x0f); emitb($1); modrm(3, $4, $2); emitb($6); } *************** *** 1364,1371 **** time(&now); sprintf(exe+28, "\r\n%s generated from %s by djasm, on %.24s\r\n", argv[2], argv[1], ctime(&now)); if (copyright) ! strncat(exe+36, copyright, 476-strlen(exe+36)); ! strcat(exe+36, "\r\n\032"); if (argv[2] == 0) { --- 1393,1400 ---- time(&now); sprintf(exe+28, "\r\n%s generated from %s by djasm, on %.24s\r\n", argv[2], argv[1], ctime(&now)); if (copyright) ! strncat(exe+28, copyright, 480-strlen(exe+28)); ! strcat(exe+28, "\r\n\032"); if (argv[2] == 0) { --------------ABA82994AEC1D2A34C4FF857--