* [TUHS] as(1) on Ultrix-11 vs 2.11BSD @ 2020-04-28 1:56 Jacob Ritorto 2020-04-28 13:03 ` Ronald Natalie 0 siblings, 1 reply; 13+ messages in thread From: Jacob Ritorto @ 2020-04-28 1:56 UTC (permalink / raw) To: The Eunuchs Hysterical Society [-- Attachment #1: Type: text/plain, Size: 1249 bytes --] Hiya! Got these two pdp11s, one an 11/23 (Ultrix-11 3.1) and the other an 11/84 (2.11BSD) On the Ultrix machine, I can enter an assembly language program, assemble it and run it fine. amnesiac# cat hello.s mov $1,r0 sys 4 a 6 sys 1 a: <Hello\n> amnesiac# od hello 0000000 000407 000022 000000 000000 000014 000000 000000 000000 0000020 012700 000001 104404 000014 000006 104401 062510 066154 0000040 005157 000000 000000 000000 000002 000000 000000 000000 0000060 000000 000000 000141 000000 000000 000000 000002 000014 0000100 amnesiac# ./hello Hello amnesiac# But on the BSD machine, the exact same source program assembles differently and crashes with Illegal instruction when I run it. > cat hello.s mov $1,r0 sys 4 a 6 sys 1 a: <Hello\n> > od a.out 0000000 000407 000022 000000 000000 000010 000000 000000 000000 0000020 012700 000001 104404 000014 000006 104401 062510 066154 0000040 005157 000000 000000 000000 000002 000000 000000 000000 0000060 000000 000000 000000 000004 000002 000014 000000 000006 0000100 000141 0000102 > ./a.out Illegal instruction (core dumped) > Anyone know what I'm doing wrong? thx jake [-- Attachment #2: Type: text/html, Size: 1746 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-28 1:56 [TUHS] as(1) on Ultrix-11 vs 2.11BSD Jacob Ritorto @ 2020-04-28 13:03 ` Ronald Natalie 2020-04-29 0:17 ` Jacob Ritorto 0 siblings, 1 reply; 13+ messages in thread From: Ronald Natalie @ 2020-04-28 13:03 UTC (permalink / raw) To: Jacob Ritorto; +Cc: The Eunuchs Hysterical Society [-- Attachment #1: Type: text/plain, Size: 901 bytes --] Yes, you aren’t programming 2.11 BSD correctly. Your examples are the older UNIX syscalls (your programs work correctly in Version 6 by the way as well). In 2.11 BSD, all the arguments for the syscalls are inline (i.e., none are passed in registers. This appears to be the beginnings of making the kernel protable across architectures. The systent table no longer has separate fields for args in registers and not in registers and the code in sys/pdp/trap.c doesn’t look at the registers anymore. > On Apr 27, 2020, at 9:56 PM, Jacob Ritorto <jacob.ritorto@gmail.com> wrote: > > mov $1,r0 > sys 4 > a > 6 > sys 1 Proper code now should be: sys 4 1 a 6 sys 1 0 Note your previous code used to just return 6 from the program (the return value of write). [-- Attachment #2: Type: text/html, Size: 5286 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-28 13:03 ` Ronald Natalie @ 2020-04-29 0:17 ` Jacob Ritorto 2020-04-29 0:54 ` ron 0 siblings, 1 reply; 13+ messages in thread From: Jacob Ritorto @ 2020-04-29 0:17 UTC (permalink / raw) To: Ronald Natalie; +Cc: The Eunuchs Hysterical Society [-- Attachment #1: Type: text/plain, Size: 1436 bytes --] On Tue, Apr 28, 2020 at 9:03 AM Ronald Natalie <ron@ronnatalie.com> wrote: > Yes, you aren’t programming 2.11 BSD correctly. > Wow, I'd hoped it was that. Thank you so much! I spent way too much time fiddling incorrectly. Was an example I'd cobbled together from my college textbook I've been going back through, _Assembly_Language_for_the_PDP-11_RT-RSX-UNIX_ (c)1981 Kapps and Stafford. We didn't have UNIX for the class so never ran into this. > Your examples are the older UNIX syscalls (your programs work correctly in > Version 6 by the way as well). > > In 2.11 BSD, all the arguments for the syscalls are inline (i.e., none are > passed in registers. This appears to be the beginnings of making the > kernel protable across architectures. > The systent table no longer has separate fields for args in registers and > not in registers and the code in sys/pdp/trap.c doesn’t look at the > registers anymore. > I wonder if the differences are written up somewhere. I did try to look for more documentation but came up short. Must've been quite well-ingrained in programmers' minds in the day. > Proper code now should be: > sys 4 > 1 > a > 6 > sys 1 > 0 > Note your previous code used to just return 6 from the program (the return > value of write). > Ah, so passing exit code as an arg to sys 1. Cool. Thanks again! [-- Attachment #2: Type: text/html, Size: 2459 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-29 0:17 ` Jacob Ritorto @ 2020-04-29 0:54 ` ron 0 siblings, 0 replies; 13+ messages in thread From: ron @ 2020-04-29 0:54 UTC (permalink / raw) To: Jacob Ritorto; +Cc: The Eunuchs Hysterical Society Yes, the calling sequence changes were in the back of my mind, but fortunately the TUHS source archives allowed me to easily look at the kernel source to see how the arguments were passed. Somewhere between 2.8 and 2.11 they changed it. Again, 2.11 was one fo the first attempts to formalize a true "multi platform" kernel rather than just copying over the kernel and reworking it for a new machine from a seperate source "tree." Yes, your code takes the return of the write system call and uses it as the exit code. Not that it makes too much difference. My 2.11 version of your code passes a zero explicitly. Amusingly, speaking of college courses. I had early on joined the UNIX systems programming team at JHU and had also done some custom work for various PDP-11 sites on campus (DOS/BATCH, RT-11, etc...). PDP-11 assembler was something I knew well. The head of the EE department told me he'd be very disappointed if I actually signed up for his PDP-11 assembler programming course my senior year. Oddly, this caused some consternation with the faculty committee approving my graduation as I hadn't taken it and it was required. Our department UNIX machine as a PDP-11/45 running a high modified V6 kernel. I also got one of the early 11/23's and we brought up the same software on that. A year after I graduated, I was attending a DEC announcement on the T-11 (I think the first single chip PDP-11). The speaker says it had all the instructions with the exception of MARK. Me and one other guy are going, "What? No MARK instruction?" MARK was the most useless instruction concocted and it wouldn't even work on an executable that was set up split I/D. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD @ 2020-04-29 2:26 Noel Chiappa 2020-04-29 4:08 ` Jacob Ritorto 0 siblings, 1 reply; 13+ messages in thread From: Noel Chiappa @ 2020-04-29 2:26 UTC (permalink / raw) To: tuhs; +Cc: jnc > From: Jacob Ritorto > I wonder if the differences are written up somewhere. I did try to look > for more documentation but came up short. Sounds like a perfect topic for a CHWiki page. :-) E.g. this one: http://gunkies.org/wiki/Unix_V6_internals which I did as a bit of an addendum to Lions, to explain rsav, qsav and ssav, and similar topics. I noticed in the comparison of your two binary files that the instructions looked the same, but the a.out headers had a difference, but I didn't remember the fields in the a.out header enough to know what the differences meant. I thought I remembered doing an a.out page there, but apparently not. I thought about doing one now, but decided it wasn't worth it; I just needed to spin up my V6 system and do 'man a.out'! :-) Noel ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-29 2:26 Noel Chiappa @ 2020-04-29 4:08 ` Jacob Ritorto 2020-04-29 12:20 ` Ronald Natalie 0 siblings, 1 reply; 13+ messages in thread From: Jacob Ritorto @ 2020-04-29 4:08 UTC (permalink / raw) To: Ronald Natalie; +Cc: The Eunuchs Hysterical Society [-- Attachment #1: Type: text/plain, Size: 2231 bytes --] Shoot, celebrated too soon. I rearranged it per your tutelage, Ron, and it's still giving an Illegal Instruction error! From the adb output it looks like it's balking at the "14" instruction at location 24, which, based on the BSD updates you mentioned, I thought should've been taken as an arg, not an instruction, right? I assume this worked for you on some BSD, right? If so, is it a bug in the recent 2.11BSD patch release, perhaps? Anyone able to help me understand? > vi hello.s "hello.s" 8 lines, 52 characters sys 4 1 a 6 sys 1 0 a: <Hello\n> "hello.s" 7 lines, 78 characters > as !$ as hello.s > ./a.out Illegal instruction (core dumped) > od a.out 0000000 000407 000022 000000 000000 000010 000000 000000 000000 0000020 104404 000001 000014 000006 104401 000000 062510 066154 0000040 005157 000000 000000 000002 000000 000000 000000 000000 0000060 000000 000000 000000 000004 000002 000014 000000 000006 0000100 000141 0000102 > adb adb> :s stopped at 0: sys write adb> :s a.out: running stopped at 04: <illegal op> 014 adb> :s a.out: running Illegal instruction stopped at 06: rtt adb> :s a.out: running Illegal instruction - core dumped process terminated adb> > On Tue, Apr 28, 2020 at 10:26 PM Noel Chiappa <jnc@mercury.lcs.mit.edu> wrote: > > From: Jacob Ritorto > > > I wonder if the differences are written up somewhere. I did try to > look > > for more documentation but came up short. > > Sounds like a perfect topic for a CHWiki page. :-) E.g. this one: > > http://gunkies.org/wiki/Unix_V6_internals > > which I did as a bit of an addendum to Lions, to explain rsav, qsav and > ssav, and > similar topics. > > > I noticed in the comparison of your two binary files that the instructions > looked the same, but the a.out headers had a difference, but I didn't > remember > the fields in the a.out header enough to know what the differences meant. > > I thought I remembered doing an a.out page there, but apparently not. I > thought about doing one now, but decided it wasn't worth it; I just needed > to > spin up my V6 system and do 'man a.out'! :-) > > Noel > > [-- Attachment #2: Type: text/html, Size: 3074 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-29 4:08 ` Jacob Ritorto @ 2020-04-29 12:20 ` Ronald Natalie 0 siblings, 0 replies; 13+ messages in thread From: Ronald Natalie @ 2020-04-29 12:20 UTC (permalink / raw) To: Jacob Ritorto; +Cc: The Eunuchs Hysterical Society [-- Attachment #1: Type: text/plain, Size: 2839 bytes --] 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 > On Apr 29, 2020, at 12:08 AM, Jacob Ritorto <jacob.ritorto@gmail.com> wrote: > > Shoot, celebrated too soon. I rearranged it per your tutelage, Ron, and it's still giving an Illegal Instruction error! > From the adb output it looks like it's balking at the "14" instruction at location 24, which, based on the BSD updates you mentioned, I thought should've been taken as an arg, not an instruction, right? > > I assume this worked for you on some BSD, right? > If so, is it a bug in the recent 2.11BSD patch release, perhaps? Anyone able to help me understand? > > > vi hello.s > "hello.s" 8 lines, 52 characters > sys 4 > 1 > a > 6 > sys 1 > 0 > a: <Hello\n> > > "hello.s" 7 lines, 78 characters > > as !$ > as hello.s > > ./a.out > Illegal instruction (core dumped) > > od a.out > 0000000 000407 000022 000000 000000 000010 000000 000000 000000 > 0000020 104404 000001 000014 000006 104401 000000 062510 066154 > 0000040 005157 000000 000000 000002 000000 000000 000000 000000 > 0000060 000000 000000 000000 000004 000002 000014 000000 000006 > 0000100 000141 > 0000102 > > adb > adb> :s > stopped at 0: sys write > adb> :s > a.out: running > stopped at 04: <illegal op> 014 > adb> :s > a.out: running > Illegal instruction > stopped at 06: rtt > adb> :s > a.out: running > Illegal instruction - core dumped > process terminated > adb> > > > On Tue, Apr 28, 2020 at 10:26 PM Noel Chiappa <jnc@mercury.lcs.mit.edu <mailto:jnc@mercury.lcs.mit.edu>> wrote: > > From: Jacob Ritorto > > > I wonder if the differences are written up somewhere. I did try to look > > for more documentation but came up short. > > Sounds like a perfect topic for a CHWiki page. :-) E.g. this one: > > http://gunkies.org/wiki/Unix_V6_internals <http://gunkies.org/wiki/Unix_V6_internals> > > which I did as a bit of an addendum to Lions, to explain rsav, qsav and ssav, and > similar topics. > > > I noticed in the comparison of your two binary files that the instructions > looked the same, but the a.out headers had a difference, but I didn't remember > the fields in the a.out header enough to know what the differences meant. > > I thought I remembered doing an a.out page there, but apparently not. I > thought about doing one now, but decided it wasn't worth it; I just needed to > spin up my V6 system and do 'man a.out'! :-) > > Noel > [-- Attachment #2: Type: text/html, Size: 5071 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* [TUHS] as(1) on Ultrix-11 vs 2.11BSD
@ 2020-04-29 13:55 Paul Ruizendaal
2020-04-29 14:18 ` ron
0 siblings, 1 reply; 13+ messages in thread
From: Paul Ruizendaal @ 2020-04-29 13:55 UTC (permalink / raw)
To: TUHS main list
> 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!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-29 13:55 Paul Ruizendaal @ 2020-04-29 14:18 ` ron 2020-04-30 21:49 ` Alexander Voropay 0 siblings, 1 reply; 13+ messages in thread From: ron @ 2020-04-29 14:18 UTC (permalink / raw) To: Paul Ruizendaal; +Cc: TUHS main list 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! > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-29 14:18 ` ron @ 2020-04-30 21:49 ` Alexander Voropay 2020-04-30 22:06 ` Clem Cole 2020-05-01 0:12 ` Ronald Natalie 0 siblings, 2 replies; 13+ messages in thread From: Alexander Voropay @ 2020-04-30 21:49 UTC (permalink / raw) To: The Eunuchs Hysterical Society 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! > > > > > > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-30 21:49 ` Alexander Voropay @ 2020-04-30 22:06 ` Clem Cole 2020-04-30 22:09 ` Clem Cole 2020-05-01 0:12 ` Ronald Natalie 1 sibling, 1 reply; 13+ messages in thread From: Clem Cole @ 2020-04-30 22:06 UTC (permalink / raw) To: Alexander Voropay; +Cc: The Eunuchs Hysterical Society [-- 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 --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-30 22:06 ` Clem Cole @ 2020-04-30 22:09 ` Clem Cole 0 siblings, 0 replies; 13+ messages in thread From: Clem Cole @ 2020-04-30 22:09 UTC (permalink / raw) To: Alexander Voropay; +Cc: The Eunuchs Hysterical Society [-- Attachment #1: Type: text/plain, Size: 2831 bytes --] 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 <clemc@ccc.com> 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[] = { "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: 4915 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [TUHS] as(1) on Ultrix-11 vs 2.11BSD 2020-04-30 21:49 ` Alexander Voropay 2020-04-30 22:06 ` Clem Cole @ 2020-05-01 0:12 ` Ronald Natalie 1 sibling, 0 replies; 13+ messages in thread From: Ronald Natalie @ 2020-05-01 0:12 UTC (permalink / raw) To: Alexander Voropay; +Cc: The Eunuchs Hysterical Society 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@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! >>> >>> >> >> ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-05-01 0:13 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-28 1:56 [TUHS] as(1) on Ultrix-11 vs 2.11BSD Jacob Ritorto 2020-04-28 13:03 ` Ronald Natalie 2020-04-29 0:17 ` Jacob Ritorto 2020-04-29 0:54 ` ron 2020-04-29 2:26 Noel Chiappa 2020-04-29 4:08 ` Jacob Ritorto 2020-04-29 12:20 ` Ronald Natalie 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 2020-04-30 22:09 ` Clem Cole 2020-05-01 0:12 ` Ronald Natalie
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).