home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / mdec / rpuboot.s < prev    next >
Encoding:
Text File  |  1979-01-10  |  3.1 KB  |  252 lines

  1. / disk boot program to load and transfer
  2. / to a unix entry
  3.  
  4. / entry is made by jsr pc,*$0
  5. / so return can be rts pc
  6.  
  7. core = 28.
  8. .. = [core*2048.]-512.
  9.  
  10. / establish sp and check if running below
  11. / intended origin, if so, copy
  12. / program up to 'core' K words.
  13. start:
  14.     mov    $..,sp
  15.     mov    sp,r1
  16.     cmp    pc,r1
  17.     bhis    2f
  18.     clr    r0
  19.     cmp    (r0),$407
  20.     bne    1f
  21.     mov    $20,r0
  22. 1:
  23.     mov    (r0)+,(r1)+
  24.     cmp    r1,$end
  25.     blo    1b
  26.     jmp    (sp)
  27.  
  28. / clear core to make things clean
  29. 2:
  30.     clr    (r0)+
  31.     cmp    r0,sp
  32.     blo    2b
  33.  
  34. / at origin, read pathname,
  35. / initialize rp
  36.  
  37.     clr    *$rpcs        / selects drive zero
  38. / spread out in array 'names', one
  39. / component every 14 bytes.
  40.     mov    $names,r1
  41. 1:
  42.     mov    r1,r2
  43. 2:
  44.     jsr    pc,getc
  45.     cmp    r0,$'\n
  46.     beq    1f
  47.     cmp    r0,$'/
  48.     beq    3f
  49.     movb    r0,(r2)+
  50.     br    2b
  51. 3:
  52.     cmp    r1,r2
  53.     beq    2b
  54.     add    $14.,r1
  55.     br    1b
  56.  
  57. / now start reading the inodes
  58. / starting at the root and
  59. / going through directories
  60. 1:
  61.     mov    $names,r1
  62.     mov    $2,r0
  63. 1:
  64.     clr    bno
  65.     jsr    pc,iget
  66.     tst    (r1)
  67.     beq    1f
  68. 2:
  69.     jsr    pc,rmblk
  70.         br start
  71.     mov    $buf,r2
  72. 3:
  73.     mov    r1,r3
  74.     mov    r2,r4
  75.     add    $16.,r2
  76.     tst    (r4)+
  77.     beq    5f
  78. 4:
  79.     cmpb    (r3)+,(r4)+
  80.     bne    5f
  81.     cmp    r4,r2
  82.     blo    4b
  83.     mov    -16.(r2),r0
  84.     add    $14.,r1
  85.     br    1b
  86. 5:
  87.     cmp    r2,$buf+512.
  88.     blo    3b
  89.     br    2b
  90.  
  91. / read file into core until
  92. / a mapping error, (no disk address)
  93. 1:
  94.     clr    r1
  95. 1:
  96.     jsr    pc,rmblk
  97.         br 1f
  98.     mov    $buf,r2
  99. 2:
  100.     mov    (r2)+,(r1)+
  101.     cmp    r2,$buf+512.
  102.     blo    2b
  103.     br    1b
  104. / relocate core around
  105. / assembler header
  106. 1:
  107.     clr    r0
  108.     cmp    (r0),$407
  109.     bne    2f
  110. 1:
  111.     mov    20(r0),(r0)+
  112.     cmp    r0,sp
  113.     blo    1b
  114. / enter program and
  115. / restart if return
  116. 2:
  117.     jsr    pc,*$0
  118.     br    start
  119.  
  120. / get the inode specified in r0
  121. iget:
  122.     add    $15.,r0
  123.     mov    r0,r5
  124.     ash    $-3.,r0
  125.     bic    $!17777,r0
  126.     mov    r0,dno
  127.     clr    r0
  128.     jsr    pc,rblk
  129.     bic    $!7,r5
  130.     ash    $6,r5
  131.     add    $buf,r5
  132.     mov    $inod,r4
  133. 1:
  134.     mov    (r5)+,(r4)+
  135.     cmp    r4,$inod+64.
  136.     blo    1b
  137.     rts    pc
  138.  
  139. / read a mapped block
  140. / offset in file is in bno.
  141. / skip if success, no skip if fail
  142. / the algorithm only handles a single
  143. / indirect block. that means that
  144. / files longer than 10+128 blocks cannot
  145. / be loaded.
  146. rmblk:
  147.     add    $2,(sp)
  148.     mov    bno,r0
  149.     cmp    r0,$10.
  150.     blt    1f
  151.     mov    $10.,r0
  152. 1:
  153.     mov    r0,-(sp)
  154.     asl    r0
  155.     add    (sp)+,r0
  156.     add    $addr+1,r0
  157.     movb    (r0)+,dno
  158.     movb    (r0)+,dno+1
  159.     movb    -3(r0),r0
  160.     bne    1f
  161.     tst    dno
  162.     beq    2f
  163. 1:
  164.     jsr    pc,rblk
  165.     mov    bno,r0
  166.     inc    bno
  167.     sub    $10.,r0
  168.     blt    1f
  169.     ash    $2,r0
  170.     mov    buf+2(r0),dno
  171.     mov    buf(r0),r0
  172.     bne    rblk
  173.     tst    dno
  174.     bne    rblk
  175. 2:
  176.     sub    $2,(sp)
  177. 1:
  178.     rts    pc
  179.  
  180. cyl    = 0.
  181. read    = 4
  182. go    = 1
  183.  
  184. rpcs    = 176710
  185. rpda    = 176724
  186. rpca    = 176722
  187. rpba    = 176720
  188. / rp03 disk driver.
  189. / low order address in dno,
  190. / high order in r0.
  191. rblk:
  192.     mov    r1,-(sp)
  193.     mov    dno,r1
  194.     div    $20.*10.,r0
  195. /    add    $cyl,r0
  196.     mov    r0,*$rpca
  197.     clr    r0
  198.     div    $10.,r0
  199.     swab    r0
  200.     bis    r1,r0
  201.     mov    r0,*$rpda
  202.     mov    $rpba,r1
  203.     mov    $buf,(r1)
  204.     mov    $-256.,-(r1)
  205.     mov    $read+go,-(r1)
  206. 1:
  207.     tstb    (r1)
  208.     bge    1b
  209.     mov    (sp)+,r1
  210.     rts    pc
  211.  
  212. tks = 177560
  213. tkb = 177562
  214. / read and echo a teletype character
  215. getc:
  216.     mov    $tks,r0
  217.     inc    (r0)
  218. 1:
  219.     tstb    (r0)
  220.     bge    1b
  221.     mov    tkb,r0
  222.     bic    $!177,r0
  223.     cmp    r0,$'A
  224.     blo    1f
  225.     cmp    r0,$'Z
  226.     bhi    1f
  227.     add    $'a-'A,r0
  228. 1:
  229.  
  230. tps = 177564
  231. tpb = 177566
  232. / print a teletype character
  233. putc:
  234.     tstb    *$tps
  235.     bge    putc
  236.     mov    r0,*$tpb
  237.     cmp    r0,$'\r
  238.     bne    1f
  239.     mov    $'\n,r0
  240.     br    putc
  241. 1:
  242.     rts    pc
  243.  
  244. end:
  245. inod = ..-1024.
  246. addr = inod+12.
  247. buf = inod+64.
  248. bno = buf+512.
  249. dno = bno+2
  250. names = dno+2
  251. reset = 5
  252.