File: addbftcc.c

package info (click to toggle)
zoo 2.10-7
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 780 kB
  • ctags: 1,285
  • sloc: ansic: 9,041; asm: 793; makefile: 202
file content (99 lines) | stat: -rw-r--r-- 2,097 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma inline					/* tell turbo assemble to use inline assembly */
#ifndef LINT
static char sccsid[]="$Source: /usr/home/dhesi/zoo/RCS/addbftcc.c,v $\n\
$Id: addbftcc.c,v 1.1 91/07/07 18:40:11 dhesi Exp $";
#endif /* LINT */

extern unsigned int crccode;
extern unsigned crctab[];

void addbfcrc(buffer,count)
char *buffer;
int count;
{
	(void) kbhit();				/* allow keyboard interrupt to occur */
	_AX = crccode;					/* ax holds crccode value */
	_CX = count;					/* cx holds byte count */
	asm 	les di,buffer			/* es:di holds buffer address */

	asm 	jcxz	done		/* if zero bytes, just skip */

/* loop begins here */
xloop:
	asm 	sub bh,bh
	asm	mov bl,al
	asm 	xor bl,es:[di]		/* now bx = (crccode xor c) & 0x00ff */
	/* next statement shifts _BX left (2-byte items) */
   _DX = crctab[_BX];		/* dx <= *buffer == exp2 */
	asm	sub bh,bh			/* bh = 0 */
	asm	mov bl,ah			/* bx <- exp1 */
	asm	xor bx,dx			/* bx <- exp1 xor exp2 */
	asm	mov ax,bx			/* crccode <- exp1 xor exp2 */
	asm	inc di				/* inc buffer pointer */
	asm	loop xloop			/* dec CX, jump if not zero */
/* loop ends here */

	crccode = _AX;				/* put back calculated CRC value */

done:
	;

}


#if 0
; The following (edited) code was generated by Turbo C from the
; preceding code.  It is supplied here for porting to other systems
; and for user education.

_TEXT	segment byte public 'CODE'
_TEXT	ends

DGROUP	group	_DATA,_BSS
	assume	cs:_TEXT,ds:DGROUP

_DATA	segment word public 'DATA'
_DATA	ends

_BSS	segment word public 'BSS'
_BSS	ends

_TEXT	segment byte public 'CODE'

	assume	cs:_TEXT
_addbfcrc	proc	near
	push	bp
	mov	bp,sp
	push	di

	call	near ptr _kbhit
	mov	ax,word ptr DGROUP:_crccode
	mov	cx,word ptr [bp+8]
 		les	 di,[bp+4]			
	jcxz	short @1@362
@1@98:
 	sub	 bh,bh
	mov	 bl,al
 	xor	 bl,es:[di]		
	shl	bx,1
	mov	dx,word ptr DGROUP:_crctab[bx]
	sub	 bh,bh			
	mov	 bl,ah			
	xor	 bx,dx			
	mov	 ax,bx			
	inc	 di				
	loop	short @1@98
	mov	word ptr DGROUP:_crccode,ax
@1@362:
	pop	di
	pop	bp
	ret	
_addbfcrc	endp
_TEXT	ends

	extrn	_crccode:word
	extrn	_kbhit:near
	extrn	_crctab:word
	public	_addbfcrc
	end
#endif