1: 
   2: / C register save and restore -- version 7/75
   3: / modified by wnj && cbh 6/79 for overlaid text registers
   4: / modified by wf jolitz 2/80 to work and use emt syscall
   5: / modified for 8-byte thunk, mjk 10/81
   6: /
   7: 
   8: .globl  csv
   9: .globl  cret
  10: .globl  __ovno
  11: .globl  _etext
  12: .data
  13: __ovno: 0
  14: .text
  15: 
  16: emt= 0104000            / overlays switched by emulator trap. ovno in r0.
  17: 
  18: / ovhndlr1 through ovhndlr7 are called from the thunks after
  19: / r1 is set to the location of the first instruction in the subroutine
  20: / after the call to csv (~foo+4).  They in turn branch to ovhndlr
  21: / which sets the overlay and simulates a csv.
  22: / Thus, the subroutine's call to csv is by-passed.
  23: 
  24: .globl  ovhndlr1, ovhndlr2, ovhndlr3, ovhndlr4, ovhndlr5, ovhndlr6, ovhndlr7
  25: 
  26: ovhndlr1:
  27:         mov     $1,r0
  28:         br      ovhndlr
  29: 
  30: ovhndlr2:
  31:         mov     $2,r0
  32:         br      ovhndlr
  33: 
  34: ovhndlr3:
  35:         mov     $3,r0
  36:         br      ovhndlr
  37: 
  38: ovhndlr4:
  39:         mov     $4,r0
  40:         br      ovhndlr
  41: 
  42: ovhndlr5:
  43:         mov     $5,r0
  44:         br      ovhndlr
  45: 
  46: ovhndlr6:
  47:         mov     $6,r0
  48:         br      ovhndlr
  49: 
  50: ovhndlr7:
  51:         mov     $7,r0
  52:         br      ovhndlr
  53: 
  54: ovhndlr:
  55: 
  56: .bss
  57: .globl  _ovswtab
  58: _ovswtab:                       / table to collect overlay switch statistics
  59: .=.+400                         / long ovswtab[1 + NOVL][1 + NOVL];
  60: .text
  61: 
  62: /	_ovswtab[__ovno][r0]++;
  63:         mov     r1, -(sp)
  64:         mov     __ovno, r1      / ((__ovno
  65:         ash     $3, r1          / * (1 + NOVL))
  66:         add     r0, r1          / + r0
  67:         inc     r1              / + 1)
  68:         ash     $2, r1          / * sizeof (long)
  69:         add     $_ovswtab, r1
  70:         add     $1, -(r1)
  71:         adc     -(r1)
  72:         mov     (sp)+, r1
  73: 
  74:         cmp     r0,__ovno
  75:         beq     1f
  76:         emt
  77: 1:      mov     sp,r5
  78:         mov     __ovno,-(sp)
  79:         mov     r0,__ovno
  80:         mov     r4,-(sp)
  81:         mov     r3,-(sp)
  82:         mov     r2,-(sp)
  83:         jsr     pc,(r1)         / jsr part is sub $2,sp
  84: 
  85: / csv for routines called directly (in base or intra-overlay calls).
  86: / no overlays have been changed, so we just save the previous overlay
  87: / number on the stack. note that r0 isn't set to the current overlay
  88: / because we weren't called through a thunk.
  89: csv:
  90:         mov     r5,r1
  91:         mov     sp,r5
  92:         mov     __ovno,-(sp)    / overlay is extra (first) word in mark
  93: / rest is old code common with csv
  94:         mov     r4,-(sp)
  95:         mov     r3,-(sp)
  96:         mov     r2,-(sp)
  97:         jsr     pc,(r1)         / jsr part is sub $2,sp
  98: /
  99: / at this point, the stack frame looks like this:
 100: /
 101: /	_________________________
 102: /	|  return addr to callee|
 103: /	|_______________________|
 104: / r5->	| old r5	        |
 105: /	|_______________________|
 106: /	| previous ovnumber     |
 107: /	|_______________________|
 108: /	| old r4		|
 109: /	|_______________________|
 110: /	| old r3		|
 111: /	|_______________________|
 112: / sp->	| old r2		|
 113: /	|_______________________|
 114: /
 115: 
 116: 
 117: cret:
 118:         mov     r5,r2
 119: / get the overlay out of the mark, and if it is non-zero
 120: / make sure it is the currently loaded one
 121:         mov     -(r2),r4
 122:         bne     1f              / zero is easy
 123: 2:
 124:         mov     -(r2),r4
 125:         mov     -(r2),r3
 126:         mov     -(r2),r2
 127:         mov     r5,sp
 128:         mov     (sp)+,r5
 129:         rts     pc
 130: / not returning to root segment, so check that the right
 131: / overlay is loaded, and if not ask UNIX for help
 132: 1:
 133:         cmp     r4,__ovno
 134:         beq     2b              / lucked out!
 135: / if return address is in root segment, then nothing to do
 136:         cmp     2(r5),$_etext
 137:         blos    2b
 138: / returning to wrong overlay --- do something!
 139:         mov     r0,r3
 140:         mov     r4,r0
 141:         emt
 142:         mov     r4,__ovno
 143:         mov     r3,r0
 144: / intr. routines may run between these, so should force segment __ovno
 145:         br      2b

Defined functions

cret declared in line 9; defined in line 117; used 1 times
  • in line 9
csv declared in line 8; defined in line 89; used 1 times
  • in line 8
emt defined in line 16; used 2 times
ovhndlr defined in line 54; used 7 times
ovhndlr1 declared in line 24; defined in line 26; used 1 times
  • in line 24
ovhndlr2 declared in line 24; defined in line 30; used 1 times
  • in line 24
ovhndlr3 declared in line 24; defined in line 34; used 1 times
  • in line 24
ovhndlr4 declared in line 24; defined in line 38; used 1 times
  • in line 24
ovhndlr5 declared in line 24; defined in line 42; used 1 times
  • in line 24
ovhndlr6 declared in line 24; defined in line 46; used 1 times
  • in line 24
ovhndlr7 declared in line 24; defined in line 50; used 1 times
  • in line 24

Defined variables

__ovno declared in line 10; defined in line 13; used 20 times
_ovswtab declared in line 57; defined in line 58; used 2 times
Last modified: 1982-10-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 535
Valid CSS Valid XHTML 1.0 Strict