Are you blogging on PH? Get your free blog.

View \XCRC.ASM

Modem Protocol Source Codes (Pascal).

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


title   'XCRC linkage to CRC'
name    xcrc
cseg    segment byte public 'CODE'
        assume  cs : cseg
        public  crcasm, crca
;
; PROCEDURE crc(byte, VAR integer);
; incorporates byte in integer using x^16+x^12+x^5+1
crcasm  proc      far
        pop     dx;    return offset
        pop     cx;    return segment
        pop     bx;    ^integer, offset
        pop     es;    ^integer, segment
        pop     ax;    al := byte
        push    cx;  return segment
        push    dx;  return offset
        mov     dx,es:[bx];  old crc value
;       ------  busy regs - speed optimized.
        xor     al,dh;       al ah dl dh
        mov     ah,al;        x  x  x 
        ror     al,1;         x  x  x
        ror     al,1;         x  x  x
        ror     al,1;         x  x  x
        ror     al,1;         x  x  x
        and     al,0fh;       x  x  x
        xor     al,ah;   x     x
        mov     dh,al;        x     x  . 
        ror     al,1;         x     x  .
        ror     al,1;         x     x  .
        ror     al,1;         x     x  .
        mov     ah,al;        x  x  x  .
        and     al,1fh;       x  x  x  .
        xor     al,dl;        x  x     .
        xchg    dh,al;       .  .     .
        mov     dl,al;           .  .  .
        mov     al,ah;        x  x  .  x
        and     al,0e0h; x  x     x
        xor     dl,al;           .  .  .
        ror     ah,1;            x  x  x
        and     ah,0f0h;    x  x  x
        xor     dh,ah;              x  x    one byte done
;       -----
        mov     es:[bx],dx;  save result
        ret
crcasm  endp
;
; PROCEDURE crca(VAR byte array; VAR integer);
; incorporates bytes in integer using x^16+x^12+x^5+1
crca    proc        far
        pop     dx;    return offset
        pop     ax;    return segment
        pop     bx;    ^integer, offset
        pop     es;    ^integer, segment
        pop     cx;    length
        pop     si;    ^array, offset
        pop     di;    ^array, segment
        push    ax;  return segment
        push    dx;  return offset
        push    ds;  save
        mov     ds,di;              array segment
        mov     dx,es:[bx];  incoming crc
        jcxz    crca2;            zero length
crca1:  lodsb
;       ------  busy regs - speed optimized
        xor     al,dh;       al ah dl dh
        mov     ah,al;        x  x  x 
        ror     al,1;         x  x  x
        ror     al,1;         x  x  x
        ror     al,1;         x  x  x
        ror     al,1;         x  x  x
        and     al,0fh;       x  x  x
        xor     al,ah;   x     x
        mov     dh,al;        x     x  . 
        ror     al,1;         x     x  .
        ror     al,1;         x     x  .
        ror     al,1;         x     x  .
        mov     ah,al;        x  x  x  .
        and     al,1fh;       x  x  x  .
        xor     al,dl;        x  x     .
        xchg    dh,al;       .  .     .
        mov     dl,al;           .  .  .
        mov     al,ah;        x  x  .  x
        and     al,0e0h; x  x     x
        xor     dl,al;           .  .  .
        ror     ah,1;            x  x  x
        and     ah,0f0h;    x  x  x
        xor     dh,ah;              x  x    one byte done
;       -----
        loop    crca1;            over the array
        mov     es:[bx],dx;  save result
crca2:  pop       ds
        ret
crca    endp

cseg    ends
        end
 
corner
© 1996-2008. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin.
bootstrapLabs Logo A bootstrapLabs project.