The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [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
* [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

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-06  3:26 [TUHS] asm helper routines in v7 Douglas McIlroy
2022-01-06  3:37 ` Warner Losh
2022-01-06 16:00 ` Clem Cole
  -- strict thread matches above, loose matches on Subject: below --
2022-01-04 20:37 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

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).