

    PROC  W.bus()
      SEQ
        check.for.preemption(WB, PCtemp, clock0, process.id,report, clock0,
               previous.report, preempt.frequency,preempt.magnitude,msgnum, accum.preempt,screen, found)

        IF
          found=TRUE
            SEQ
              debugmsg(report,screen, "ADDINT-AddC: PREEMPTION FOUND!!!!  Wbus", WB)

          found=FALSE
            SEQ
              debugmsg(report,screen, "ADDINT-AddC: PREEMPTION NOT FOUND!!!!  Wbus", WB)

                         



        Wdata.occ:=WB
        Data:=WB
        clock0:=Data[TIME.STAMP]

        IF
          Data[0]<>FINISH
            SEQ
              Wc? Ctrl
               

              int.to.bool(Ctrl[0], Ctrlb)
              Sp:=Ctrlb[9]
              Lsm:=Ctrlb[8]
              Nusr:=Ctrlb[5]      -- they will be part of pcc
              oldPCpar:=PCpar
              PCpar:= Ctrlb[0]
              valid:=Ctrlb[2]
              -------------------------------------------DELETE CORRESPONDING ENTRIES
              IF
                valid=FALSE    --LDR discarded in ALU      --delete 2 entries!
                  ----------------------------------------------------------------
                  SEQ
                    IF
                      invalid.instruction.buffer.empty=TRUE
                        SEQ
                          invalid.table.updated:=FALSE
                          update.instruction.buffer(VALID.TABLE,DELETE, NULL1)
                      invalid.instruction.buffer.empty=FALSE
                        SEQ
                          invalid.table.updated:=TRUE
                          update.instruction.buffer(INVALID.TABLE,DELETE, NULL1)



                valid=TRUE    --LDR/M  discarded in ALU   
                  ----------------------------------------------------------------
                  SEQ
                    IF
                      (((((lookahead.table[lkahead.table.base][6]) /\  #0C000000) = #04000000)   AND ((((lookahead.table[lkahead.table.base][6]) /\  #00100000) = #00100000)  AND  (((lookahead.table[lkahead.table.base][6]) /\  #0000F000) = #0000F000)))  OR   ((((lookahead.table[lkahead.table.base][6]) /\  #0E000000) = #08000000)   AND  ((((lookahead.table[lkahead.table.base][6]) /\  #00100000) = #00100000)   AND   (((lookahead.table[lkahead.table.base][6]) /\  #00008000) = #00008000))))  
                        SEQ
                          ldr.or.ldm.r15:=TRUE
                      TRUE
                        SEQ
                          ldr.or.ldm.r15:=FALSE

                    update.instruction.buffer(VALID.TABLE,DELETE, NULL1)

              ------------------------------------------UPDATE CORRESPONDING TABLES AND LIMITS
              IF
                (valid=FALSE) AND (invalid.table.updated=TRUE) 
                  SEQ
                    SKIP
                TRUE                     
                  SEQ  
                    ----------------------- 
                    IF
                      ldr.or.ldm.r15=TRUE
                        SEQ
                          update.instruction.buffer(VALID.TABLE,DELETE, NULL1)
                      ldr.or.ldm.r15=FALSE
                        SEQ
                          SKIP
                                 
                    limit.exists:=FALSE
                    IF                           --ckeck if the pc parity has changed
                      oldPCpar<>PCpar
                        SEQ
                          pcparchanged:=TRUE
                          -----------------------go on and delete relevant entries in the lookahead table

                          WHILE ((lookahead.table.empty=FALSE) AND ((lookahead.table[lkahead.table.base][2]) = (INT oldPCpar)))
                            SEQ
                              debugmsg(report,screen, "ADDINT-AddC: deleting lkahead table entries for discarded instructions....", Data)
                              ------------------------create invalid lookahead table???
                              IF
                                ((((((lookahead.table[lkahead.table.base][6]) /\  #0C000000) = #04000000)) OR  ((((lookahead.table[lkahead.table.base][6]) /\  #0E000000) = #08000000))) )  --LDR/M  STR/M
                                  SEQ
                                    debugmsg(report,screen, "ADDINT-AddC: inserting into INVALID TABLE ",[lookahead.table[lkahead.table.base][6], 0,0,0])
                                    IF
                                      ((((lookahead.table[lkahead.table.base][6]) /\  #0C000000) = #04000000)   AND  (((lookahead.table[lkahead.table.base][6]) /\  #00100000) = #00100000))  --ldr 
                                        SEQ
                                          append.invalid.instruction.buffer()
                                          limit.exists:=FALSE
                                      TRUE
                                        SKIP
                                    update.instruction.buffer(VALID.TABLE,DELETE, NULL1)  --first entry
                                    update.instruction.buffer(VALID.TABLE,DELETE, NULL1)  --second entry
                                    


                                ((lookahead.table[lkahead.table.base][0]=(-1)))
                                  SEQ
                                    debugmsg(report,screen, "ADDINT-AddC: inserting into INVALID TABLE ",[lookahead.table[lkahead.table.base][6], 0,0,0])

                                    append.invalid.instruction.buffer()
                                    update.instruction.buffer(VALID.TABLE,DELETE, NULL1)  --first entry 

                         
                                TRUE
                                  SEQ
                                    update.instruction.buffer(VALID.TABLE,DELETE, NULL1)  --just one entry
                      TRUE      
                        SKIP
                    -------------------------------------------
                    IF
                      ldr.or.ldm.r15=TRUE
                        SEQ
                          debugmsg(report,screen, "ADDINT-AddC: ldr.or.ldm.r15=TRUE  appending to lookahead table", Data)
                          limit.exists:=TRUE
                          update.instruction.buffer(VALID.TABLE,APPEND, [0,0,0,0])
                          ldr.or.ldm.r15:=FALSE
                      ldr.or.ldm.r15=FALSE
                        SEQ
                          debugmsg(report,screen, "ADDINT-AddC: ldr.or.ldm.r15=FALSE  NOT appending to lookahead table", Data)


              -------------------------------------------

              clock0:=clock0+delay[1] --ARBITER+SELECT
              IF
                ((Sp=TRUE) AND (Lsm=FALSE))
                  SEQ
                    debugmsg(report,screen, "ADDINT-AddC: call rapipe ", Data)
                    clock0:=clock0+delay[2]  --SELECT
                    rapipe()
                (Sp=FALSE)
                  SEQ
                    debugmsg(report,screen, "ADDINT-AddC: call rwbus ", Data)
                    clock0:=clock0+ delay[3]  --CALL+CALL

                    rwbus()
                ((Sp=TRUE) AND (Lsm=TRUE))
                  SEQ
                    clock0:=clock0+delay[7]  --SELECT+XOR
                    debugmsg(report,screen, "ADDINT-AddC: call rlsmreg ", Data)
                    rlsmreg()
          
          TRUE
            end:=TRUE
    :
    -----------------------------------------------------------------
