01.03.2014 Views

Section 2 - Commodore Computers

Section 2 - Commodore Computers

Section 2 - Commodore Computers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

May, 1982, Issue 24<br />

116 . COMPUTEI<br />

COMPUTE! May. 1982. Issue 24<br />

better way of detecting g errors. The most common<br />

CCRC that is used is a 16 bit polynomial, defined as<br />

(X + I 1 )*(X' )*(X* 15 + X + I). 1). By starting with a value e of<br />

zero in the CRC and passing g all the (lie received data<br />

through the CCRC routine. routine, when the final CRC<br />

received passes through the routine, the final<br />

result will be 0 (if {ifno errors were eencountered).<br />

There is no single besl best way to transfer programs<br />

via a modem, but bill there are some melhods<br />

methods<br />

which arc are better than olhers.<br />

others.<br />

*CPItH *C/V/W ;S is 1I a Iraril'Jllarlt trademark oj ofDigital Rt'search<br />

Research<br />

Computing A Checksum<br />

Checksum generates a sum of the data that<br />

is passed through it by adding (without any<br />

carry) each byte with the sum of the previous<br />

bytes. The checksum is initiallyy set to zero<br />

aand the final result is sent to be compared<br />

against the independently computed check­<br />

sum atlhe the receiver computer. Since thee<br />

checksum is ann eighl eight bit value. value, only a single<br />

byte of data needs to be sent. It is quick and<br />

easy to perform this with a computer. The<br />

checksum method can onlyy reliably catch<br />

single bit errors. Although it does do reasonably<br />

well with wilh multibil Illultibit errors, the e percentages<br />

can rapidly drop lo to the realm of or<br />

coin toss odds.<br />

To use the checksum program enter it<br />

To use the checksum program enter it<br />

with the data in the accumulator. The result<br />

is saved in location CHKSUMC H for [i) r later use.<br />

The location CHKSUMC I-I M should be cleared<br />

to zero at the start of sending the data<br />

to zero at the start o f sending the data<br />

stream. stream,<br />

8080 VERSION 6502 VERSION<br />

CHKSUM PUSH PSW CHKSUM PHA<br />

PUSH B<br />

PHP<br />

MOV<br />

LDA LOA<br />

ADD STA POP POP RET<br />

C,A CHKSUM<br />

C CHKSUM B PSW CLC<br />

ADC STA PLP<br />

PLA<br />

RTS<br />

CHKSUM<br />

CHKSUM<br />

This shortha nd version for th e 8080<br />

This shorthand version for the 8080<br />

assumes that at a register in the I CPU C does<br />

not get destroyed by the calling program,<br />

and that it is acceptable for the flags to be<br />

destroyed.<br />

not get destroyed by the calling program,<br />

and that it is acceptable for the flags to be<br />

d estroyed .<br />

8080 VERSION<br />

8080 VERSION<br />

CHKSUM ADDC C<br />

MOV C,A<br />

MOVC,A<br />

RET<br />

RET<br />

The CRC Method<br />

eRC computes CRC-1 6 crcsum from the poly­<br />

CRC computes CRC-16 crcsum from the poly<br />

nomial nomiaI(X+l)*X"15 1)* X' + X X+l) + I)<br />

A CRC method of error detection is far<br />

supe superior to the checksum. By using a 16 Hi bit<br />

value e for the sum instead or ofan eight bit<br />

va value, e. a much improved detection capability<br />

is achieved. By using a polynomial of th the e<br />

proper type, the 16 bit va value can be used<br />

ra far r more effectively as well. The provided<br />

polynomial can detect errors or of up to 171 7<br />

bits.<br />

Since the CRCSUM generated is a<br />

division remainder, r, a CRCSUMed CRCSUMcd data<br />

sequence can be verified ed by running the<br />

data through the CRC, and thenn running<br />

the e previously obtained CCRCSUM M throughh<br />

the CRC. Re. The resultant CRCSUMM should<br />

be zero. When the CRCSUM itself is transmittemined,<br />

, it should not be run through the e<br />

trans-<br />

CRC as this would disrupt the result. Also. Also,<br />

the MSB (1-1) {H } must be run through h the<br />

CRC first then followed by the LSB (L)<br />

{ L }<br />

whenn checking the CRCSUM.<br />

To use li this routine, rOlltine, enter with the byte<br />

to be CRCSUMed in A (accumulator). TThe<br />

CRCSUMC is automatically tica y updated upon UPO Il<br />

passing the data through this is routine.<br />

8080 VERSION<br />

6502 VERSION<br />

CRC<br />

CRC2 2<br />

A CRC method of error detection is rar<br />

bits.<br />

Si nce the CRCSUM generated is a<br />

C RC<br />

CRCI<br />

PUSH P PSW<br />

PUSH PUS H B8<br />

PUSH<br />

H<br />

MVI B,8 8,8<br />

LHLD LHLO<br />

CRCSUM<br />

RCL<br />

MOV<br />

C,A<br />

MOV<br />

A,L<br />

ADD AOO<br />

A<br />

MOV<br />

L.A<br />

MOV 1\-fOV<br />

A,H<br />

RAL<br />

MOV<br />

H.A<br />

RAL<br />

XRA<br />

C<br />

RRC<br />

JNC<br />

CRC2<br />

MOV<br />

A,H<br />

XRI<br />

80H<br />

MOV H,A H.A<br />

MOV A.L<br />

MOV<br />

XRI X IU<br />

MOV<br />

MOV<br />

DCR OCR<br />

JNZ<br />

SHLD<br />

POP<br />

POP<br />

POP<br />

RET<br />

ENO<br />

END<br />

A.L<br />

051-1 H<br />

L.A<br />

A,C<br />

A,C<br />

B<br />

CRC I<br />

CRCSUM<br />

H<br />

CRCI<br />

CRCSUM<br />

H<br />

B<br />

PSW<br />

CRC<br />

PHP<br />

PHA<br />

STX<br />

XTEMP<br />

LDX LOX #0811 # 08>1<br />

CRCI<br />

I ASL<br />

ADC AOC<br />

A<br />

#00H #OOH<br />

STA<br />

CRCTMP<br />

LDA LOA<br />

CRCSUM<br />

ASL<br />

A<br />

STA<br />

CRCSUM<br />

LDA LOA CRCSUM+1<br />

J<br />

ROL<br />

A<br />

STA CRCSUM+1<br />

CRCSUM+ J<br />

ROL<br />

A<br />

EOR<br />

CRCTMP<br />

LSR<br />

A<br />

BCC<br />

CRC2<br />

LDA LOA CRCSUM+1<br />

I<br />

EOR #80H<br />

STA<br />

CRCSUM+ + II<br />

LDA LOA<br />

CRCSUM<br />

EOR #5H #05H<br />

STA STA<br />

CRCSUM<br />

CRC2 LDA LOA CRCTMP CRCTM P<br />

DEX DEX<br />

BNE CRCI<br />

BNE<br />

LDX LOX<br />

PLA PLA<br />

PLP<br />

RTS<br />

ENO<br />

END<br />

CRCI<br />

XTEMP<br />

XTEMP

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!