From owner-freebsd-questions@FreeBSD.ORG Wed Mar 3 06:40:27 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8B6DA16A4CE for ; Wed, 3 Mar 2004 06:40:27 -0800 (PST) Received: from lilzmailso01.liwest.at (lilzmailso01.liwest.at [212.33.55.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2AC1843D1D for ; Wed, 3 Mar 2004 06:40:27 -0800 (PST) (envelope-from dgw@liwest.at) Received: from cm58-27.liwest.at ([212.33.58.27]) by lilzmailso01.liwest.at with esmtp (Exim 4.24) id 1AyXXs-0007gk-C3; Wed, 03 Mar 2004 15:40:24 +0100 From: Daniela To: Sergey 'DoubleF' Zaharchenko Date: Wed, 3 Mar 2004 15:34:34 +0000 User-Agent: KMail/1.5.3 References: <200403022110.50014.dgw@liwest.at> <200403030623.28794.dgw@liwest.at> <20040303170243.545985fc@Hal.localdomain> In-Reply-To: <20040303170243.545985fc@Hal.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200403031534.34992.dgw@liwest.at> cc: jan.muenther@nruns.com cc: questions@freebsd.org Subject: Re: Strange behaviour in assembly language program X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2004 14:40:27 -0000 On Wednesday 03 March 2004 14:02, Sergey 'DoubleF' Zaharchenko wrote: > On Wed, 3 Mar 2004 06:23:28 +0000 > > Daniela probably wrote: > > In this situation, I can only use a single-byte instruction to push 4 > > bytes, everything else costs me too much space. The only one I know of, > > is PUSHA, but it pushes too many bytes. > > Quoting from dev-handbook: > > But assembly language programmers like to shave off cycles. The above > > example requires a call/ret combination. We can eliminate it by > > pushing an extra dword: > > > > open: > > push dword mode > > push dword flags > > push dword path > > mov eax, 5 > > push eax ; Or any other dword > > int 80h > > add esp, byte 16 > > > > The 5 that we have placed in EAX identifies the kernel function, in > > this case open. > > The last time I wrote `push ebp \n mov ebp, esp' the push took 1 > byte :). `push ' will work, as the kernel doesn't > really care for the value of the dword. Ah yes, thanks. I read that part of the handbook multiple times and never understood what that "push eax" is good for. I was looking at an incomplete opcode list where that instruction is not even listed.