* [TUHS] asm helper routines in v7
@ 2022-01-04 20:37 Will Senn
2022-01-04 21:12 ` Dan Cross
2022-01-04 21:38 ` Clem Cole
0 siblings, 2 replies; 9+ messages in thread
From: Will Senn @ 2022-01-04 20:37 UTC (permalink / raw)
To: TUHS main list
[-- Attachment #1: Type: text/plain, Size: 1738 bytes --]
So,
in v6, it was possible to use the mesg function from the system library
with:
ed hello.s
/ hello world using external mesg routine
.globl mesg
mov sp,r5
jsr r5,mesg; <Hello, World!\n\0>; .even
sys exit
as hello.sld -s a.out -l
a.out
Hello, World!
This was because v6 included mesg in the library, in v7, it doesn't look
like mesg is included, so doing the same thing as above requires that
code to write the message out be included and in addition system call
names are not predefined, so exit and write have to be looked up in
/usr/include/sys.s, resulting in the v7 equivalent file:
ed hello2.s
/ hello world using internal mesg routine
mov sp,r5
jsr r5,mesg; <Hello, World!\n\0>; .even
sys 1
mesg:
mov r0,-(sp)
mov r5,r0
mov r5,0f
1:
tstb (r5)+
bne 1b
sub r5,r0
com r0
mov r0,0f+2
mov $1,r0
sys 0; 9f
.data
9:
sys 4; 0:..; ..
.text
inc r5
bic $1,r5
mov (sp)+,r0
rts r5
as hello2.s
a.out
Hello, World!
My questions are:
1. Is mesg or an equivalent available in v7?
2. If not, what was the v7 way of putting strings out?
3. Why aren't the system call names defined?
4. What was the v7 way of naming system calls?
Will
[-- Attachment #2: Type: text/html, Size: 2447 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TUHS] asm helper routines in v7
2022-01-04 20:37 [TUHS] asm helper routines in v7 Will Senn
@ 2022-01-04 21:12 ` Dan Cross
2022-01-04 21:24 ` Will Senn
2022-01-04 21:38 ` Clem Cole
1 sibling, 1 reply; 9+ messages in thread
From: Dan Cross @ 2022-01-04 21:12 UTC (permalink / raw)
To: Will Senn; +Cc: TUHS main list
On Tue, Jan 4, 2022 at 3:38 PM Will Senn <will.senn@gmail.com> wrote:
> [snip]
> My questions are:
>
> 1. Is mesg or an equivalent available in v7?
Perhaps just call printf?
> 2. If not, what was the v7 way of putting strings out?
Here's what I did:
$ rm -f h h.o
$ cat h.s
.globl _printf, _exit
mov sp, r5
mov $hi,(sp)
jsr pc,*$_printf
mov $0, (sp)
jsr pc,*$_exit
hi: <Hello, World!\n\0>
$ as -o h.o h.s
$ ld -o h h.o -lc
$ ./h
Hello, World!
$ rm h h.o
> 3. Why aren't the system call names defined?
If I had to hazard a guess, it would have been to de-emphasize the use
of assembler for user code, particularly as 7th Edition was starting
to be portable beyond the PDP-11.
> 4. What was the v7 way of naming system calls?
I imagine the canonical way to invoke system calls from assembler was
invoking calling functions in the C library and linking against that.
- Dan C.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TUHS] asm helper routines in v7
2022-01-04 21:12 ` Dan Cross
@ 2022-01-04 21:24 ` Will Senn
2022-01-04 21:28 ` Warner Losh
0 siblings, 1 reply; 9+ messages in thread
From: Will Senn @ 2022-01-04 21:24 UTC (permalink / raw)
To: Dan Cross; +Cc: TUHS main list
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
On 1/4/22 3:12 PM, Dan Cross wrote:
> On Tue, Jan 4, 2022 at 3:38 PM Will Senn<will.senn@gmail.com> wrote:
>> [snip]
>> My questions are:
>>
>> 1. Is mesg or an equivalent available in v7?
> Perhaps just call printf?
>
>> 2. If not, what was the v7 way of putting strings out?
> Here's what I did:
>
> $ rm -f h h.o
> $ cat h.s
> .globl _printf, _exit
>
> mov sp, r5
> mov $hi,(sp)
> jsr pc,*$_printf
> mov $0, (sp)
> jsr pc,*$_exit
>
> hi: <Hello, World!\n\0>
> $ as -o h.o h.s
> $ ld -o h h.o -lc
> $ ./h
> Hello, World!
> $ rm h h.o
>
>> 3. Why aren't the system call names defined?
> If I had to hazard a guess, it would have been to de-emphasize the use
> of assembler for user code, particularly as 7th Edition was starting
> to be portable beyond the PDP-11.
>
>> 4. What was the v7 way of naming system calls?
> I imagine the canonical way to invoke system calls from assembler was
> invoking calling functions in the C library and linking against that.
>
> - Dan C.
Yep, that worked... you make it look so easy, and your rationales are
definitely believable :).
Will
[-- Attachment #2: Type: text/html, Size: 2208 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TUHS] asm helper routines in v7
2022-01-04 21:24 ` Will Senn
@ 2022-01-04 21:28 ` Warner Losh
2022-01-05 17:35 ` Dan Cross
0 siblings, 1 reply; 9+ messages in thread
From: Warner Losh @ 2022-01-04 21:28 UTC (permalink / raw)
To: Will Senn; +Cc: TUHS main list
[-- Attachment #1: Type: text/plain, Size: 1739 bytes --]
On Tue, Jan 4, 2022 at 2:24 PM Will Senn <will.senn@gmail.com> wrote:
> On 1/4/22 3:12 PM, Dan Cross wrote:
>
> On Tue, Jan 4, 2022 at 3:38 PM Will Senn <will.senn@gmail.com> <will.senn@gmail.com> wrote:
>
> [snip]
> My questions are:
>
> 1. Is mesg or an equivalent available in v7?
>
> Perhaps just call printf?
>
>
> 2. If not, what was the v7 way of putting strings out?
>
> Here's what I did:
>
> $ rm -f h h.o
> $ cat h.s
> .globl _printf, _exit
>
> mov sp, r5
> mov $hi,(sp)
> jsr pc,*$_printf
> mov $0, (sp)
> jsr pc,*$_exit
>
> hi: <Hello, World!\n\0>
> $ as -o h.o h.s
> $ ld -o h h.o -lc
> $ ./h
> Hello, World!
> $ rm h h.o
>
>
> 3. Why aren't the system call names defined?
>
> If I had to hazard a guess, it would have been to de-emphasize the use
> of assembler for user code, particularly as 7th Edition was starting
> to be portable beyond the PDP-11.
>
>
> 4. What was the v7 way of naming system calls?
>
> I imagine the canonical way to invoke system calls from assembler was
> invoking calling functions in the C library and linking against that.
>
> - Dan C.
>
> Yep, that worked... you make it look so easy, and your rationales are
> definitely believable :).
>
You can use puts too, at least in v7.
The system call interface between V6 and V7 changed as well... Some
internal AT&T branches
(cb unix for one) could run both V6 and V7 binaries. BSD uses the v7 system
call interface through
2.10.x. 2.11 moves to a new system call interface as well. There's niggles
in these statements, since
it isn't quite exactly the same, but for things like this it's ok.
V7 also moved to stdio completely. V6 had precursor routines to stdio and
mesg() was dropped in
that whole process.
Warner
[-- Attachment #2: Type: text/html, Size: 2820 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TUHS] asm helper routines in v7
2022-01-04 21:28 ` Warner Losh
@ 2022-01-05 17:35 ` Dan Cross
0 siblings, 0 replies; 9+ messages in thread
From: Dan Cross @ 2022-01-05 17:35 UTC (permalink / raw)
To: Warner Losh; +Cc: TUHS main list
On Tue, Jan 4, 2022 at 4:28 PM Warner Losh <imp@bsdimp.com> wrote:
> On Tue, Jan 4, 2022 at 2:24 PM Will Senn <will.senn@gmail.com> wrote:
>> Yep, that worked... you make it look so easy, and your rationales are definitely believable :).
It would be nice to hear about the rationale from a primary source.
Perhaps Ken or Doug might chime in?
> You can use puts too, at least in v7.
Ah right; I always forget that puts was unequivocally a function in
7th Ed. It'll even add a newline for you!
- Dan C.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TUHS] asm helper routines in v7
2022-01-04 20:37 [TUHS] asm helper routines in v7 Will Senn
2022-01-04 21:12 ` Dan Cross
@ 2022-01-04 21:38 ` Clem Cole
1 sibling, 0 replies; 9+ messages in thread
From: Clem Cole @ 2022-01-04 21:38 UTC (permalink / raw)
To: Will Senn; +Cc: TUHS main list
[-- Attachment #1: Type: text/plain, Size: 563 bytes --]
On Tue, Jan 4, 2022 at 3:38 PM Will Senn <will.senn@gmail.com> wrote:
> 1. Is mesg or an equivalent available in v7?
>
its not part of the C stdio library and by te
> 2. If not, what was the v7 way of putting strings out?
>
_puts declared as an external
> 3. Why aren't the system call names defined?
>
Ah .. you want the DEC assembler ;-) By the time of V5/V6 assembler is
starting to have less importance and by V7, little if anything is left.
> 4. What was the v7 way of naming system calls?
>
_XXX where XXX is the system call declared as a global.
[-- Attachment #2: Type: text/html, Size: 1995 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [TUHS] asm helper routines in v7
@ 2022-01-06 3:26 Douglas McIlroy
2022-01-06 3:37 ` Warner Losh
2022-01-06 16:00 ` Clem Cole
0 siblings, 2 replies; 9+ messages in thread
From: Douglas McIlroy @ 2022-01-06 3:26 UTC (permalink / raw)
To: TUHS main list
> It would be nice to hear about the rationale from a primary source.
Assembly language was deemed a last resort, especially as portability
was coming to the fore. As I wrote in A Research Unix Reader,
"Assembly language and magic constants gradually declined from the
status of the 'real truth' (v4) to utterly forgotten (v8)." In v7,
assembler usage was demoted to the bottom of syscall man pages. It
could also be found in /usr/src/libc/sys/*.s
Doug
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TUHS] asm helper routines in v7
2022-01-06 3:26 Douglas McIlroy
@ 2022-01-06 3:37 ` Warner Losh
2022-01-06 16:00 ` Clem Cole
1 sibling, 0 replies; 9+ messages in thread
From: Warner Losh @ 2022-01-06 3:37 UTC (permalink / raw)
To: Douglas McIlroy; +Cc: TUHS main list
[-- Attachment #1: Type: text/plain, Size: 796 bytes --]
On Wed, Jan 5, 2022, 8:27 PM Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
wrote:
> > It would be nice to hear about the rationale from a primary source.
>
> Assembly language was deemed a last resort, especially as portability
> was coming to the fore. As I wrote in A Research Unix Reader,
> "Assembly language and magic constants gradually declined from the
> status of the 'real truth' (v4) to utterly forgotten (v8)." In v7,
> assembler usage was demoted to the bottom of syscall man pages. It
> could also be found in /usr/src/libc/sys/*.s
>
That makes a lot of sense. I've found errors and omissions in the assembler
documentation for the odd system call for V7 and System III ports. A little
sloppy I thought when I noticed. I'll have to see if I can dig one up
again...
Warner
>
[-- Attachment #2: Type: text/html, Size: 1420 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [TUHS] asm helper routines in v7
2022-01-06 3:26 Douglas McIlroy
2022-01-06 3:37 ` Warner Losh
@ 2022-01-06 16:00 ` Clem Cole
1 sibling, 0 replies; 9+ messages in thread
From: Clem Cole @ 2022-01-06 16:00 UTC (permalink / raw)
To: Douglas McIlroy; +Cc: TUHS main list
[-- Attachment #1: Type: text/plain, Size: 303 bytes --]
On Wed, Jan 5, 2022 at 10:27 PM Douglas McIlroy <
douglas.mcilroy@dartmouth.edu> wrote:
> As I wrote in A Research Unix Reader, "Assembly language and magic
> constants gradually declined from the
> status of the 'real truth' (v4) to utterly forgotten (v8)."
Ah ... theory and practice in alignment.
[-- Attachment #2: Type: text/html, Size: 1006 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-01-06 16:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04 20:37 [TUHS] asm helper routines in v7 Will Senn
2022-01-04 21:12 ` Dan Cross
2022-01-04 21:24 ` Will Senn
2022-01-04 21:28 ` Warner Losh
2022-01-05 17:35 ` Dan Cross
2022-01-04 21:38 ` Clem Cole
2022-01-06 3:26 Douglas McIlroy
2022-01-06 3:37 ` Warner Losh
2022-01-06 16:00 ` Clem Cole
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).