CHECKSUM CALCULATION, Please Help!


+ Reply to Thread
Results 1 to 13 of 13
  1. #1
    Join Date
    Jun 2012
    Posts
    2

    Default CHECKSUM CALCULATION, Please Help!

    Hello guys,

    I use a pic 16f88 to capture data from the rs232 PC port, the data comes in packets,

    for example I get (ASCII characters): P1234 1A , where 1A is the checksum of P1234

    ASCII - HEX

    P - 50
    1 - 31
    2 - 32
    3 - 33
    4 - 34

    1 - 31
    A - 41

    The software that sends the data packets calculates the checksum as follow:

    50(P) + 31(1) + 32(2) + 33(3) + 34(4) = 11A and sends only 1A as checksum,
    BUT it sends the 1A checksum as ASCII characters, in HEX 31 and 41.

    So my question is, how can I calculate the checksum? If I add P1234 I will get 11A in HEX but I could not find a way to compare the 11A with
    the 2 bytes checksum I received 31 and 41.

    Can anyone please help me to solve this problem?
    I am programming tha pic in assembler.
    Thak you.

  2. #2

    Default Re: CHECKSUM CALCULATION, Please Help!

    Given you only have 16 possibilities, you could use a lookup table. Calculate the checksum, take the low nibble, look up the ascii in the table, compare with what you received, shift the checksum left (or simply take the high nibble), and look up the ascii in the table, and compare with what you received.

  3. #3
    Join Date
    Jun 2010
    Location
    Venezuela
    Posts
    11

    Default Re: CHECKSUM CALCULATION, Please Help!

    Hello
    , i use this:

    you call this sub, length contains the number of characters in array
    '********************* GENERAR CHECKSUM ********************************
    crc__16: ' Funcion calculo checksum
    Generator var word
    Temp var word
    CRC var word
    j var byte
    BitVal var bit
    CRC = 65535
    Generator = 40961
    For i = 1 To Length ' this contains the number of characters in buffer
    Temp = buffer[i]' data AIBDCF10
    CRC = CRC ^ Temp
    For j = 1 To 8
    BitVal = CRC.0
    CRC = CRC >> 1
    If BitVal Then
    CRC = CRC ^ Generator
    EndIf
    Next j
    Next i
    crc16[1] = (CRC // 256) ' CRC16 low byte
    crc16[2] = (CRC / 256) ' CRC16 high byte
    Return

    RESULT A1-BD-CF-10-crc16[1]-crc16[2]
    ************************************************** *************

    or use this from VisualBasic 6 use lookup table, you needed adapt to PICBASIC PRO

    Public CRCTable(0 To 511) As Byte
    Public CRC_Low, CRC_High As Byte

    Public Sub CRC_16(ByVal Data As String, Length As Integer)
    CRC_Low = &HFF
    CRC_High = &HFF

    For i = 1 To Length
    Index = CRC_High Xor Asc(Mid(Data, i, 1))
    CRC_High = CRC_Low Xor CRCTable(Index)
    CRC_Low = CRCTable(Index + 256)
    Next i

    End Sub

    LOOKUP TABLE
    CRCTable(0) = &H0
    CRCTable(1) = &HC1
    CRCTable(2) = &H81
    CRCTable(3) = &H40
    CRCTable(4) = &H1
    CRCTable(5) = &HC0
    CRCTable(6) = &H80
    CRCTable(7) = &H41
    CRCTable(8) = &H1
    CRCTable(9) = &HC0
    CRCTable(10) = &H80
    CRCTable(11) = &H41
    CRCTable(12) = &H0
    CRCTable(13) = &HC1
    CRCTable(14) = &H81
    CRCTable(15) = &H40
    CRCTable(16) = &H1
    CRCTable(17) = &HC0
    CRCTable(18) = &H80
    CRCTable(19) = &H41
    CRCTable(20) = &H0
    CRCTable(21) = &HC1
    CRCTable(22) = &H81
    CRCTable(23) = &H40
    CRCTable(24) = &H0
    CRCTable(25) = &HC1
    CRCTable(26) = &H81
    CRCTable(27) = &H40
    CRCTable(28) = &H1
    CRCTable(29) = &HC0
    CRCTable(30) = &H80
    CRCTable(31) = &H41
    CRCTable(32) = &H1
    CRCTable(33) = &HC0
    CRCTable(34) = &H80
    CRCTable(35) = &H41
    CRCTable(36) = &H0
    CRCTable(37) = &HC1
    CRCTable(38) = &H81
    CRCTable(39) = &H40
    CRCTable(40) = &H0
    CRCTable(41) = &HC1
    CRCTable(42) = &H81
    CRCTable(43) = &H40
    CRCTable(44) = &H1
    CRCTable(45) = &HC0
    CRCTable(46) = &H80
    CRCTable(47) = &H41
    CRCTable(48) = &H0
    CRCTable(49) = &HC1
    CRCTable(50) = &H81
    CRCTable(51) = &H40
    CRCTable(52) = &H1
    CRCTable(53) = &HC0
    CRCTable(54) = &H80
    CRCTable(55) = &H41
    CRCTable(56) = &H1
    CRCTable(57) = &HC0
    CRCTable(58) = &H80
    CRCTable(59) = &H41
    CRCTable(60) = &H0
    CRCTable(61) = &HC1
    CRCTable(62) = &H81
    CRCTable(63) = &H40
    CRCTable(64) = &H1
    CRCTable(65) = &HC0
    CRCTable(66) = &H80
    CRCTable(67) = &H41
    CRCTable(68) = &H0
    CRCTable(69) = &HC1
    CRCTable(70) = &H81
    CRCTable(71) = &H40
    CRCTable(72) = &H0
    CRCTable(73) = &HC1
    CRCTable(74) = &H81
    CRCTable(75) = &H40
    CRCTable(76) = &H1
    CRCTable(77) = &HC0
    CRCTable(78) = &H80
    CRCTable(79) = &H41
    CRCTable(80) = &H0
    CRCTable(81) = &HC1
    CRCTable(82) = &H81
    CRCTable(83) = &H40
    CRCTable(84) = &H1
    CRCTable(85) = &HC0
    CRCTable(86) = &H80
    CRCTable(87) = &H41
    CRCTable(88) = &H1
    CRCTable(89) = &HC0
    CRCTable(90) = &H80
    CRCTable(91) = &H41
    CRCTable(92) = &H0
    CRCTable(93) = &HC1
    CRCTable(94) = &H81
    CRCTable(95) = &H40
    CRCTable(96) = &H0
    CRCTable(97) = &HC1
    CRCTable(98) = &H81
    CRCTable(99) = &H40
    CRCTable(100) = &H1
    CRCTable(101) = &HC0
    CRCTable(102) = &H80
    CRCTable(103) = &H41
    CRCTable(104) = &H1
    CRCTable(105) = &HC0
    CRCTable(106) = &H80
    CRCTable(107) = &H41
    CRCTable(108) = &H0
    CRCTable(109) = &HC1
    CRCTable(110) = &H81
    CRCTable(111) = &H40
    CRCTable(112) = &H1
    CRCTable(113) = &HC0
    CRCTable(114) = &H80
    CRCTable(115) = &H41
    CRCTable(116) = &H0
    CRCTable(117) = &HC1
    CRCTable(118) = &H81
    CRCTable(119) = &H40
    CRCTable(120) = &H0
    CRCTable(121) = &HC1
    CRCTable(122) = &H81
    CRCTable(123) = &H40
    CRCTable(124) = &H1
    CRCTable(125) = &HC0
    CRCTable(126) = &H80
    CRCTable(127) = &H41
    CRCTable(128) = &H1
    CRCTable(129) = &HC0
    CRCTable(130) = &H80
    CRCTable(131) = &H41
    CRCTable(132) = &H0
    CRCTable(133) = &HC1
    CRCTable(134) = &H81
    CRCTable(135) = &H40
    CRCTable(136) = &H0
    CRCTable(137) = &HC1
    CRCTable(138) = &H81
    CRCTable(139) = &H40
    CRCTable(140) = &H1
    CRCTable(141) = &HC0
    CRCTable(142) = &H80
    CRCTable(143) = &H41
    CRCTable(144) = &H0
    CRCTable(145) = &HC1
    CRCTable(146) = &H81
    CRCTable(147) = &H40
    CRCTable(148) = &H1
    CRCTable(149) = &HC0
    CRCTable(150) = &H80
    CRCTable(151) = &H41
    CRCTable(152) = &H1
    CRCTable(153) = &HC0
    CRCTable(154) = &H80
    CRCTable(155) = &H41
    CRCTable(156) = &H0
    CRCTable(157) = &HC1
    CRCTable(158) = &H81
    CRCTable(159) = &H40
    CRCTable(160) = &H0
    CRCTable(161) = &HC1
    CRCTable(162) = &H81
    CRCTable(163) = &H40
    CRCTable(164) = &H1
    CRCTable(165) = &HC0
    CRCTable(166) = &H80
    CRCTable(167) = &H41
    CRCTable(168) = &H1
    CRCTable(169) = &HC0
    CRCTable(170) = &H80
    CRCTable(171) = &H41
    CRCTable(172) = &H0
    CRCTable(173) = &HC1
    CRCTable(174) = &H81
    CRCTable(175) = &H40
    CRCTable(176) = &H1
    CRCTable(177) = &HC0
    CRCTable(178) = &H80
    CRCTable(179) = &H41
    CRCTable(180) = &H0
    CRCTable(181) = &HC1
    CRCTable(182) = &H81
    CRCTable(183) = &H40
    CRCTable(184) = &H0
    CRCTable(185) = &HC1
    CRCTable(186) = &H81
    CRCTable(187) = &H40
    CRCTable(188) = &H1
    CRCTable(189) = &HC0
    CRCTable(190) = &H80
    CRCTable(191) = &H41
    CRCTable(192) = &H0
    CRCTable(193) = &HC1
    CRCTable(194) = &H81
    CRCTable(195) = &H40
    CRCTable(196) = &H1
    CRCTable(197) = &HC0
    CRCTable(198) = &H80
    CRCTable(199) = &H41
    CRCTable(200) = &H1
    CRCTable(201) = &HC0
    CRCTable(202) = &H80
    CRCTable(203) = &H41
    CRCTable(204) = &H0
    CRCTable(205) = &HC1
    CRCTable(206) = &H81
    CRCTable(207) = &H40
    CRCTable(208) = &H1
    CRCTable(209) = &HC0
    CRCTable(210) = &H80
    CRCTable(211) = &H41
    CRCTable(212) = &H0
    CRCTable(213) = &HC1
    CRCTable(214) = &H81
    CRCTable(215) = &H40
    CRCTable(216) = &H0
    CRCTable(217) = &HC1
    CRCTable(218) = &H81
    CRCTable(219) = &H40
    CRCTable(220) = &H1
    CRCTable(221) = &HC0
    CRCTable(222) = &H80
    CRCTable(223) = &H41
    CRCTable(224) = &H1
    CRCTable(225) = &HC0
    CRCTable(226) = &H80
    CRCTable(227) = &H41
    CRCTable(228) = &H0
    CRCTable(229) = &HC1
    CRCTable(230) = &H81
    CRCTable(231) = &H40
    CRCTable(232) = &H0
    CRCTable(233) = &HC1
    CRCTable(234) = &H81
    CRCTable(235) = &H40
    CRCTable(236) = &H1
    CRCTable(237) = &HC0
    CRCTable(238) = &H80
    CRCTable(239) = &H41
    CRCTable(240) = &H0
    CRCTable(241) = &HC1
    CRCTable(242) = &H81
    CRCTable(243) = &H40
    CRCTable(244) = &H1
    CRCTable(245) = &HC0
    CRCTable(246) = &H80
    CRCTable(247) = &H41
    CRCTable(248) = &H1
    CRCTable(249) = &HC0
    CRCTable(250) = &H80
    CRCTable(251) = &H41
    CRCTable(252) = &H0
    CRCTable(253) = &HC1
    CRCTable(254) = &H81
    CRCTable(255) = &H40
    CRCTable(256) = &H0
    CRCTable(257) = &HC0
    CRCTable(258) = &HC1
    CRCTable(259) = &H1
    CRCTable(260) = &HC3
    CRCTable(261) = &H3
    CRCTable(262) = &H2
    CRCTable(263) = &HC2
    CRCTable(264) = &HC6
    CRCTable(265) = &H6
    CRCTable(266) = &H7
    CRCTable(267) = &HC7
    CRCTable(268) = &H5
    CRCTable(269) = &HC5
    CRCTable(270) = &HC4
    CRCTable(271) = &H4
    CRCTable(272) = &HCC
    CRCTable(273) = &HC
    CRCTable(274) = &HD
    CRCTable(275) = &HCD
    CRCTable(276) = &HF
    CRCTable(277) = &HCF
    CRCTable(278) = &HCE
    CRCTable(279) = &HE
    CRCTable(280) = &HA
    CRCTable(281) = &HCA
    CRCTable(282) = &HCB
    CRCTable(283) = &HB
    CRCTable(284) = &HC9
    CRCTable(285) = &H9
    CRCTable(286) = &H8
    CRCTable(287) = &HC8
    CRCTable(288) = &HD8
    CRCTable(289) = &H18
    CRCTable(290) = &H19
    CRCTable(291) = &HD9
    CRCTable(292) = &H1B
    CRCTable(293) = &HDB
    CRCTable(294) = &HDA
    CRCTable(295) = &H1A
    CRCTable(296) = &H1E
    CRCTable(297) = &HDE
    CRCTable(298) = &HDF
    CRCTable(299) = &H1F
    CRCTable(300) = &HDD
    CRCTable(301) = &H1D
    CRCTable(302) = &H1C
    CRCTable(303) = &HDC
    CRCTable(304) = &H14
    CRCTable(305) = &HD4
    CRCTable(306) = &HD5
    CRCTable(307) = &H15
    CRCTable(308) = &HD7
    CRCTable(309) = &H17
    CRCTable(310) = &H16
    CRCTable(311) = &HD6
    CRCTable(312) = &HD2
    CRCTable(313) = &H12
    CRCTable(314) = &H13
    CRCTable(315) = &HD3
    CRCTable(316) = &H11
    CRCTable(317) = &HD1
    CRCTable(318) = &HD0
    CRCTable(319) = &H10
    CRCTable(320) = &HF0
    CRCTable(321) = &H30
    CRCTable(322) = &H31
    CRCTable(323) = &HF1
    CRCTable(324) = &H33
    CRCTable(325) = &HF3
    CRCTable(326) = &HF2
    CRCTable(327) = &H32
    CRCTable(328) = &H36
    CRCTable(329) = &HF6
    CRCTable(330) = &HF7
    CRCTable(331) = &H37
    CRCTable(332) = &HF5
    CRCTable(333) = &H35
    CRCTable(334) = &H34
    CRCTable(335) = &HF4
    CRCTable(336) = &H3C
    CRCTable(337) = &HFC
    CRCTable(338) = &HFD
    CRCTable(339) = &H3D
    CRCTable(340) = &HFF
    CRCTable(341) = &H3F
    CRCTable(342) = &H3E
    CRCTable(343) = &HFE
    CRCTable(344) = &HFA
    CRCTable(345) = &H3A
    CRCTable(346) = &H3B
    CRCTable(347) = &HFB
    CRCTable(348) = &H39
    CRCTable(349) = &HF9
    CRCTable(350) = &HF8
    CRCTable(351) = &H38
    CRCTable(352) = &H28
    CRCTable(353) = &HE8
    CRCTable(354) = &HE9
    CRCTable(355) = &H29
    CRCTable(356) = &HEB
    CRCTable(357) = &H2B
    CRCTable(358) = &H2A
    CRCTable(359) = &HEA
    CRCTable(360) = &HEE
    CRCTable(361) = &H2E
    CRCTable(362) = &H2F
    CRCTable(363) = &HEF
    CRCTable(364) = &H2D
    CRCTable(365) = &HED
    CRCTable(366) = &HEC
    CRCTable(367) = &H2C
    CRCTable(368) = &HE4
    CRCTable(369) = &H24
    CRCTable(370) = &H25
    CRCTable(371) = &HE5
    CRCTable(372) = &H27
    CRCTable(373) = &HE7
    CRCTable(374) = &HE6
    CRCTable(375) = &H26
    CRCTable(376) = &H22
    CRCTable(377) = &HE2
    CRCTable(378) = &HE3
    CRCTable(379) = &H23
    CRCTable(380) = &HE1
    CRCTable(381) = &H21
    CRCTable(382) = &H20
    CRCTable(383) = &HE0
    CRCTable(384) = &HA0
    CRCTable(385) = &H60
    CRCTable(386) = &H61
    CRCTable(387) = &HA1
    CRCTable(388) = &H63
    CRCTable(389) = &HA3
    CRCTable(390) = &HA2
    CRCTable(391) = &H62
    CRCTable(392) = &H66
    CRCTable(393) = &HA6
    CRCTable(394) = &HA7
    CRCTable(395) = &H67
    CRCTable(396) = &HA5
    CRCTable(397) = &H65
    CRCTable(398) = &H64
    CRCTable(399) = &HA4
    CRCTable(400) = &H6C
    CRCTable(401) = &HAC
    CRCTable(402) = &HAD
    CRCTable(403) = &H6D
    CRCTable(404) = &HAF
    CRCTable(405) = &H6F
    CRCTable(406) = &H6E
    CRCTable(407) = &HAE
    CRCTable(408) = &HAA
    CRCTable(409) = &H6A
    CRCTable(410) = &H6B
    CRCTable(411) = &HAB
    CRCTable(412) = &H69
    CRCTable(413) = &HA9
    CRCTable(414) = &HA8
    CRCTable(415) = &H68
    CRCTable(416) = &H78
    CRCTable(417) = &HB8
    CRCTable(418) = &HB9
    CRCTable(419) = &H79
    CRCTable(420) = &HBB
    CRCTable(421) = &H7B
    CRCTable(422) = &H7A
    CRCTable(423) = &HBA
    CRCTable(424) = &HBE
    CRCTable(425) = &H7E
    CRCTable(426) = &H7F
    CRCTable(427) = &HBF
    CRCTable(428) = &H7D
    CRCTable(429) = &HBD
    CRCTable(430) = &HBC
    CRCTable(431) = &H7C
    CRCTable(432) = &HB4
    CRCTable(433) = &H74
    CRCTable(434) = &H75
    CRCTable(435) = &HB5
    CRCTable(436) = &H77
    CRCTable(437) = &HB7
    CRCTable(438) = &HB6
    CRCTable(439) = &H76
    CRCTable(440) = &H72
    CRCTable(441) = &HB2
    CRCTable(442) = &HB3
    CRCTable(443) = &H73
    CRCTable(444) = &HB1
    CRCTable(445) = &H71
    CRCTable(446) = &H70
    CRCTable(447) = &HB0
    CRCTable(448) = &H50
    CRCTable(449) = &H90
    CRCTable(450) = &H91
    CRCTable(451) = &H51
    CRCTable(452) = &H93
    CRCTable(453) = &H53
    CRCTable(454) = &H52
    CRCTable(455) = &H92
    CRCTable(456) = &H96
    CRCTable(457) = &H56
    CRCTable(458) = &H57
    CRCTable(459) = &H97
    CRCTable(460) = &H55
    CRCTable(461) = &H95
    CRCTable(462) = &H94
    CRCTable(463) = &H54
    CRCTable(464) = &H9C
    CRCTable(465) = &H5C
    CRCTable(466) = &H5D
    CRCTable(467) = &H9D
    CRCTable(468) = &H5F
    CRCTable(469) = &H9F
    CRCTable(470) = &H9E
    CRCTable(471) = &H5E
    CRCTable(472) = &H5A
    CRCTable(473) = &H9A
    CRCTable(474) = &H9B
    CRCTable(475) = &H5B
    CRCTable(476) = &H99
    CRCTable(477) = &H59
    CRCTable(478) = &H58
    CRCTable(479) = &H98
    CRCTable(480) = &H88
    CRCTable(481) = &H48
    CRCTable(482) = &H49
    CRCTable(483) = &H89
    CRCTable(484) = &H4B
    CRCTable(485) = &H8B
    CRCTable(486) = &H8A
    CRCTable(487) = &H4A
    CRCTable(488) = &H4E
    CRCTable(489) = &H8E
    CRCTable(490) = &H8F
    CRCTable(491) = &H4F
    CRCTable(492) = &H8D
    CRCTable(493) = &H4D
    CRCTable(494) = &H4C
    CRCTable(495) = &H8C
    CRCTable(496) = &H44
    CRCTable(497) = &H84
    CRCTable(498) = &H85
    CRCTable(499) = &H45
    CRCTable(500) = &H87
    CRCTable(501) = &H47
    CRCTable(502) = &H46
    CRCTable(503) = &H86
    CRCTable(504) = &H82
    CRCTable(505) = &H42
    CRCTable(506) = &H43
    CRCTable(507) = &H83
    CRCTable(508) = &H41
    CRCTable(509) = &H81
    CRCTable(510) = &H80
    CRCTable(511) = &H40

    *********************************************
    espero te sirva

  4. #4

    Default Re: CHECKSUM CALCULATION, Please Help!

    Interesting methof of doing CRC, but completely unrelated to the original question.

  5. #5

    Default Re: CHECKSUM CALCULATION, Please Help!

    Take the ASCII value, subtract 0x30, if results is >9 then subtract 0x07. Value should then be in hex. If you want to bounds check then test result to make sure it is >= 0 and < 0x10. Then take the first packet hex value and leftshift by 4 and then add to hex value of second packet. Bitwise AND your calculated checksum with 0xFF and compare with the transmitted checksum.
    Tim Barr

  6. #6
    Join Date
    Jun 2010
    Location
    Venezuela
    Posts
    11

    Default Re: CHECKSUM CALCULATION, Please Help!

    hi wasilus, tanks for you answer, these are examples used to calculate CRC16.

    try this:

    1.- $50 + $31 + $32 + $33 + $34 = $11A

    2.- $11A / $100 = $1

    3.- the carry = A

    4.- Your checksum = 1A

  7. #7
    Join Date
    Feb 2012
    Posts
    5

    Default Re: CHECKSUM CALCULATION, Please Help!

    Hello guys, I have a similar problem

    I use a pic to capture data from the rs232 PC port, the data comes in packets,
    for example I get (ASCII characters): $P;22;00000;02;0;000530257;191 where 191 is the checksum


    The software that sends the data packets calculates the checksum as follow:

    chk=0;
    for(i=0;i <= 26;i++)
    {
    chk^=Buffer[i];
    }
    chk^=0xFF;


    My question is, how can I calculate the checksum with pibasic?

    Can anyone please help me to solve this problem?

    Here's some additional sample data to try:
    $P;01;00009;28;4;000474522;191
    $P;22;00000;00;0;000015245;188


    Thank you,
    Nick

  8. #8
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    991

    Default Re: CHECKSUM CALCULATION, Please Help!

    Everyone complains C is so hard, yet the code you posted is identical to BASIC with slightly different syntax.

    Code:
    chk = 0
    FOR i = 0 TO 26
    chk = chk ^ Buffer[i]
    NEXT i
    chk = chk ^ $FF

  9. #9
    Join Date
    Feb 2012
    Posts
    5

    Default Re: CHECKSUM CALCULATION, Please Help!

    You are right!
    I make a small test and its working:

    i var byte
    chk var byte
    Buffer var byte

    chk = 0
    FOR i = 0 TO 26
    lookup i, ["$P;22;00000;02;0;000530257;"],Buffer
    chk = chk ^ Buffer
    NEXT i

    chk = chk ^ $FF

    hserout ["Checksum=",#chk]


    Thank you very much for your help,
    Nick

  10. #10
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    991

    Default Re: CHECKSUM CALCULATION, Please Help!

    No problem. Still I’d love for someone to explain the difficulty.

    Code:
    const unsigned char Buffer[27] = {
    0x24, 0x50, 0x3B, 0x32, 0x32 0x3B, 0x30, 0x30, 0x30,
    0x30, 0x30, 0x3B, 0x30, 0x32 0x3B, 0x30, 0x3B, 0x30,
    0x30, 0x30, 0x35, 0x33, 0x30 0x32, 0x35, 0x37, 0x3B
    };
    
    unsigned char chk = 0;
    unsigned char i = 0;
    
    for(i=0;i <= 26;i++) { 
    chk^=Buffer[i]; 
    } 
    chk^=0xFF;

  11. #11
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    252

    Default Re: CHECKSUM CALCULATION, Please Help!

    Art, different "languages" require a different way of thinking. As a native English speaker, Spanish (and a few other popular world languages) require me to reverse the order between nouns and verbs (and other grammatical objects). Going from English to Chinese requires me to become aware of the importance of voice inflections, in addition to other differences. The written language I'm familiar with is phonetic, while Chinese is symbolic; again, a different way of thinking.

    Moving from Basic to ASM to C requires a total revamping of how the programmer THINKS. The 3 different common PIC programming languages "flow" within their method of getting things done. Someone capable of working miracles in ASM might have a tough time with PBP or even C. Someone fluent in C might have difficulty learning the different approach to doing anything in PBP or ASM. The 3 are really radically different, with different methodologies.

    With that said, this is a PBP forum with tolerance for ASM (and to a lesser degree, C). For someone like you that has a good fluency in PBP and C (and perhaps even ASM for that matter), your brain works like that of a Chinese translator, virtually automatically seeing the C and the PPB and the ASM versions almost as one and the same.

  12. #12
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    991

    Default Re: CHECKSUM CALCULATION, Please Help!

    No, it doesn’t, not even the slightest little bit.

    Any BASIC program can be written directly into C, with the same structure, and exactly the same program flow.
    C is much more flexible, so it just may not work the other way round if the program was originally C.

  13. #13
    Join Date
    Feb 2012
    Posts
    5

    Default Re: CHECKSUM CALCULATION, Please Help!

    I agree with mpgmike. For me the C, require a different way of thinking.

    And in case of my issue, the code:

    chk=0;
    for(i=0;i <= 26;i++)
    {
    chk^=Buffer[i];
    }
    chk^=0xFF;

    comes from the manual of the software that I use and I did not understand it.


    Nick

Members who have read this thread : 24

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts