The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Clem Cole <clemc@ccc.com>
To: Alexander Voropay <alec@sensi.org>
Cc: The Eunuchs Hysterical Society <tuhs@tuhs.org>
Subject: Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD
Date: Thu, 30 Apr 2020 18:06:16 -0400	[thread overview]
Message-ID: <CAC20D2PcSkWdqTjcnxFWdT109E_FhR9v0xJmMMF2tkLxNPfQXg@mail.gmail.com> (raw)
In-Reply-To: <CAGqcPWAX_N4tvg4DCDC5CWHNnYAmObz0cn7hHU95Po5m7j-8bA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2389 bytes --]

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[] = { "hello world\n" };
main() {
   write(1, hello, sizeof(hello));
   exit(0);
}

On Thu, 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/tuhs/2019-October/019274.html
> https://minnie.tuhs.org/pipermail/tuhs/2019-October/019294.html
>
> Example:
> ===
>         .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
>
> ср, 29 апр. 2020 г. в 17:19, <ron@ronnatalie.com>:
> >
> > 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:   <hello>
> >
> >
> > >> Sorry, I typed that in haste without testing. I don’t have a 2.11
> system
> > >> to try it on. However, reading the source code, I did that wrong. 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 find the
> > > superb https://unix50.org web emulator excellent for such things.
> > >
> > > Many thanks to the folks hosting & maintaining this great resource!
> > >
> > >
> >
> >
>

[-- Attachment #2: Type: text/html, Size: 4128 bytes --]

  reply	other threads:[~2020-04-30 22:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 13:55 Paul Ruizendaal
2020-04-29 14:18 ` ron
2020-04-30 21:49   ` Alexander Voropay
2020-04-30 22:06     ` Clem Cole [this message]
2020-04-30 22:09       ` Clem Cole
2020-05-01  0:12     ` Ronald Natalie
  -- strict thread matches above, loose matches on Subject: below --
2020-04-29  2:26 Noel Chiappa
2020-04-29  4:08 ` Jacob Ritorto
2020-04-29 12:20   ` Ronald Natalie
2020-04-28  1:56 Jacob Ritorto
2020-04-28 13:03 ` Ronald Natalie
2020-04-29  0:17   ` Jacob Ritorto
2020-04-29  0:54     ` ron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAC20D2PcSkWdqTjcnxFWdT109E_FhR9v0xJmMMF2tkLxNPfQXg@mail.gmail.com \
    --to=clemc@ccc.com \
    --cc=alec@sensi.org \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).