MPASM 02.20 Released CKSUM.ASM 2-20-1999 11:57:44 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;CKSUM.ASM FEB-15-99 00002 ;Routine to calculate the checksum of instruction memory 00003 ; by Loren Blaney 00004 ; 00005 ;Assemble with MPASM 00006 ; 00007 INCLUDE "SXDEFS.INC" ;macro definitions for new instructions 00146 LIST 00147 PROCESSOR 16C57 ; "SX28AC" 00339 LIST 1010 008B 00340 DATA _FUSE ;configuration bits (TURBO, SYNC, OPTIONX, etc.) 1011 04FE 00341 DATA _FUSEX ; (PINS, CARRYX, BOR40, BANKS, PAGES) 00345 LIST 0040EF00 00008 DEVICE EQU PINS28+TURBO+SYNC+OPTIONX+STACKX+BANKS8+PAGES4 00009 00010 0010 00011 ORG 10h 0010 00012 POINTER RES 2 ;pointer to words in instruction memory 0012 00013 SUM RES 1 ;accumulator for checksum 00014 00015 0000 00016 ORG 0 0000 0903 00017 START CALL CKSUM ;calculate checksum of ROM 0001 0003 00018 SLEEP ;stop 0002 0A00 00019 GOTO START ;loop forever 00020 00021 ;---------------------------------------------------------------------- 00022 0003 0070 00023 CKSUM CLRF POINTER ;initialize pointer to ROM 0004 0071 00024 CLRF POINTER+1 0005 0072 00025 CLRF SUM ;initialize checksum 00026 0006 0211 00027 CKSUM10 MOVF POINTER+1,W ;move POINTER into MODE:W 00028 MOVWM ; copy low 4 bits in W into MODE 0007 0043 M DATA 43h ;MOVWM ;move W register to MODE register 0008 0210 00029 MOVF POINTER,W ; copy low 8 bits of POINTER into W 00030 IREAD ;move instr at (MODE:W) to MODE:W 0009 0041 M DATA 41h ;IREAD ;move instruction at (MODE:W) to MODE:W 000A 01F2 00031 ADDWF SUM,F ;add in low 8 bits 00032 MOVMW ;copy MODE to W 000B 0042 M DATA 42h ;MOVMW ;move MODE register to W register 000C 01F2 00033 ADDWF SUM,F ;add in high 4 bits 00034 000D 03F0 00035 INCFSZ POINTER,F ;loop for all of ROM (000-7FFh) 000E 0A06 00036 GOTO CKSUM10 000F 02B1 00037 INCF POINTER+1,F 0010 0771 00038 BTFSS POINTER+1,3 ;does pointer = 800h ? 0011 0A06 00039 GOTO CKSUM10 ;loop if not 00040 0012 0212 00041 MOVF SUM,W ;return with checksum in W register 00042 RET 0013 000C M DATA 0Ch ;RET ;return without destroying W register 00043 MPASM 02.20 Released CKSUM.ASM 2-20-1999 11:57:44 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00044 07FE 00045 ORG 07FEh ;reset vector 07FE 008F 00046 DATA 8Fh ;make cksum = 0 Message[306]: Crossing page boundary -- ensure page bits are set. 07FF 0A00 00047 GOTO START 00048 00049 END MPASM 02.20 Released CKSUM.ASM 2-20-1999 11:57:44 PAGE 3 SYMBOL TABLE LABEL VALUE BANKA BANKS1 00000000 BANKS2 00004000 BANKS4 00008000 BANKS8 0000C000 BANKX BOR13 00010000 BOR25 00020000 BOR40 00030000 C 00000000 CARRYX 00040000 CKSUM 00000003 CKSUM10 00000006 CMP 00000008 CSA CSA# CSAE CSAE# CSB CSB# CSBE CSBE# DC 00000001 DEVICE 0040EF00 FCALL FGOTO FSR 00000004 ID IND 00000000 INPUTX IREAD LVL 0000000D MODE MOVMW MOVWM OPTIONX 00000200 OSC125KHZ 000000D0 OSC1MHZ 000000A0 OSC250KHZ 000000C0 OSC2MHZ 00000090 OSC31KHZ 000000F0 OSC4MHZ 00000080 OSC500KHZ 000000B0 OSC62KHZ 000000E0 OSCHS 00000001 OSCLP 00000003 OSCRC 00000000 OSCXT 00000002 OUTPUTX PA0 00000005 PA1 00000006 PA2 00000007 PAGEA MPASM 02.20 Released CKSUM.ASM 2-20-1999 11:57:44 PAGE 4 SYMBOL TABLE LABEL VALUE PAGES1 00000000 PAGES2 00001000 PAGES4 00002000 PAGES8 00003000 PAGEX PC 00000002 PD 00000003 PINS18 00000000 PINS28 00400000 PLP 0000000E POINTER 00000010 PRE7 00080000 PRINTX PROTECT 00000008 RA 00000005 RB 00000006 RC 00000007 RET RETI RETIW RETP RTCC 00000001 SKIP ST 0000000C STACKX 00000100 START 00000000 STATUS 00000003 SUM 00000012 SYNC 00000400 TO 00000004 TRIM0 00000000 TRIM12 00800000 TRIM15 00900000 TRIM18 00A00000 TRIM21 00B00000 TRIM3 00100000 TRIM6 00200000 TRIM9 00300000 TRISX 0000000F TURBO 00000800 WATCHDOG 00000004 WKED 0000000A WKEN 0000000B WKPND 00000009 Z 00000002 _DEVICE 004FE08B _FUSE 0000008B _FUSEX 000004FE _INVERT 000F0F8B _PINS 00000001 _ROM 00000002 __16C57 00000001 MPASM 02.20 Released CKSUM.ASM 2-20-1999 11:57:44 PAGE 5 MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XXXXXXXXXXXXXXXX XXXX------------ ---------------- ---------------- 07C0 : ---------------- ---------------- ---------------- --------------XX 1000 : ---------------- XX-------------- ---------------- ---------------- All other memory blocks unused. Program Memory Words Used: 22 Program Memory Words Free: 2026 Errors : 0 Warnings : 0 reported, 3 suppressed Messages : 1 reported, 0 suppressed