Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Mar 2004 17:02:43 +0300
From:      Sergey 'DoubleF' Zaharchenko <doublef@tele-kom.ru>
To:        Daniela <dgw@liwest.at>
Cc:        questions@freebsd.org
Subject:   Re: Strange behaviour in assembly language program
Message-ID:  <20040303170243.545985fc@Hal.localdomain>
In-Reply-To: <200403030623.28794.dgw@liwest.at>
References:  <200403022110.50014.dgw@liwest.at> <20040302211919.GA10074@ergo.nruns.com> <200403030623.28794.dgw@liwest.at>

next in thread | previous in thread | raw e-mail | index | archive | help
--Signature=_Wed__3_Mar_2004_17_02_43_+0300_YG9.NVZAAi0l.fsm
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

On Wed, 3 Mar 2004 06:23:28 +0000
Daniela <dgw@liwest.at> 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 <your_favorite_reg>' will work, as the kernel doesn't
really care for the value of the dword.

-- 
DoubleF
"I'd love to go out with you, but I have to floss my cat."

--Signature=_Wed__3_Mar_2004_17_02_43_+0300_YG9.NVZAAi0l.fsm
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD4DBQFAReWcwo7hT/9lVdwRAuc2AJ9aZjNnv2EtaFV6PfUOzJ8LZjOqUwCXWafv
+TARx7QEC8s9SJxvSl1VoA==
=YHUk
-----END PGP SIGNATURE-----

--Signature=_Wed__3_Mar_2004_17_02_43_+0300_YG9.NVZAAi0l.fsm--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040303170243.545985fc>