[TUHS] as(1) on Ultrix-11 vs 2.11BSD

Ronald Natalie ron at ronnatalie.com
Fri May 1 10:12:50 AEST 2020


The syscall skips over a location for reasons not fully clear to me.    I guess if you dug down into the libc functions that call it you’d figure out why.   As far as the kernel is concerned, it just doesn’t look at it.
The zero is just a spacer, other code just does a tst -(sp) there which just decrs the stack poitner.

> On Apr 30, 2020, at 5:49 PM, Alexander Voropay <alec at 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 at 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!
>>> 
>>> 
>> 
>> 



More information about the TUHS mailing list