home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol027 / crcgen.asm < prev    next >
Encoding:
Assembly Source File  |  1985-02-10  |  7.0 KB  |  178 lines

  1. Title 'CRCC GENERATOR for ATS GCP ROM'
  2. ;    File CRCGEN.ASM
  3. ;         
  4. ;         Written Feb. '81 by:
  5. ;         d.a. steele
  6. ;         Information Development and Applications Inc.
  7. ;         10759 Tucker St.
  8. ;         Beltsville, MD. 20705
  9. ;
  10. ;This program is to be loaded and execuited in the GCP by useing
  11. ;ILOAD and will generate and print out to the console the CRC 
  12. ;value to be used in the GCP ROM test of the ATS Diagnostics.
  13. ;After this program is ran the operator will need to run SID.
  14. ;Using SID create load the first two bytes at 100h with these two
  15. ;values.  The low byte first.  Now exit SID by useing a ^C and
  16. ;save one page into a file called CRCC.DAT.  This file will be needed
  17. ;on the diagnositcs disc before running the GCP ROM test.
  18. maclib    z80
  19. ;aseg
  20. GBASE      EQU       0F800H
  21. WBOOT      EQU       GBASE + 3    ;Warm reset of the GCP boot code
  22. CONST      EQU       GBASE + 6    ;Console status
  23.                                   ;Tests status of keyboard input
  24.                                   ;<A> = 0FFH  --> keystroke is available
  25.                                   ;<A> = 0     --> keystroke not available
  26. CONIN      EQU       GBASE + 9    ;Console input
  27.                                   ;Waits for input. 
  28.                                   ;Returns with keystroke in <A>
  29. CONOUT     EQU       GBASE + 12   ;Console output
  30.                                   ;Prints contents of <C> to Plasma
  31. STRING     EQU       GBASE + 15   ;String output
  32.                                   ;Prints string pointed to by <HL> to Plasma
  33.                                   ;Terminates on string containing 00H
  34. MCPSTAT    EQU       GBASE + 18   ;MCP status
  35.                                   ;Tests status of MCP input port
  36.                                   ;<A> = 0FFH --> Char. ready for parallel inpt
  37.                                   ;<A> = 00   --> Char. not ready
  38. MCPIN      EQU       GBASE + 21   ;MCP input
  39.                                   ;Wait for MCP input
  40.                                   ;Input returned in <A>
  41. MCPOUT     EQU       GBASE + 24   ;MCP output
  42.                                   ;Output char in <C> to the MCP
  43.  
  44.            ORG       6000H        ;Set the stack pointer
  45. START:     LXI       SP,7000H     
  46.            LXI       B,0F800H     ;starting address of ROM
  47.            LXI       D,3FFFH      ;ending address
  48.            CALL      CRC
  49.                                   ;Now we have the CRCC of the EPROMS
  50.                                   ;So print them pot to the console
  51.            PUSH      H            ;Save the CRCC
  52.            LXI       H,LOWB       ;Print low byte msg.
  53.            CALL      STRING
  54.            POP       H            ;Get the CRCC in HL 
  55.            PUSH      H            ;Then put it awayè           MOV       A,L          ;Put low byte in a to be printed
  56.            RRC                    ;Convert to hex format
  57.            RRC
  58.            RRC
  59.            RRC
  60.            CALL      OUTCHR       ;Print pot the first hex digit
  61.            POP       H
  62.            PUSH      H
  63.            MOV       A,L
  64.            CALL      OUTCHR       ;Print the second hex digit of the low byte
  65.            LXI       H,HIB        ;Print the high message
  66.            CALL      STRING       
  67.            POP       H            ;Get the CRC back again
  68.            PUSH      H
  69.            MOV       A,H          ;Put high hex digit into a
  70.            RRC                    ;Convert to hex
  71.            RRC
  72.            RRC
  73.            RRC
  74.            CALL      OUTCHR       ;Print out high hex digit
  75.            POP       H
  76.            MOV       A,H
  77.            CALL      OUTCHR       ;print out the low hex digit
  78.            LXI       H,CRLF       ;and do a CR LF
  79.            CALL      STRING
  80.            JMP       WBOOT        ;End with a jump to WBOOT
  81.  
  82. OUTCHR:    ANI       0FH          ;Print out the hex char. in A
  83.            ADI       90H
  84.            DAA
  85.            ACI       40H
  86.            DAA
  87.            MOV       C,A
  88.            CALL      CONOUT
  89.            RET
  90.           
  91.  
  92.  
  93.  
  94. LOWB:      DB        'Low Byte = ',0
  95. HIB:       DB        '  High Byte = ',0 
  96. CRLF:      DB        0AH,0DH,0
  97. POINT:     DW        0
  98.  
  99. CRC:                              ;This is the CRCC generator routine
  100.                                   ;This routine computes the CRCC char
  101.                                   ;(16 bits) on the area of memory
  102.                                   ;specified by the call parameters
  103.            PUSH      B            ;Save the first
  104.            MOV       A,C
  105.            CMA
  106.            MOV       C,A
  107.            MOV       A,B
  108.            CMA
  109.            MOV       B,Aè           INX       B
  110.            XCHG
  111.            DAD       B
  112.            PUSH      H
  113.            POP       B
  114.            POP       H
  115.            INX       B            ;Adjust the length
  116.            CALL      CRCGEN
  117.            RET
  118.  
  119. CRCGEN:                         ;CRCC Gennerator
  120.                                 ;HL Beginning of file
  121.                                 ;BC Length of file
  122.                                 ;<POINT> save location of the result
  123.                                 ;HL result saved
  124.                                 ;Generator polynominal G(X)=X(16)+X(12)+X(5)+1
  125.            
  126. GX1        EQU       00100001B    ;Generator polynominal
  127. GX2        EQU       00010000B    ;same
  128.  
  129.                                   ;Beginning of routine
  130.            SHLD      POINT        ;Save location of P(X)
  131.            PUSH      B            ;save length
  132.            POP       H
  133.            LXI       D,-1         ;Initialize CRC generator
  134.            MVI       C,8          ;Bit count
  135. CRC2:                             ;Do the generation
  136.            PUSH      H            ;Load (BC) @ POINT
  137.            LHLD      POINT        ;Load next P(X)
  138.            MOV       B,M
  139.            INX       H
  140.            SHLD      POINT
  141.            POP       H
  142. CRC4:      
  143.            MOV       A,E
  144.            ADD       E
  145.            MOV       E,A
  146.            MOV       A,D
  147.            ADC       D
  148.            MOV       D,A
  149.            JC        CRC3         ;JMP if MSB = 1
  150.  
  151.            MOV       A,B          ;shift P(X) left (B)
  152.            ADD       B
  153.            MOV       B,A
  154.            JNC       CRCOUT       ;JMP if MSB = 0
  155.  
  156. CRCXOR:    MOV       A,E          ;XOR CRC and G(X)
  157.            XRI       GX1
  158.            MOV       E,A
  159.            MOV       A,D
  160.            XRI       GX2
  161.            MOV       D,A
  162. CRCOUT:    DCR       C            ;CK bit count
  163.            JNZ       CRC4è           MVI       C,8
  164.            DCX       H            ;Ck word count
  165.            MOV       A,L
  166.            ORA       H
  167.            JNZ       CRC2
  168.            XCHG                   ;save the CRC result
  169.            SHLD      POINT
  170.            RET
  171.  
  172. CRC3:      MOV       A,B          ;Shift P(X)
  173.            ADD       B
  174.            MOV       B,A
  175.            JC        CRCOUT       ;JMP if MSB = 1           
  176.            JMP       CRCXOR       ;JMP if XOR MSB = 0
  177.  
  178.