Newsgroup: alt.sys.pdp11 From: paramucho Date: 03 Sep 2013 On Mon, 2 Sep 2013 10:15:39 -0700 (PDT), jgh wrote: >jgh wrote: >> A Unix executable starts with a header that "looks" like it >> starts with a PDP-11 branch instruction, the "a.out" header. > > Here's a minimal example: > http://mdfs.net/Software/PDP11/Assembler/hello.mac The following program executes under RT-11 and Unix (using your Unix code). The program is assembled under RT-11. The constant UHEAD (Unix header size) is used compensate for the fact that Unix begins loading the image starting at byte (octal) 20. Under RT-11 the app displays "Hello RT-11" Under Unix it displays "Hello Unix". Note, I tested the Unix code under my RUST/XM Unix emulator. The RT-11 code works because RT-11 effectively ignores the low area of an executable image. RT-11 does use information from location (octal) 40 to location (octal) 600 or so, but the jump at START: skips that area. I guess this description is as clear as mud. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .title unixrt .mcall .print, .exit ; %build ; macro sks:unixrt/object:skb: ; link skb:unixrt/exe:skb:unixrt/nobitmap ; %end .asect .=0 ; unix startup info .word 407 ; 00 107 or 407 .word codex-start ; 02 .word datax-codex ; 04 .word objx-datax ; 06 .word 0 ; 10 size of symbol table .word 0 ; 12 ept .word 0 ; 14 unused .word 1 ; 16 no relocation data uhead=20 start: jmp unix ; 20 go to unix code .=40 ; RT-11 startup info .word rt11 ; RT-11 entry point .word 1000 ; RT-11 stack .csect ; .=1000 .blkb uhead ; pad out for unix header unix: inc isunix ; flag unix environment mov #1,r0 ; unix print message trap 4 .word hello-uhead ; relocate with "uhead" .word hellox-hello trap 1 halt rt11: inc isrt11 ; flag rt-11 environment .print #gday ; rt-11 print message .exit hello: .ascii /Hello Unix/<10.><13.> hellox: gday: .asciz /Hello RT-11/ .even isunix: .word 0 isrt11: .word 0 codex: datax: objx: .end +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Ian