Message-Id: Date: Thu, 25 Jul 1996 09:49:52 +1200 From: Bill Currie To: djgpp-workers AT delorie DOT com Subject: djasm patch (group3/aa(md)/align) This patch file will update djasm.y to include ALL of group 3 instructions (imul etc), the undocumented forms of aad and aam, and allow the specification of a fill value for .align. (I had to use touch to set the date stamp on my local copy, I wish date stamps would be preseved by netscape) Bill -------------- cut -------------------- *** djasm.y Tue Jul 23 22:57:00 1996 --- new/djasm.y Fri Jul 19 08:37:56 1996 *************** *** 1,4 **** - /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ %{ --- 1,3 ---- *************** *** 135,141 **** int istemp(char *symname, char which); void do_sreg_pop(int sreg); void do_sreg_push(int sreg); ! void do_align(int p2); void set_lineaddr(); void add_copyright(char *buf); void add_rcs_ident(char *buf); --- 134,140 ---- int istemp(char *symname, char which); void do_sreg_pop(int sreg); void do_sreg_push(int sreg); ! void do_align(int p2, int val); void set_lineaddr(); void add_copyright(char *buf); void add_rcs_ident(char *buf); *************** *** 177,184 **** %token LXS MOVSZX %token JCC JCCL LOOP %token SHIFT SHLRD ! %token ONEBYTE TWOBYTE ! %token BITTEST GROUP3 GROUP6 GROUP7 %token ALIGN %token BSS %token CALL CALLF COPYRIGHT --- 176,183 ---- %token LXS MOVSZX %token JCC JCCL LOOP %token SHIFT SHLRD ! %token ONEBYTE TWOBYTE ASCADJ ! %token BITTEST GROUP3 GROUP3B GROUP3D GROUP3W GROUP6 GROUP7 %token ALIGN %token BSS %token CALL CALLF COPYRIGHT *************** *** 187,192 **** --- 186,192 ---- %token JMPW JMPB JMPF %token LINKCOFF %token MOV MOVB MOVD MOVW + %token IMUL IMULB IMULD IMULW %token ORG OUT %token POP POPW POPD PUSH PUSHW PUSHD %token RCS_ID RET RETF *************** *** 205,212 **** struct opcode opcodes[] = { "aaa", ONEBYTE, 0x37, ! "aad", TWOBYTE, 0xd50a, ! "aam", TWOBYTE, 0xd40a, "aas", ONEBYTE, 0x3f, "cbw", ONEBYTE, 0x98, "cwde", TWOBYTE, 0x6698, --- 205,212 ---- struct opcode opcodes[] = { "aaa", ONEBYTE, 0x37, ! "aad", ASCADJ, 0xd5, ! "aam", ASCADJ, 0xd4, "aas", ONEBYTE, 0x3f, "cbw", ONEBYTE, 0x98, "cwde", TWOBYTE, 0x6698, *************** *** 321,326 **** --- 321,338 ---- "decb", DECB, NO_ATTR, "decd", DECD, NO_ATTR, "decw", DECW, NO_ATTR, + "div", GROUP3, 6, + "divb", GROUP3B, 6, + "divd", GROUP3D, 6, + "divw", GROUP3W, 6, + "idiv", GROUP3, 7, + "idivb", GROUP3B, 7, + "idivd", GROUP3D, 7, + "idivw", GROUP3W, 7, + "imul", IMUL, NO_ATTR, + "imulb", IMULB, NO_ATTR, + "imuld", IMULD, NO_ATTR, + "imulw", IMULW, NO_ATTR, "in", IN, NO_ATTR, "inc", INC, NO_ATTR, "incb", INCB, NO_ATTR, *************** *** 414,419 **** --- 426,435 ---- "movw", MOVW, NO_ATTR, "movsx", MOVSZX, 0xbe, "movzx", MOVSZX, 0xb6, + "mul", GROUP3, 4, + "mulb", GROUP3B, 4, + "muld", GROUP3D, 4, + "mulw", GROUP3W, 4, "not", GROUP3, 2, "neg", GROUP3, 3, "or", ARITH2, 1, *************** *** 557,563 **** {emitb(0x81); modrm(3, $1, $2);} else modrm (0,$1,5); ! emits($4.sym,$4.ofs,REL_abs); } | ARITH2 REG16 ',' REG16 { emitb($1*8+1); modrm(3, $4, $2); } | ARITH2 regmem ',' REG16 { emitb($1*8+1); reg($4); } --- 573,579 ---- {emitb(0x81); modrm(3, $1, $2);} else modrm (0,$1,5); ! emits($4.sym,$4.ofs,REL_abs); } | ARITH2 REG16 ',' REG16 { emitb($1*8+1); modrm(3, $4, $2); } | ARITH2 regmem ',' REG16 { emitb($1*8+1); reg($4); } *************** *** 574,580 **** | ARITH2 regmem ',' REG32 { emitb(0x66); emitb($1*8+1); reg($4); } | ARITH2 REG32 ',' regmem { emitb(0x66); emitb($1*8+3); reg($2); } ! | ALIGN const { do_align($2); } | BITTEST REG16 ',' REG16 { emitb(0x0f); emitb($1*8+0x83); modrm(3, $4, $2); } | BITTEST regmem ',' REG16 { emitb(0x0f); emitb($1*8+0x83); reg($4); } --- 590,600 ---- | ARITH2 regmem ',' REG32 { emitb(0x66); emitb($1*8+1); reg($4); } | ARITH2 REG32 ',' regmem { emitb(0x66); emitb($1*8+3); reg($2); } ! | ASCADJ { emitb($1); emitb(0x0a); } ! | ASCADJ const { emitb($1); emitb($2); } ! ! | ALIGN const { do_align($2,0x90); } ! | ALIGN const ',' const { do_align($2,$4); } | BITTEST REG16 ',' REG16 { emitb(0x0f); emitb($1*8+0x83); modrm(3, $4, $2); } | BITTEST regmem ',' REG16 { emitb(0x0f); emitb($1*8+0x83); reg($4); } *************** *** 615,623 **** --- 635,678 ---- | INCW regmem { emitb(0xff); reg(0); } | INCD regmem { emitb(0x66); emitb(0xff); reg(0); } + | IMUL REG8 { emitb(0xf6); modrm(3, 5, $2); } + | IMULB regmem { emitb(0xf6); reg(5); } + | IMUL REG16 { emitb(0xf7); modrm(3, 5, $2); } + | IMULW regmem { emitb(0xf7); reg(5); } + | IMUL REG32 { emitb(0x66); emitb(0xf7); modrm(3, 5, $2); } + | IMULD regmem { emitb(0x66); emitb(0xf7); reg(5); } + | IMUL REG16 ',' REG16 { emitb(0x0f); emitb(0xaf); modrm(3, $2, $4);} + | IMUL REG32 ',' REG32 { emitb(0x66); emitb(0x0f); emitb(0xaf); modrm(3, $2, $4);} + | IMUL REG16 ',' regmem { emitb(0x0f); emitb(0xaf); reg($2); } + | IMUL REG32 ',' regmem { emitb(0x66); emitb(0x0f); emitb(0xaf); reg($2); } + | IMUL REG16 ',' regmem ',' const { if ($6>=-128 && $6<=127) + emitb(0x6b); + else + emitb(0x69); + reg($2); + if ($6>=-128 && $6<=127) + emitb($6); + else + emitw($6); + } + | IMUL REG32 ',' regmem ',' const { emitb(0x66); + if ($6>=-128 && $6<=127) + emitb(0x6b); + else + emitb(0x69); + reg($2); + if ($6>=-128 && $6<=127) + emitb($6&0xff); + else + emitd($6); + } + | GROUP3 REG8 { emitb(0xf6); modrm(3, $1, $2); } + | GROUP3B regmem { emitb(0xf6); reg($1); } | GROUP3 REG16 { emitb(0xf7); modrm(3, $1, $2); } + | GROUP3W regmem { emitb(0xf7); reg($1); } | GROUP3 REG32 { emitb(0x66); emitb(0xf7); modrm(3, $1, $2); } + | GROUP3D regmem { emitb(0x66); emitb(0xf7); reg($1); } | GROUP6 regmem { emitb(0x0f); emitb(0x00); reg($1); } | GROUP6 REG16 { emitb(0x0f); emitb(0x00); modrm(3, $1, $2); } *************** *** 1691,1701 **** num_lineaddr++; } ! void do_align(int p2) { last_align_begin = pc; while ((pc+EXE_HEADER_SIZE) % p2) ! emitb(0x90); last_align_end = pc; } --- 1746,1756 ---- num_lineaddr++; } ! void do_align(int p2, int val) { last_align_begin = pc; while ((pc+EXE_HEADER_SIZE) % p2) ! emitb(val); last_align_end = pc; }