16-bit FCS Computation Method #356
Whammo
started this conversation in
Show and tell
Replies: 2 comments 1 reply
-
What is FCS? Forth Check Sum?
…On Thu, 15 Jul 2021 at 14:06, Whammo ***@***.***> wrote:
require io
$f0b8 constant good \ rfc1662 c.2.
: ftab 8 0 do dup 1 and if1 rshift $8408 xorelse 1 rshift then loop ; \ computes FCS table entry for byte
: tomem 256 0 doi ftab $c000 i 2* + ! loop ; \ places FCS table in memory
: fcstab 2* $c000 + @ ; \ address table entry per byte and stack
: fcs ( fcs c -- newfcs c )
swap 2dup xor $ff and fcstab
swap 8 rshift xor swap ; \ calculates checksum given the previous checksum and the current byte
: rfgc ( -- fcs ) \ Read File Get Checksum --- rfgc filename
parse-name 8 8 open ioabort
clrchn 8 chkin ioabort
chrin chrin 2drop $ffffbegin chrin fcs drop readst until
clrchn 8 close ;
: aoop ( fcs -- msb lsb ) \ Add On OutPut inverted FCS as byte stream method
dup invert 8 rshift
swap invert $ff and ;
: coip ( msb lsb fcs -- fcs ) \ Calculate On InPut method
swap fcs drop swap fcs drop ;
: pppfcs16 ( fcs caddr u -- fcs caddr ) \ checksum memory range0 do tuck i + c@ fcs drop swaploop ;
: addfcs16 ( caddr u -- ) \ init checksum, do memory, append checksum
dup >r $ffff -rot pppfcs16
over invert $ff and
over r@ + c!
swap invert 8 rshift
swap r> 1+ + c! ;
: tryfcs ( caddr u+2 -- ) \ check memory checksum
$ffff -rot
pppfcs16 drop good = if ." good"else ." bad" then cr ;
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#356>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAY34O2CBNV2342VPTXQTGDTX3FMXANCNFSM5ANNALYQ>
.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
It's a checksum that returns one value ($f0b8) when it's correct. Anything else is incorrect. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions