Annotation of coherent/b/lib/libc/sys/i8086/signal.s, revision 1.1.1.1

1.1       root        1: /
                      2: / C interface routines for the signal system call.
                      3: / This is not just a direct call, but must save
                      4: / and restore user state before and after processing
                      5: / user signal code.
                      6: /
                      7: / int (*signal(signo, function))() int signo; int (*function)();
                      8: /
                      9: 
                     10: NSIG   = 16
                     11: 
                     12:        .globl  signal_
                     13:        .globl  _fpac_
                     14: 
                     15: signal_:
                     16:        mov     bx,sp           / get stack base pointer
                     17:        mov     cx,02(bx)       / get signo
                     18:        cmp     cx,$NSIG
                     19:        ja      0f              / > NSIG illegal
                     20: 
                     21:        cmp     04(bx),$1       / function
                     22:        jbe     0f              / 0 or 1 (SIG_DFL or SIG_IGN)
                     23: 
                     24:        mov     ax,$sigsave
                     25:        push    ax              / user function changed to sigsave
                     26:        push    cx              / signo
                     27:        push    bx              / and junk word where pc would be
                     28:        sys     060             / 48
                     29:        pop     bx              / pop args
                     30:        pop     cx
                     31:        pop     cx
                     32:        jmp     1f              / return value
                     33: 
                     34: 0:     sys     060             / 48
                     35: 1:     cmp     ax,$-1
                     36:        je      1f              / error return
                     37: 
                     38:        mov     cx,04(bx)       / new user function
                     39:        mov     bx,02(bx)       / signo
                     40:        add     bx,bx           / check old signal setting
                     41:        cmp     sigtable-2(bx),$-1      / in sigtable[signo-1]
                     42:        je      0f              / unknown: yield syscall return
                     43: 
                     44:        mov     ax,sigtable-2(bx)       / else yield old user function
                     45: 0:     mov     sigtable-2(bx),cx       / and save new one in table
                     46: 1:     ret
                     47: 
                     48: sigsave:
                     49:        push    _fpac_+6        / save pseudo-regs
                     50:        push    _fpac_+4
                     51:        push    _fpac_+2
                     52:        push    _fpac_
                     53:        push    ax              / save regs
                     54:        push    cx
                     55:        push    dx
                     56:        push    bx
                     57:        push    bp
                     58: 
                     59:        mov     bp,sp
                     60:        mov     bx,2*9(bp)      / get signo (pushed by system)
                     61:        push    bx              / pass to user function
                     62:        add     bx,bx
                     63:        icall   sigtable-2(bx)  / (*sigtable[signo-1])(signo);
                     64:        pop     bx
                     65: 
                     66:        mov     bx,2*10(bp)     / swap return address
                     67:        mov     cx,2*11(bp)     / and flags
                     68:        mov     2*11(bp),bx     / to facilitate return
                     69:        mov     2*10(bp),cx
                     70: 
                     71:        pop     bp              / restore regs
                     72:        pop     bx
                     73:        pop     dx
                     74:        pop     cx
                     75:        pop     ax
                     76:        pop     _fpac_          / restore pseudo-regs
                     77:        pop     _fpac_+2
                     78:        pop     _fpac_+4
                     79:        pop     _fpac_+6
                     80:        add     sp,$2           / discard signo
                     81:        popf                    / get flags
                     82:        ret
                     83: 
                     84:        .prvd
                     85: sigtable:
                     86:        .word   -1
                     87:        .word   -1
                     88:        .word   -1
                     89:        .word   -1
                     90:        .word   -1
                     91:        .word   -1
                     92:        .word   -1
                     93:        .word   -1
                     94:        .word   -1
                     95:        .word   -1
                     96:        .word   -1
                     97:        .word   -1
                     98:        .word   -1
                     99:        .word   -1
                    100:        .word   -1
                    101:        .word   -1
                    102:        .word   -1
                    103:        .word   -1
                    104:        .word   -1
                    105:        .word   -1

unix.superglobalmegacorp.com

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