delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/05/20/10:20:53

Date: Mon, 20 May 1996 16:11:23 +0200 (MET DST)
From: MOLNAR Laszlo <s0052mol AT sun10 DOT vsz DOT bme DOT hu>
To: djgpp-workers AT delorie DOT com
Subject: djasm patch
Message-Id: <Pine.SUN.3.91.960520160539.7515A-100000@sun10>
Mime-Version: 1.0

Hi Workers,

        Optimizing the DJP executable file compressor, I realized that DJASM
doesn't always generate the smallest possible code for some instructions. In
DJP 1.03 this made the stub 50+ bytes bigger than it could be, ie. the size of
the stub became 2560 bytes.
        With this patch the stub fills in 2048 bytes again.

-------------------cut-cut-cut---------------------

*** djasm.y	Tue Dec 26 18:55:08 1995
--- E:\ML\DJP\djasm.y	Sun May 19 10:40:30 1996
***************
*** 77,80 ****
--- 77,81 ----
  int stack_ptr =	0;
  int start_ptr =	0;
+ int movacc = 0;
  
  typedef	struct Symbol {
***************
*** 541,545 ****
  
  	| ARITH2B regmem ',' const	{ emitb(0x80), reg($1); emitb($4); }
! 	| ARITH2 REG8 ',' const		{ emitb(0x80), modrm(3, $1, $2); emitb($4); }
  	| ARITH2 REG8 ',' REG8		{ emitb($1*8); modrm(3, $4, $2); }
  	| ARITH2 regmem ',' REG8	{ emitb($1*8); reg($4); }
--- 542,551 ----
  
  	| ARITH2B regmem ',' const	{ emitb(0x80), reg($1);	emitb($4); }
! 	| ARITH2 REG8 ',' const		{ if ($2)
! 					      {emitb(0x80), modrm(3, $1, $2);}
! 					  else
! 					      modrm (0,$1,4); 
! 					  emitb	($4);
! 					}
  	| ARITH2 REG8 ',' REG8		{ emitb($1*8); modrm(3,	$4, $2); }
  	| ARITH2 regmem	',' REG8	{ emitb($1*8); reg($4);	}
***************
*** 547,551 ****
  
  	| ARITH2W regmem ',' constID	{ emitb(0x81); reg($1); emits($4.sym,$4.ofs,REL_abs); }
! 	| ARITH2 REG16 ',' constID	{ emitb(0x81); modrm(3, $1, $2); 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); }
--- 553,562 ----
  
  	| ARITH2W regmem ',' constID	{ emitb(0x81); reg($1);	emits($4.sym,$4.ofs,REL_abs); }
! 	| ARITH2 REG16 ',' constID	{ if ($2)
! 					      {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); }
***************
*** 553,557 ****
  
  	| ARITH2D regmem ',' constID	{ emitb(0x66); emitb(0x81); reg($1); emits($4.sym,$4.ofs,REL_abs); emitw($4.ofs >> 16); }
! 	| ARITH2 REG32 ',' constID	{ emitb(0x66); emitb(0x81); modrm(3, $1, $2); emits($4.sym,$4.ofs,REL_abs); emitw($4.ofs >> 16); }
  	| ARITH2 REG32 ',' REG32	{ emitb(0x66); emitb($1*8+1); modrm(3, $4, $2); }
  	| ARITH2 regmem ',' REG32	{ emitb(0x66); emitb($1*8+1); reg($4); }
--- 564,573 ----
  
  	| ARITH2D regmem ',' constID	{ emitb(0x66); emitb(0x81); reg($1); emits($4.sym,$4.ofs,REL_abs); emitw($4.ofs	>> 16);	}
! 	| ARITH2 REG32 ',' constID	{ emitb(0x66);
! 					  if ($2)
! 					      {emitb(0x81); modrm(3, $1, $2);}
! 					  else
! 					      modrm (0,$1,5);
! 					  emits($4.sym,$4.ofs,REL_abs);	emitw($4.ofs >>	16); }
  	| ARITH2 REG32 ',' REG32	{ emitb(0x66); emitb($1*8+1); modrm(3, $4, $2);	}
  	| ARITH2 regmem	',' REG32	{ emitb(0x66); emitb($1*8+1); reg($4); }
***************
*** 626,644 ****
  	| MOV REG8 ',' const		{ emitb(0xb0+$2); emitb($4); }
  	| MOV REG8 ',' REG8		{ emitb(0x88), modrm(3, $4, $2); }
! 	| MOV regmem ',' REG8		{ emitb(0x88); reg($4); }
! 	| MOV REG8 ',' regmem		{ emitb(0x8a); reg($2); }
! 
  	| MOVW regmem ',' constID	{ emitb(0xc7); reg(0); emits($4.sym,$4.ofs,REL_abs); }
  	| MOV REG16 ',' constID		{ emitb(0xb8+$2); emits($4.sym,$4.ofs,REL_abs); }
  	| MOV REG16 ',' REG16		{ emitb(0x89); modrm(3, $4, $2); }
! 	| MOV regmem ',' REG16		{ emitb(0x89); reg($4); }
! 	| MOV REG16 ',' regmem		{ emitb(0x8b); reg($2); }
! 
  	| MOVD regmem ',' constID	{ emitb(0x66); emitb(0xc7); reg(0); emits($4.sym,$4.ofs,REL_abs); emitw($4.ofs >> 16); }
  	| MOV REG32 ',' constID		{ emitb(0x66); emitb(0xb8+$2); emits($4.sym,$4.ofs,REL_abs); emitw($4.ofs >> 16); }
  	| MOV REG32 ',' REG32		{ emitb(0x66); emitb(0x89); modrm(3, $4, $2); }
! 	| MOV regmem ',' REG32		{ emitb(0x66); emitb(0x89); reg($4); }
! 	| MOV REG32 ',' regmem		{ emitb(0x66); emitb(0x8b); reg($2); }
! 
  	| MOV regmem ',' SREG		{ emitb(0x8c); reg($4); }
  	| MOV REG16 ',' SREG		{ emitb(0x8c); modrm(3, $4, $2); }
--- 642,689 ----
  	| MOV REG8 ',' const		{ emitb(0xb0+$2); emitb($4); }
  	| MOV REG8 ',' REG8		{ emitb(0x88), modrm(3,	$4, $2); }
! 	| MOV regmem ',' REG8		{ if ($4==0 && _modrm.regs==0)
! 					      movacc=0xa2;
! 					  else
! 					      emitb(0x88); 
! 					  reg($4); 
! 					}
! 	| MOV REG8 ',' regmem		{ if ($2==0 && _modrm.regs==0)
! 					      movacc=0xa0;
! 					  else
! 					      emitb(0x8a);
! 					  reg($2);
! 					}
  	| MOVW regmem ',' constID	{ emitb(0xc7); reg(0); emits($4.sym,$4.ofs,REL_abs); }
  	| MOV REG16 ','	constID		{ emitb(0xb8+$2); emits($4.sym,$4.ofs,REL_abs);	}
  	| MOV REG16 ','	REG16		{ emitb(0x89); modrm(3,	$4, $2); }
! 	| MOV regmem ',' REG16		{ if ($4==0 && _modrm.regs==0)
! 					      movacc=0xa3;
! 					  else
! 					      emitb(0x89);
! 					  reg($4); 
! 					}
! 	| MOV REG16 ','	regmem		{ if ($2==0 && _modrm.regs==0)
! 					      movacc=0xa1;
! 					  else
! 					      emitb(0x8b);
! 					  reg($2);
! 					}
  	| MOVD regmem ',' constID	{ emitb(0x66); emitb(0xc7); reg(0); emits($4.sym,$4.ofs,REL_abs); emitw($4.ofs >> 16); }
  	| MOV REG32 ','	constID		{ emitb(0x66); emitb(0xb8+$2); emits($4.sym,$4.ofs,REL_abs); emitw($4.ofs >> 16); }
  	| MOV REG32 ','	REG32		{ emitb(0x66); emitb(0x89); modrm(3, $4, $2); }
! 	| MOV regmem ',' REG32		{ emitb(0x66);
! 					  if ($4==0 && _modrm.regs==0)
! 					      movacc=0xa3;
! 					  else
! 					      emitb(0x89);
! 					  reg($4);
! 					}
! 	| MOV REG32 ','	regmem		{ emitb(0x66);
! 					  if ($2==0 && _modrm.regs==0)
! 					      movacc=0xa1;
! 					  else
! 					      emitb(0x8b);
! 					  reg($2);
! 					}
  	| MOV regmem ',' SREG		{ emitb(0x8c); reg($4);	}
  	| MOV REG16 ','	SREG		{ emitb(0x8c); modrm(3,	$4, $2); }
***************
*** 724,731 ****
  	| XCHG REG8 ',' regmem		{ emitb(0x86); reg($2); }
  	| XCHG regmem ',' REG8		{ emitb(0x86); reg($4); }
! 	| XCHG REG16 ',' REG16		{ emitb(0x87); modrm(3, $2, $4); }
  	| XCHG REG16 ',' regmem		{ emitb(0x87); reg($2); }
  	| XCHG regmem ',' REG16		{ emitb(0x87); reg($4); }
! 	| XCHG REG32 ',' REG32		{ emitb(0x66); emitb(0x87); modrm(3, $2, $4); }
  	| XCHG REG32 ',' regmem		{ emitb(0x66); emitb(0x87); reg($2); }
  	| XCHG regmem ',' REG32		{ emitb(0x66); emitb(0x87); reg($4); }
--- 769,785 ----
  	| XCHG REG8 ','	regmem		{ emitb(0x86); reg($2);	}
  	| XCHG regmem ',' REG8		{ emitb(0x86); reg($4);	}
! 	| XCHG REG16 ',' REG16		{ if (($2==0) ^	($4==0))
! 					      emitb(0x90+$2+$4);
! 					  else
! 					      {emitb(0x87); modrm(3, $2, $4); }
! 					}      
  	| XCHG REG16 ',' regmem		{ emitb(0x87); reg($2);	}
  	| XCHG regmem ',' REG16		{ emitb(0x87); reg($4);	}
! 	| XCHG REG32 ',' REG32		{ emitb(0x66);
! 					  if (($2==0) ^	($4==0))
! 					      emitb(0x90+$2+$4);
! 					  else
! 					      {emitb(0x87); modrm(3, $2, $4); }
! 					}
  	| XCHG REG32 ',' regmem		{ emitb(0x66); emitb(0x87); reg($2); }
  	| XCHG regmem ',' REG32		{ emitb(0x66); emitb(0x87); reg($4); }
***************
*** 1350,1354 ****
    if (_modrm.regs == 0)
    {
!     emitb(mbyte + 6);
    }
    else if (_modrm.regs == 0x20 && _modrm.offset == 0 && _modrm.nsyms == 0)
--- 1404,1409 ----
    if (_modrm.regs == 0)
    {
!     emitb(movacc ? movacc : mbyte + 6);
!     movacc=0;
    }
    else if (_modrm.regs == 0x20 && _modrm.offset	== 0 &&	_modrm.nsyms ==	0)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019