dlinyj: (Default)
[personal profile] dlinyj
Я таки перенёс код с одного камня на другой. Вышла очень даже ничего. Правда пришлось RFM по обоим кристаллам. Так вот что вышло:
Код АТ89С51: 
DOW_CRC:	PUSH ACC         	;Save the Accumulator.
        PUSH B                  ;Save the B register.
        PUSH ACC                ;Save bits to be shifted.
        MOV  B,#8               ;Set to shift eight bits.
CRC_LOOP:       XRL  A,TEMP     ;Calculate DQIN xor CRCT0.
        RRC  A           	;Move it to the carry.
	MOV  A,TEMP             ;Get the last CRC value.
	JNC  ZERO        	;Skip if DQIN xor CRCT0 = 0.
	XRL  A,#18H      	;Update the CRC value.
ZERO:	RRC  A           	;Position the new CRC.
	MOV  TEMP,A      	;Store the new CRC.
	POP  ACC         	;Get the remaining bits.
	RR   A           	;Position next bit in LSB.
	PUSH ACC         	;Save the remaining bits.
	DJNZ B,CRC_LOOP  	;Repeat for eight bits.
	POP  ACC         	;Clean up the stack.
	POP  B           	;Restore the B register.
	POP  ACC         	;Restore the Accumulator.
	RET              	;Return.

Тот же код на AVR (пока на Tiny2313, хотя пишется под Tiny15):
DOW_CRC:	push	reg_TMP
		ldi		reg_count,8
CRC_LOOP:	eor		reg_TMP,reg_data
		ror		reg_TMP
		mov		reg_TMP,reg_data
		brcc	zero
		ldi		reg_TMP2,0x18
		eor		reg_TMP,reg_TMP2
ZERO:		ror		reg_TMP
		pop		reg_TMP
		mov		reg_TMP,r23
		lsr		reg_TMP
		push	reg_TMP
		DEC		reg_count
		BRNE	CRC_LOOP
		pop		reg_TMP
		pop		reg_count
		reti
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

January 2026

S M T W T F S
    123
456 78910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 22nd, 2026 09:35 pm
Powered by Dreamwidth Studios