Annotation of researchv10dc/cmd/icon/setup/pc_pcix/rswitch.s, revision 1.1.1.1

1.1       root        1: .globl _reflag
                      2: .globl _coswitch
                      3: .globl _boundary
                      4: .globl _sp
                      5: .globl __brkend
                      6: .globl csv
                      7: .globl cret
                      8: 
                      9:                        | coswitch(oldstate, newstate, first)
                     10:                        | int *oldstate, *newstate;
                     11:                        | int first;
                     12: _coswitch:
                     13:                        | save machine state on stack
                     14:        push bp
                     15:        mov bp,sp
                     16:        push di
                     17:        push si
                     18:        push _boundary
                     19:        mov bx,*4(bp)
                     20:        mov (bx),sp
                     21:        mov bx,*6(bp)
                     22:        mov ax,*8(bp)
                     23:        or ax,ax
                     24:        jnz not_first
                     25:                        | if (first == 0) set up new stack
                     26:        lea di,_sp
                     27:        mov _boundary,di
                     28:        mov ax,(bx)
                     29:        mov sp,ax
                     30:        sub ax,ax
                     31:        push ax
                     32:        push ax
                     33:        call _interp
                     34:        pop ax          | clear args from stack
                     35:        pop ax
                     36:        mov ax,#badret
                     37:        call _syserr
                     38: 
                     39: not_first:
                     40:        mov ax,(bx)     | switch to new stack
                     41:        mov sp,ax
                     42: 
                     43:        pop _boundary   | and restore machine state from stack
                     44:        pop si
                     45:        pop di
                     46:        pop bp
                     47:        ret
                     48: 
                     49: .data
                     50: badret:
                     51:        .asciz "interp() returned in coswitch"
                     52: 
                     53:        .text
                     54:        .globl _xruner
                     55:        .globl _runerr
                     56:        .globl _reflag
                     57:        .globl _sp
                     58:        .globl _abort
                     59: 
                     60:                        | runerr turns off stack probes and calls xrunerr
                     61:                        |  without this, calls to runerr might recurse
                     62:                        |  infinitely 
                     63: _runerr:
                     64:        mov _reflag,#1          | disable stack probes
                     65:        jmp _xruner
                     66: 
                     67: _reflag:       .word *0        | setting reflag disables stack probes
                     68: _boundary:     .word __brkend  | address of var representing limit on stack
                     69:                                |  growth
                     70: 
                     71:        .text
                     72: 
                     73:                | csv - save registers and set up procedure frame
                     74:                |  verify that stack space is sufficient for interrupt
                     75:                |  handlers and routine arithmetic      
                     76: csv:
                     77: ~csv=.
                     78:        pop     bx              | bx gets return address
                     79:        push    bp
                     80:        mov     bp,sp
                     81:        push    di
                     82:        push    si
                     83: 
                     84:        sub sp,ax               
                     85:        cmp _reflag,#1
                     86:        je csv_ok               | stack probes disabled
                     87:        mov ax,sp
                     88:        mov di,_boundary
                     89:        sub ax,(di)
                     90:        sub ax,#128
                     91:        ja csv_ok
                     92:        
                     93:        mov ax,#0
                     94:        push ax
                     95:        mov ax,#302
                     96:        push ax
                     97:        call _runerr
                     98:        call _abort             | runerr shouldn't return
                     99: 
                    100: csv_ok:
                    101:        jmp @bx
                    102: 
                    103:                        | cret - restore saved registers and remove 
                    104:                        |  procedure frame
                    105: cret:
                    106: ~cret=.
                    107:        lea     sp,*-4(bp)
                    108:        pop     si
                    109:        pop     di
                    110:        pop     bp
                    111:        ret
                    112: 
                    113: 
                    114:        .data
                    115: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.