From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 5814 invoked from network); 30 Apr 2020 22:07:23 -0000 Received-SPF: pass (minnie.tuhs.org: domain of minnie.tuhs.org designates 45.79.103.53 as permitted sender) receiver=inbox.vuxu.org; client-ip=45.79.103.53 envelope-from= Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 30 Apr 2020 22:07:23 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id B8E5F9C918; Fri, 1 May 2020 08:07:21 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 4D24D9C851; Fri, 1 May 2020 08:06:47 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (1024-bit key; unprotected) header.d=ccc.com header.i=@ccc.com header.b="K9mCR2Zk"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 89A3A9C851; Fri, 1 May 2020 08:06:45 +1000 (AEST) Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by minnie.tuhs.org (Postfix) with ESMTPS id 9BFB79C733 for ; Fri, 1 May 2020 08:06:44 +1000 (AEST) Received: by mail-qv1-f42.google.com with SMTP id fb4so3893560qvb.7 for ; Thu, 30 Apr 2020 15:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccc.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O8ODNJSzf0kvaFQ63bPWGmCiXN9ZyLyA4T59ZlJ1dBE=; b=K9mCR2Zkg4vlDI1jMQYx2gBhysEPzJHM0QPUS8pRI6t4oLZDPJFx60Xk+TUpwVbb4X LdlvTNyS5Lkf0iVvM4slFvdUbOSH1SFL0ANp2m/Ry9e2BdLvr230E8MIxxUk7qsoXEEW 12KJ/XGfLXn0y6jK6dv55Dl4byYaeLwAACKMs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O8ODNJSzf0kvaFQ63bPWGmCiXN9ZyLyA4T59ZlJ1dBE=; b=YUKv4L6yv74Eh8w8X+2CuyTQ0KFMdz6CCuLVCYT3O5ZcrOlM2WcFJcstd5y185XFjf 3MBQG09bjuYP2ZS+1pZTcPyILiIghnVao0IC3bytKHhZ9x79TK6yx2eX8ERxxyTxqBgJ bCpRb4LAzXY6+A45DizgfGg5xZLqVyV0Takh2LV/YmXZRhMtr/GaUNVF4cS7OvsUBehe wVd1WkoHXZBbSj/dsbDDbS/FzvBIkKyvG4zkAGbI2ZbBCVVJkKYghh6oNmfTKuPhRgsr nejAnsQu3pOAl8b0SzpevcsfTEaT/SeNq5okLWxrKTDE1/FfD+wesBbGoce0StFkGZGN rw8A== X-Gm-Message-State: AGi0Pub4JphSbPHE0K//E4GgInpjDDT84pZEvR8K/TmYdIlsCr5EJK5T QhHZl1MmGW3ATY97qpjbgViXZzW0saXrs/QH5rGKX2LncvU= X-Google-Smtp-Source: APiQypIvBmvWmMXhowj+p/hwCDAd6mdmtDFN2pQUW79bEjNBcQiLH8P9LQxS5A35Qv3lE/GtTI79LubwLn+PLR7LMe0= X-Received: by 2002:ad4:4441:: with SMTP id l1mr1175380qvt.74.1588284403296; Thu, 30 Apr 2020 15:06:43 -0700 (PDT) MIME-Version: 1.0 References: <9A1BF33E-49C9-4712-BF25-4C0BBC504CD1@planet.nl> In-Reply-To: From: Clem Cole Date: Thu, 30 Apr 2020 18:06:16 -0400 Message-ID: To: Alexander Voropay Content-Type: multipart/alternative; boundary="000000000000a94bd005a489470f" Subject: Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --000000000000a94bd005a489470f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Alexander, the exit(2) system call takes a parameter, which is an integer status that the process will return. The value 0 is traditionally a successful return, and anything else signifies an error condition. This assembler is the moral equiv of: char hello[] =3D { "hello world\n" }; main() { write(1, hello, sizeof(hello)); exit(0); } On Thu, Apr 30, 2020 at 5:50 PM Alexander Voropay wrote: > Can anyone please explain the last $0 pushed to the stack ? > Early SysIII ans SYSV on the i386 (and may be on i286) used > similar syscall convention. > > I wrote about this: > https://minnie.tuhs.org/pipermail/tuhs/2019-October/019274.html > https://minnie.tuhs.org/pipermail/tuhs/2019-October/019294.html > > Example: > =3D=3D=3D > .file "test.s" > .version "02.01" > .set WRITE,4 > .set EXIT,1 > .text > .align 4 > .globl entry > entry: > pushl %ebp > movl %esp,%ebp > subl $8,%esp > > pushl $14 /length > pushl $hello > pushl $1 /STDOUT > pushl $0 > movl $WRITE,%eax > lcall $0x07,$0 > addl $16,%esp > > pushl $0 > movl $EXIT,%eax > lcall 0x07,$0 > > .data > .align 4 > hello: > .byte 0x48,0x65,0x6c,0x6c,0x6f,0x2c, 0x20,0x77,0x6f,0x72 > .byte 0x6c,0x64,0x21,0x0a,0x00 > > =D1=81=D1=80, 29 =D0=B0=D0=BF=D1=80. 2020 =D0=B3. =D0=B2 17:19, : > > > > Thanks for the link. With that help, I fixed the bug in the program: > > > > mov $6., -(sp) > > mov $1f, -(sp) > > mov $1,-(sp) > > mov $0,-(sp) > > sys 4 > > add $8., sp > > mov $0,-(sp) > > mov $0,-(sp) > > sys 1 > > 1: > > > > > > >> Sorry, I typed that in haste without testing. I don=E2=80=99t have a= 2.11 > system > > >> to try it on. However, reading the source code, I did that wrong. Th= e > > >> args go on the stack, not in line with the code. > > >> mov $6, -(sp) > > >> mov a, -(sp) > > >> mov $1,-(sp) > > >> sys 4 > > > > > > Without suggesting that every helpful post should be tested, I find t= he > > > superb https://unix50.org web emulator excellent for such things. > > > > > > Many thanks to the folks hosting & maintaining this great resource! > > > > > > > > > > > --000000000000a94bd005a489470f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Alexander, the exit(2) system call takes a parameter, w= hich is an integer status that the process will return.=C2=A0 The value 0 i= s traditionally a successful return, and anything else signifies=C2=A0an er= ror condition.=C2=A0
This assembler is the moral equiv of:
=
char hello[] =3D { "hello world\n" };
main()= {
=C2=A0 =C2=A0write(1, hello, sizeof(hello));
=C2=A0 =C2= =A0exit(0);
}

On Thu, Apr 30, 2020 at 5:50 PM Alexander Voropa= y <alec@sensi.org> wrote:
Can anyone please exp= lain the last $0 pushed to the stack ?
Early SysIII ans SYSV on the i386 (and may be on i286) used
similar syscall convention.

I wrote about this:
https://minnie.tuhs.org/pipermail/tuh= s/2019-October/019274.html
https://minnie.tuhs.org/pipermail/tuh= s/2019-October/019294.html

Example:
=3D=3D=3D
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .file "test.s"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .version "02.01"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .set WRITE,4
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .set EXIT,1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .text
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .align 4
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .globl entry
entry:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pushl %ebp
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0movl %esp,%ebp
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0subl $8,%esp

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pushl $14 /length
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pushl $hello
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pushl $1 /STDOUT
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pushl $0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0movl $WRITE,%eax
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0lcall $0x07,$0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0addl $16,%esp

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pushl $0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0movl $EXIT,%eax
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0lcall 0x07,$0

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.data
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.align 4
hello:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.byte 0x48,0x65,0x6c,0x6c,0x6f,0x2c, 0x20= ,0x77,0x6f,0x72
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.byte 0x6c,0x64,0x21,0x0a,0x00

=D1=81=D1=80, 29 =D0=B0=D0=BF=D1=80. 2020 =D0=B3. =D0=B2 17:19, <ron@ronnatalie.com>= :
>
> Thanks for the link.=C2=A0 =C2=A0With that help, I fixed the bug in th= e program:
>
>=C2=A0 =C2=A0 mov $6., -(sp)
>=C2=A0 =C2=A0 =C2=A0 mov $1f, -(sp)
>=C2=A0 =C2=A0 =C2=A0 mov $1,-(sp)
>=C2=A0 =C2=A0 =C2=A0 mov $0,-(sp)
>=C2=A0 =C2=A0 =C2=A0 sys 4
>=C2=A0 =C2=A0 =C2=A0 add $8., sp
>=C2=A0 =C2=A0 =C2=A0 mov $0,-(sp)
>=C2=A0 =C2=A0 =C2=A0 mov $0,-(sp)
>=C2=A0 =C2=A0 =C2=A0 sys 1
> 1:=C2=A0 =C2=A0<hello>
>
>
> >> Sorry, I typed that in haste without testing. I don=E2=80=99t= have a 2.11 system
> >> to try it on. However, reading the source code, I did that wr= ong. The
> >> args go on the stack, not in line with the code.
> >> mov $6, -(sp)
> >> mov a, -(sp)
> >> mov $1,-(sp)
> >> sys 4
> >
> > Without suggesting that every helpful post should be tested, I fi= nd the
> > superb https://unix50.org web emulator excellent for such things.<= br> > >
> > Many thanks to the folks hosting & maintaining this great res= ource!
> >
> >
>
>
--000000000000a94bd005a489470f--