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 6234 invoked from network); 30 Apr 2020 22:10:46 -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:10:46 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 56FFA9C9B6; Fri, 1 May 2020 08:10:45 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 4153D9C851; Fri, 1 May 2020 08:10:19 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (1024-bit key; unprotected) header.d=ccc.com header.i=@ccc.com header.b="Wai1t4/T"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 11A089C851; Fri, 1 May 2020 08:10:18 +1000 (AEST) Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by minnie.tuhs.org (Postfix) with ESMTPS id 6AE669C733 for ; Fri, 1 May 2020 08:10:17 +1000 (AEST) Received: by mail-qk1-f182.google.com with SMTP id m67so7501519qke.12 for ; Thu, 30 Apr 2020 15:10:17 -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=UuGe0KfMBfl9KG4/gIyEJqHypq+dtI9QO7czp8QT7bo=; b=Wai1t4/TG5co5woVBcJCmmow12GQXzdbDMMeqAnDOAYQgxjn7Ha6ISHLmYYkMKM7SK cnCjZgvS/Qh0Lm31tQMbxOdWG45+HRVcdVRHglhx91J4cMKxItt5bVsLdfI60A1NBF1i K2hH6i976cjHcfrfdqHuVn8kVNboZTv6wIWFY= 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=UuGe0KfMBfl9KG4/gIyEJqHypq+dtI9QO7czp8QT7bo=; b=AeaJkU8s5SibWylOd03DLqg+nfH8TMqomYuJekHO/Fhbc6LL3rCS2u3lI/mPfby2E4 Rf3vx5hcBJFbn9JYVhBV9L7+8Kl6Fe5HApOZVczRzYmfbHgfNmmg4D1sOMYpqrKDiEND eU68UpvIfAP8figBC+bUFPK04263/KCSM6zv3do3HoU0jKLnGRUiX3uSM7Rzg18ASog7 eenFT5Hy7JmBynHOY3lCoqDXe1FixG4JUHUuFU/+eMRYLfRrUZ5wFsDOdjpX0aNQwYM0 s5XwD7na07WEidPz/fp0HzN8rYmkRnwzk5hCT8JBGalWlUQkjQ4SUn128b/cYseTON2g sjXA== X-Gm-Message-State: AGi0PuZrPF7b9cOm+Ba4RypgfmJcqM74gZjEzzMXifADrTWyV/jQQtrt itfGhqw23qHRN8V1rPa3l385QA4VR5XGwTpxCcITTYcyAWc= X-Google-Smtp-Source: APiQypIHzeMUIhrchbeqV/oGoqL1qnkvTyinjVE4YBatY+hh4akociBl0+eeaHUc3E3z0tjIL2JrpdLm09ZXkIhCf2w= X-Received: by 2002:a37:c0d:: with SMTP id 13mr715246qkm.25.1588284616314; Thu, 30 Apr 2020 15:10:16 -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:09:50 -0400 Message-ID: To: Alexander Voropay Content-Type: multipart/alternative; boundary="0000000000005ba39705a48954da" 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" --0000000000005ba39705a48954da Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ouch - just looked at that more carefully. exit it returning the what was left on the stack. The push $0 is something in the system calling convention for that port. You'll have to look at the kernel sources for that system in code that takes the trap. Clem On Thu, Apr 30, 2020 at 6:06 PM Clem Cole wrote: > 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. T= he >> > >> 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 >> the >> > > superb https://unix50.org web emulator excellent for such things. >> > > >> > > Many thanks to the folks hosting & maintaining this great resource! >> > > >> > > >> > >> > >> > --0000000000005ba39705a48954da Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ouch -=C2=A0 just looked at that more carefully.=C2=A0 = =C2=A0exit it returning the what was left on the stack.=C2=A0 The push $0 i= s something in the system calling convention for that port.=C2=A0 You'l= l have to look at the kernel sources for that system in code that takes the= trap.
Clem

On Thu, Apr 30, 2020 at 6:06 PM Clem Cole <clemc@ccc.com> wrote:
Alexander, th= e exit(2) system call takes a parameter, which is an integer status that th= e process will return.=C2=A0 The value 0 is traditionally a successful retu= rn, and anything else signifies=C2=A0an error 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 Th= u, Apr 30, 2020 at 5:50 PM Alexander Voropay <alec@sensi.org> 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/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!
> >
> >
>
>
--0000000000005ba39705a48954da--