Article View: comp.lang.asm.x86
Article #154Re: gas and gcc
From: Míla Kuchta
Date: Sat, 24 Nov 2001 18:52
Date: Sat, 24 Nov 2001 18:52
65 lines
2444 bytes
2444 bytes
Hello, In alt.lang.asm Frank Kotler <fbkotler@ne.mediaone.net> wrote: > Martin Cote wrote: > >> extern write_char(char); >> ---------------------------------- >> ..globl write_char >> >> write_char: >> pushl %ebp >> movl %esp,%ebp > > push ebx no > >> movl $4,%eax >> xorl %ebx,%ebx >> incl %ebx >> movl 4(%esp),%ecx >> movl %ecx,char >> leal char,%ecx >> xorl %edx,%edx >> incl %edx >> int $0x80 > > pop ebx no again That's simply because there are many mistakes. 1. Your function is not register safe. 2. The first parametr isn't 4(%esp), but 8(%ebp) (that's why you are saving %esp to %ebp). 4(%ebp) is return address. Here is fair copy. .globl write_char write_char: pushl %ebp movl %esp, %ebp pusha # 1 movl $4, %eax xorl %ebx, %ebx incl %ebx leal 8(%ebp), %ecx # 2 xorl %edx, %edx incl %edx int $0x80 popa # 1 leave ret -- Regards from Mila Kuchta
Technical Details
Message-ID:
<e7got9.dbk.ln@nothing.nowhere>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mailReferences:
<3BFDF24B.9E4D2F05@videotron.ca> <3BFF9471.D31E7D98@ne.mediaone.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f65d0,c50bd0ec38019abd
X-Google-Attributes: gidf65d0,public
X-Google-Thread: 114917,c50bd0ec38019abd
X-Google-Attributes: gid114917,public
X-Google-Thread: f7d8d,c50bd0ec38019abd
X-Google-Attributes: gidf7d8d,public
X-Google-ArrivalTime: 2001-11-24 10:57:52 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
From: Míla Kuchta <mila.kuchta@atlas.cz>
Newsgroups: comp.lang.asm.x86,alt.lang.asm,gnu.gcc
Subject: Re: gas and gcc
Approved: CLAX86 Moderators <ccrayne@crayne.org>
Date: Sat, 24 Nov 2001 18:52:06 +0000 (UTC)
Organization: Video On Line
Message-ID: <e7got9.dbk.ln@nothing.nowhere>
Sender: clax86@odin.asgard
References: <3BFDF24B.9E4D2F05@videotron.ca> <3BFF9471.D31E7D98@ne.mediaone.net>
X-CLAX86-Policy: http://www.pacificsites.com/~ccrayne/clax86.html
X-CLAX86-Faq: http://www2.dgsys.com/~raymoon/x86faqs.html
X-CLAX86-Info-1: Send submissions to comp-lang-asm-x86@moderators.isc.org
X-CLAX86-Info-2: Send technical complaints to ccrayne@crayne.org
X-CLAX86-Info-3: Send complaints about policy to ccrayne@crayne.org
X-Comment: moderators do not necessarily agree or disagree with this article.
User-Agent: tin/1.5.10-20010901 ("Chord of Souls") (UNIX) (Linux/2.4.10 (i686))
X-Complaints-To: newsabuse@supernews.com
Lines: 66