.TITLE SELECT .IDENT /hah010/ .PSECT CODE,RO ; ; VERSION 00 ; ; TOM GETZINGER 29-DEC-79 ; ; Modified: 27-Jul-85 hah010 ; Convert SELECT subroutine to support DOB as a I&D space task. ; ; THIS ROUTINE DOES A COMPUTED GOTO OR CALL ; ; CALLING SEQUENCE: ; MOV VALUE,R1 ; LOAD THE VALUE INTO R1 ; CALL SELECT ; DO THE COMPUTED JUMP ; .BYTE LOWVAL,HIVAL ; THESE ARE THE LEGAL LIMITS ; .WORD BADVAL ; IT GOES HERE IF THE VALUE IS ILLEGAL ; .WORD LOWEST ; IT GOES HERE IF VALUE=LOWVAL ; .WORD NEXT ; IT GOES HERE IF VALUE=LOWVAL+1 ; : ; : ; .WORD HIGHEST ; IT GOES HERE IF VALUE=HIVAL ; (NEXT INSTRUCTION) ; ; THE PROCESSOR ADDRESSES (E.G. BADVAL, LOWEST, HIGHEST) ARE ; JUMPED TO IF EVEN. IF ODD, A CALL IS MADE TO THE VALUE-1, WHICH ; RETURNS TO THE INSTRUCTION AFTER THE PROCESSOR ADDRESS LIST. ; ; New calling sequence: ;hah010 ; mov value,r1 ;hah010 ; mov r0,-(sp) ;SELECT restores this value to R0 ;hah010 ; mov #table,r0 ;Pointer to table of above format ;hah010 ; call select ;hah010 ; (next instruction) ;Only returns here if address are odd ;hah010 ; ;hah010 ; Stack at this point: ;hah010 ; 2(sp) Old r0 ;hah010 ; 0(sp) Return address to caller (thrown away if jmp desired). ;hah010 SELECT:: MOV R1,-(SP) ; SAVE THE VALUE MOV R2,-(SP) ; SAVE R2 CMPB R1,(R0) ; IS THE VALUE LEGAL? BLT 10$ ; NO CMPB R1,1(R0) ; MAYBE BGT 10$ ; NO MOVB (R0),R2 ; GET LOW VALUE SUB R2,R1 ; GET OFFSET ASL R1 ; CONVERT TO WORD OFFSET ADD #4,R1 ; R1 = OFFSET TO PROCESSOR ADDRESS BR 20$ ; GO TO THE PROCESSOR 10$: MOV #2,R1 ; R1 = OFFSET TO ILLEGAL VALUE PROCESSOR 20$: ADD R0,R1 ; R1 = ADDRESS OF PROCESSOR ADDRESS BIT #1,(R1) ; SHOULD WE CALL THE PROCESSOR? BNE 30$ ; YES ; ; Stack: ;hah010 ; 6(sp) Old R0 ;hah010 ; 4(sp) Return address to caller ;hah010 ; 2(sp) R1 ;hah010 ; 0(sp) R2 ;hah010 ; ;hah010 MOV (R1),4(SP) ; NO, SET RET ADDR TO PROCESSOR ADDRESS ;hah010 ; ;hah010 ; Stack: ;hah010 ; 6(sp) Old R0 ;hah010 ; 4(sp) Processor address to "JMP" to. ;hah010 ; 2(sp) R1 ;hah010 ; 0(sp) R2 ;hah010 ; ;hah010 MOV (SP)+,R2 ; RESTORE R2 MOV (SP)+,R1 ; RESTORE R1 ; ;hah010 ; Stack: ;hah010 ; 2(sp) Old R0 ;hah010 ; 0(sp) Processor address to "JMP" to. ;hah010 ; ;hah010 mov 2(sp),r0 ; Restore R0 ;hah010 mov @sp,2(sp) ; Bump up return address ;hah010 tst (sp)+ ; Clean stack ;hah010 return ; Jump to processor ;hah010 ; ;hah010 ; Stack: ;hah010 ; 6(sp) Old R0 ;hah010 ; 4(sp) Return address to caller ;hah010 ; 2(sp) R1 ;hah010 ; 0(sp) R2 ;hah010 ; ;hah010 30$: mov @r1,r1 ; Get processor address+call flag ;hah010 bic #1,r1 ; Clear "Call" flag ;hah010 mov (sp)+,r2 ; Restore work register ;hah010 ; ;hah010 ; Stack: ;hah010 ; 4(sp) Old R0 ;hah010 ; 2(sp) Return address of caller ;hah010 ; 0(sp) R1 ;hah010 ; ;hah010 mov 4(sp),r0 ; Restore r0 ;hah010 mov 2(sp),4(sp) ; Bump return address up ;hah010 ; ;hah010 ; Stack: ;hah010 ; 4(sp) Return address of caller ;hah010 ; 2(sp) Return address of caller ;hah010 ; 0(sp) R1 ;hah010 ; ;hah010 mov r1,2(sp) ; Put in address of processor ;hah010 ; ;hah010 ; Stack: ;hah010 ; 4(sp) Return address of caller ;hah010 ; 2(sp) Address of processor ;hah010 ; 0(sp) R1 ;hah010 ; ;hah010 mov (sp)+,r1 ; Restore R1 ;hah010 RETURN ; CALL THE PROCESSOR .END