start:
    seltap1;             // the BS octal driving the leds is on TAP1
    serflg0;		 // select error flag 0 in the current TAP
    rst;                 // reset TAP
    state irshift;       // go to Shift-IR state
    ld cnt,8d;           // prepare to shift in 8 bits (instruction)
    nshfcp 0h,80h,C0h;   // shift in EXTEST, check the sequence shifted out
    jerr insterror;
    state drshift;       // move on to Shift-DR state
    ld cnt,18d;          // prepare to shift in an 18-bit test vector
    nshfcp 55000h,       // place neighbouring outputs in opposite states
           00FF0h,       // and check that all inputs capture a 1
           00FF0h;     
    jerr dataerror;  
    tms1;                // apply test vector (move on to Update-DR)
    tms0;                // go to Run Test / Idle state
    halt;                // stops here if no errors are detected
insterror:
    halt;                // stops here if an instruction error is found
dataerror:
    halt;                // stops here if a data error is found