Annotation of cci/d/event/ttrap_evt.s, revision 1.1

1.1     ! root        1:  #
        !             2:  #     TRACE TRAP EVENT TEST
        !             3:  #
        !             4:  #     R0 = error code
        !             5:  #          1 - instruction is executed before trap exception occured
        !             6:  #              R1 : PC of instruction excecuted
        !             7:  #          2 - Error in PC after taking trap
        !             8:  #              R1 : Actual,  R2 : Expected
        !             9:  #          3 - PSL is not saved after taking trap
        !            10:  #              R2 : PC of instruction trapped
        !            11:  #          4 - Too many parameter pushed on the stack
        !            12:  #              R2 : PC of instruction trapped
        !            13: 
        !            14:        .globl  _ttrap_evt
        !            15: _ttrap_evt:
        !            16:        .word   0x1fff
        !            17:        mtpr    $0x1f,$IPL              /* Set IPL to HIGH              */
        !            18:        movab   (sp),_savvec0           /* Save sp                      */
        !            19:        mtpr    _savvec0,$ISP           /* Set ISP to sp                */
        !            20:        movl    _scb+TRACEVEC,_savvec7  /* Save TRACE trap vector       */
        !            21:        movab   vecvec6,_scb+TRACEVEC   /* Set new TRACE trap vector    */
        !            22:        movl    $-1,-(sp)               /* Set marker on sp             */
        !            23:                                        
        !            24:        andl3   $_pcb0,$0x3fffffff,r1   /* Initialize PCB slightly      */
        !            25:        mtpr    r1,$PCBB                /* Set PCBB                     */
        !            26:        movab   (sp),_pcb0              /* Set PCB_KSP to current sp    */
        !            27:        movab   (sp),_pcb0+4            /* Set PCB_USP to current sp    */
        !            28: 
        !            29:        clrl    _savvec1
        !            30:        clrl    _savvec2                /* savvec2 : exp value of savvec1 */
        !            31:                                        /* after trapped.               */
        !            32:        movab   epc1,_exp_pc            /* expected PC after trap       */
        !            33:        movab   epc1,r8
        !            34:        bispsw  $0x10                   /* Turn on TRACE enable bit     */
        !            35: epc1:  movl    $1,_savvec1
        !            36: epc2:  bicpsw  $0x10                   /* Turn off TRACE enable bit    */
        !            37:        movab   epc3,_exp_pc
        !            38:        incl    _savvec1
        !            39:        movab   epc3,r8
        !            40:        bispsw  $0x10                   /* Turn on trace enable bit     */
        !            41: epc3:  bicpsw  $0x10                   /* Turn off TRACE enable bit    */
        !            42: eee:                           
        !            43:        mtpr    $31,$IPL                /* Restore original SP, PSL,    */
        !            44:        movl    _savvec0,sp             /* TRACE trap vector.           */
        !            45:        movl    _savvec7,_scb+TRACEVEC
        !            46:        ret                             /* Done with this sucker !!     */
        !            47: 
        !            48: 
        !            49: 
        !            50:        .align  2                       /* TRACE trap handler           */
        !            51: vecvec6:
        !            52:        bicpsw  $0x10                   /* Clear TRACE bit              */
        !            53:        cmpl    _savvec1,_savvec2       /* Check if instruction is      */
        !            54:        beql    1f                      /* executed before trapped ..   */
        !            55:        movl    $1,r0
        !            56:        movl    r8,r1           /* PC of inst. executed before trapped  */
        !            57:        jmp     *badrtn                 /* Error - inst is executed     */
        !            58:                                        /* before trap occured.         */      
        !            59: 1:
        !            60:        incl    _savvec2
        !            61:        movl    (sp)+,r1                /* Pop actual PC from stack     */
        !            62:        movl    r1,r10                  /* Save PC to return            */
        !            63:        movl    _exp_pc,r2              /* Get expected PC              */
        !            64:        cmpl    r1,r2                   /* Compare to actual PC         */
        !            65:        beql    1f
        !            66:        movl    $2,r0                   /* PC error : error code = 2    */
        !            67:        jmp     *badrtn                 /* r1 = actual; r2 = expected   */
        !            68: 
        !            69: 1:
        !            70:        movab   epc2,_exp_pc            /* Expected PC of next trap     */
        !            71:        movl    (sp)+,r1                /* Pop next longword from stack */
        !            72:        movl    r1,r11                  /* Save PSL for REI             */
        !            73:        cmpl    $-1,r1                  /* Check if this's PSL or marker */
        !            74:        bneq    1f
        !            75: 2:     movl    $3,r0                   /* Error : PSL not saved        */
        !            76:        jmp     *badrtn                 /* Error code = 3; r1 = monster */
        !            77:                                        /* from stack !!                */
        !            78: 1:     cmpl    $-1,(sp)        /* Error if SP not pointing at marker   */
        !            79:        beql    1f
        !            80: 2:     movl    $4,r0                   /* Error : too many monsters    */
        !            81:        jmp     *badrtn                 /* pushed on the stack !!       */
        !            82: 1:
        !            83:        movl    r11,-(sp)               /* Push PSL & PC for next REI   */
        !            84:        movl    r10,-(sp)
        !            85:        rei
        !            86:        halt
        !            87: 
        !            88:        .align  2
        !            89: _exp_pc:
        !            90:        .long   0

unix.superglobalmegacorp.com

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