ALWAYS 26JAN4 CRC .MCALL DIR$,CALLR ;************************************************************************ ;* * ;* MODULE: CRC * ;* * ;* FUNCTION: COMPUTE A 16-BIT FORWARD CRC OVER A RANGE * ;* * ;* INPUT PARAMETERS: * ;* * ;* R0 POINTS TO THE COMMAND LINE IN PROCESS * ;* * ;* OUTPUT PARAMETERS: * ;* * ;* R0 POINTS JUST BEYOND COMMAND LINE * ;* * ;* DESTROYS: ALL REGISTERS * ;* * ;* AUTHOR: KEVIN ANGLEY * ;* * ;* DATE: 27-JUL-82 * ;* * ;* * ;* REVISED BY: CHRIS DORAN, SIRA * ;* * ;* DATE: Dec-83 to Jan-84 * ;* * ;* MODIFICATIONS: * ;* Support STEP/EVEN/ODD option in FROM-THRU. * ;* Put CRO message, only used here, into this module, for * ;* overlaid code. * ;* * ;************************************************************************ CRC:: CALL FROMTH ; GET FROM ADDR IN R1, THRU ADDR IN R2 ; AND COUNT IN R3 BCS 255$ ; CS: FAILURE PUSH R0 ; SAVE COMMAND LINE POINTER CLR R2 ; USE ZERO PRESET CRC 10$: CLR %4 ; Clear %4 for hi byte BISB MEMORY(R1),R4 ; OR in lo (avoids sign-extend) MOV #120001,R0 XOR R4,R2 ; XOR NEW BYTE INTO CRC MOV #8.,R5 ; BIT COUNT FOR DIVIDE 20$: CLC ROR R2 BCC 30$ XOR R0,R2 ; SUBTRACT POLY 30$: SOB R5,20$ ; DECREMENT BIT COUNT ADD STEP,R1 ; NEXT LOCATION SOB R3,10$ ; CONTINUE FOR COUNT MOV R2,R1 ; PREPARE TO OUTPUT SWAB R1 ; PUT IN HIGH-LOW MOV R2,R5 ; AND SAVE CRC FOR LATER MOV #CRO+CROLEN-4,R0 ; PUT INTO MESSAGE CALL PUTHX4 OUTPUT CRO ; OUTPUT THE MESSAGE POP R0 ; RESTORE COMMAND LINE POINTER TSTB (R0) ; "TO" SPECIFIED? BEQ 255$ ; EQ: NO - TAKE NO ACTION, CC from TSTB GETKEY TO ; GET KEYWORD "TO" BEQ 40$ ; EQ: GOT IT OUTPUT MSK ; MISSING KEYWORD BR 255$ ; TAKE ERROR EXIT 40$: CMPB #'%,(R0) ; PSEUDO-REGISTER DESTINATION FOR CRC? BNE 45$ ; NE: NO - GET 4-DIGIT HEX ADDRESS INC R0 ; POINT TO REGISTER NUMBER CLR R1 ; CLEAR HIGH BYTE OF REGISTER NUMBER CALL GETHX2 ; GET TWO DIGIT HEX NUMBER BCS 255$ ; CS: FAILURE MOVB R5,REGISTER(R1) ; PUT IN HIGH BYTE INCB R1 ; INCREMENT REGISTER NUMBER WITH WRAP SWAB R5 ; PREPARE TO PUT OUT LOW BYTE MOVB R5,REGISTER(R1) ; PUT IN LOW BYTE BR 255$ ; ALL DONE OK (CC from SWAB) 45$: CALL GETHXL ; GET TARGET ADDRESS BCS 255$ ; CS: FAILED MOV R1,R3 ; PUT REAL ADDRESS WHERE IT BELONGS MOV R2,R4 CALL VALID ; VALIDATE AND OFFSET BCS 255$ ; CS: INVALID MOVB R5,MEMORY(R2) ; PUT HIGH BYTE IN INCR34 ; INCREMENT REAL ADDRESS SWAB R5 CALL VALID ; VALIDATE AND OFFSET LOC FOR LOW BYTE BCS 255$ ; CS: INVALID MOVB R5,MEMORY(R2) ; PUT IN LO BYTE 255$: CALLR EXTRA ; PURGE SUPERFLUOUS COMMAND LINE .PSECT DATA D,RW DEFM CRO ; Only used here .EVEN .END