Hot!Disassembler / Decompiler

Page: 1234 > Showing page 1 of 4
Author
John Mayer
New Member
  • Total Posts : 8
  • Reward points : 0
  • Joined: 2018/05/21 17:30:01
  • Location: Portland, Oregon
  • Status: offline
2018/05/24 18:40:45 (permalink)
5 (1)

Disassembler / Decompiler

Hello Microchip Community!
I'm a total newbie here, so please forgive any dumb questions.
 
So here's the gist: I've managed to pull some 1's and 0's off of a PIC18F2480. I'm wondering if I can decipher what it means without going through line by line and converting machine code to assembly language and trying to make sense of it. I think what I'm asking for is some kind of disassembler and/or decompiler or other software reverse-engineering tool.
 
So here's the background that goes with this question:
My name is John Mayer; I'm the owner of Cuttlefish Auto Clinic in Portland, Oregon. I am one of only a few people in the US that works on an obscure brand of electric vehicle called Think City, a Swedish brand.
Unfortunately, the manufacturer is out of business, and I can't find any documentation for the car's control modules, and there are some problems that I would like to correct. Specifically, the .hex file that I've attached is from a PTC (positive temperature coefficient) heater module (the car's cabin heater); I pulled it from the circuit board using a PIC kit 3. The heater doesn't know to turn off immediately when the car is turned off, so if the car's ignition is cycled off and back on within a few seconds, the high current draw from the heater causes a precharge resistor in the traction battery's management system to catch on fire. I would like to update the code to fix that.
 
There are a few other control modules that also use PIC chips, but not specifically this same one. I would like to document the code for all of them, and be able to find other bugs that might show up in the future.
 
I'm mostly a mechanic, so I might be a little out of my league here, but I do have some experience with electronics, and I have taken some programming classes including one in C++, so at least I have some idea what headers and makefiles are.
 
I also made up a schematic of the circuit board that this PIC was mounted on so I have some idea of which pins do what, too.
Thanks in advance!
 
Oh, also, if you're curious you can learn more about Thinks at thinkcitypdx.com and cuttlefishauto.com.
#1

61 Replies Related Threads

    David
    Super Member
    • Total Posts : 1277
    • Reward points : 0
    • Joined: 2007/12/17 23:19:53
    • Location: uk sussex
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/25 17:47:42 (permalink)
    0
    just a thought have you programmed same code into another pic chip and does it still work ?

    David
    I support http://picforum.ric323.com because this forum is often too broken to use!
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 16282
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Disassembler / Decompiler 2018/05/25 18:27:47 (permalink)
    0
    If you read the data from the chip and import it in to MPLab it will display the code in pic ASM. But pic ASM is far from C++
    #3
    Mysil
    Super Member
    • Total Posts : 2880
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 04:13:04 (permalink)
    0
    Hi,
    As far as I can recall, Think City was designed in Norway by a Norwegian company, and produced in  Finland by Valmet Automotive in Uusikaupunki.
    Saab-Valmet was once upon a time founded by Valmet, a Finnish company and Saab which was a Swedish company.
     
       Mysil
    #4
    JorgeF
    Super Member
    • Total Posts : 3281
    • Reward points : 0
    • Joined: 2011/07/09 11:56:58
    • Location: PT/EU @ Third rock from the Sun
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 13:10:58 (permalink)
    0
    Hi
     
    In terms of reading/correcting a disassembled PIC program, you can throw out the desktop based C++ specific experience.
    Use the algorithmic and basic programming structure and forgett the remaining.
    In the PIC you don't have the massive frameworks available for desktop programming, you also don't have an operating system to provide for all the low-level support.
    Here you are divinbg to the bare metal, and building from there on.
     
    That said, I've took a quick look at the disassembly of the hex file you provided and it was surprisingly clear.
    I would say the program was probably written in assembly and not in 'C', its missing the twisted code of an optimizing compiler and the redundant gotos and alike so common in non optimized compiled code.
    What is not surprising as its a small program, about 1K in size, on a simple PIC.
     
    A simple interrupt service, seems to be a basic timming system built around Timer0, at first site sight it looks like interrupts priorities are not in use (PIC16 compatible mode).
    A handfull of subroutines.
    A number of easi to identify state machines and what seems to be, at least one, lookup table.
    And also a number of bit manipulations in sequence directly to the PORT registers, the original programmer was not too warried with the R-M-W risk.
     
    All in all its not a very complex exercise, but a hard time for someone without microcontrollers and ASM experience.
     
     
    Best regards
    Jorge
     
     EDIT: Typo
      
    post edited by JorgeF - 2018/05/26 15:44:13
    #5
    David
    Super Member
    • Total Posts : 1277
    • Reward points : 0
    • Joined: 2007/12/17 23:19:53
    • Location: uk sussex
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 14:09:53 (permalink)
    +1 (1)
    i got this
         Line Address Opcode Label DisAssy 
           1 0000 EFF0 GOTO 0x7E0
           2 0002 F003 NOP
           3 0004 FFFF NOP
           4 0006 FFFF NOP
           5 0008 CFD8 MOVFF STATUS, 0x0
           6 000A F000 NOP
           7 000C CFE0 MOVFF BSR, 0x1
           8 000E F001 NOP
           9 0010 6E02 MOVWF 0x2, ACCESS
          10 0012 A4F2 BTFSS INTCON, 2, ACCESS
          11 0014 D004 BRA 0x1E
          12 0016 2A24 INCF 0x24, F, ACCESS
          13 0018 0E4E MOVLW 0x4E
          14 001A 5ED6 SUBWF TMR0, F, ACCESS
          15 001C 94F2 BCF INTCON, 2, ACCESS
          16 001E 5002 MOVF 0x2, W, ACCESS
          17 0020 C001 MOVFF 0x1, BSR
          18 0022 FFE0 NOP
          19 0024 C000 MOVFF 0x0, STATUS
          20 0026 FFD8 NOP
          21 0028 0010 RETFIE 0
          22 002A 6E7F MOVWF 0xF7F, ACCESS
          23 002C B2A6 BTFSC EECON1, 1, ACCESS
          24 002E D7FE BRA 0x2C
          25 0030 CF7F MOVFF 0xF7F, EEADR
          26 0032 FFA9 NOP
          27 0034 CF7F MOVFF 0xF7F, EEDATA
          28 0036 FFA8 NOP
          29 0038 9EA6 BCF EECON1, 7, ACCESS
          30 003A 9CA6 BCF EECON1, 6, ACCESS
          31 003C AEF2 BTFSS INTCON, 7, ACCESS
          32 003E 907F BCF 0xF7F, 0, ACCESS
          33 0040 BEF2 BTFSC INTCON, 7, ACCESS
          34 0042 807F BSF 0xF7F, 0, ACCESS
          35 0044 9EF2 BCF INTCON, 7, ACCESS
          36 0046 84A6 BSF EECON1, 2, ACCESS
          37 0048 0E55 MOVLW 0x55
          38 004A 6EA7 MOVWF EECON2, ACCESS
          39 004C 0EAA MOVLW 0xAA
          40 004E 6EA7 MOVWF EECON2, ACCESS
          41 0050 82A6 BSF EECON1, 1, ACCESS
          42 0052 94A6 BCF EECON1, 2, ACCESS
          43 0054 A07F BTFSS 0xF7F, 0, ACCESS
          44 0056 9EF2 BCF INTCON, 7, ACCESS
          45 0058 B07F BTFSC 0xF7F, 0, ACCESS
          46 005A 8EF2 BSF INTCON, 7, ACCESS
          47 005C 0012 RETURN 0
          48 005E 6E7F MOVWF 0xF7F, ACCESS
          49 0060 507F MOVF 0xF7F, W, ACCESS
          50 0062 E00B BZ 0x7A
          51 0064 CF7F MOVFF 0xF7F, 0xF7F
          52 0066 FF7F NOP
          53 0068 CF7F MOVFF 0xF7F, FSR0
          54 006A FFE9 NOP
          55 006C 6AEA CLRF FSR0H, ACCESS
          56 006E 50EF MOVF INDF0, W, ACCESS
          57 0070 DFDC RCALL 0x2A
          58 0072 2A7F INCF 0xF7F, F, ACCESS
          59 0074 2A7F INCF 0xF7F, F, ACCESS
          60 0076 067F DECF 0xF7F, F, ACCESS
          61 0078 D7F3 BRA 0x60
          62 007A 0012 RETURN 0
          63 007C 6E7F MOVWF 0xF7F, ACCESS
          64 007E CF7F MOVFF 0xF7F, EEADR
          65 0080 FFA9 NOP
          66 0082 9EA6 BCF EECON1, 7, ACCESS
          67 0084 9CA6 BCF EECON1, 6, ACCESS
          68 0086 80A6 BSF EECON1, 0, ACCESS
          69 0088 50A8 MOVF EEDATA, W, ACCESS
          70 008A 0012 RETURN 0
          71 008C 6E7F MOVWF 0xF7F, ACCESS
          72 008E 507F MOVF 0xF7F, W, ACCESS
          73 0090 E00C BZ 0xAA
          74 0092 507F MOVF 0xF7F, W, ACCESS
          75 0094 DFF3 RCALL 0x7C
          76 0096 6E7F MOVWF 0xF7F, ACCESS
          77 0098 CF7F MOVFF 0xF7F, FSR0
          78 009A FFE9 NOP
          79 009C 6AEA CLRF FSR0H, ACCESS
          80 009E CF7F MOVFF 0xF7F, INDF0
          81 00A0 FFEF NOP
          82 00A2 2A7F INCF 0xF7F, F, ACCESS
          83 00A4 2A7F INCF 0xF7F, F, ACCESS
          84 00A6 067F DECF 0xF7F, F, ACCESS
          85 00A8 D7F2 BRA 0x8E
          86 00AA 0012 RETURN 0
          87 00AC 0EC7 MOVLW 0xC7
          88 00AE 6ED5 MOVWF T0CON, ACCESS
          89 00B0 6AD6 CLRF TMR0, ACCESS
          90 00B2 0E4E MOVLW 0x4E
          91 00B4 5ED6 SUBWF TMR0, F, ACCESS
          92 00B6 94F2 BCF INTCON, 2, ACCESS
          93 00B8 8AF2 BSF INTCON, 5, ACCESS
          94 00BA 0E32 MOVLW 0x32
          95 00BC 6E1A MOVWF 0x1A, ACCESS
          96 00BE 8219 BSF 0x19, 1, ACCESS
          97 00C0 0012 RETURN 0
          98 00C2 0EC7 MOVLW 0xC7
          99 00C4 6ED5 MOVWF T0CON, ACCESS
         100 00C6 8AF2 BSF INTCON, 5, ACCESS
         101 00C8 5224 MOVF 0x24, F, ACCESS
         102 00CA E013 BZ 0xF2
         103 00CC 0E0A MOVLW 0xA
         104 00CE 6E03 MOVWF 0x3, ACCESS
         105 00D0 EE00 LFSR 0, 0x1A
         106 00D2 F01A NOP
         107 00D4 50EF MOVF INDF0, W, ACCESS
         108 00D6 A4D8 BTFSS STATUS, 2, ACCESS
         109 00D8 06EF DECF INDF0, F, ACCESS
         110 00DA 50EE MOVF POSTINC0, W, ACCESS
         111 00DC 2E03 DECFSZ 0x3, F, ACCESS
         112 00DE D7FA BRA 0xD4
         113 00E0 661A TSTFSZ 0x1A, ACCESS
         114 00E2 D004 BRA 0xEC
         115 00E4 0E64 MOVLW 0x64
         116 00E6 6E1A MOVWF 0x1A, ACCESS
         117 00E8 8019 BSF 0x19, 0, ACCESS
         118 00EA 9219 BCF 0x19, 1, ACCESS
         119 00EC 2E24 DECFSZ 0x24, F, ACCESS
         120 00EE D7EE BRA 0xCC
         121 00F0 D001 BRA 0xF4
         122 00F2 9019 BCF 0x19, 0, ACCESS
         123 00F4 0012 RETURN 0
         124 00F6 CF7F MOVFF 0xF7F, FSR0
         125 00F8 FFE9 NOP
         126 00FA 6AEA CLRF FSR0H, ACCESS
         127 00FC CF7F MOVFF 0xF7F, FSR1
         128 00FE FFE1 NOP
         129 0100 6AE2 CLRF FSR1H, ACCESS
         130 0102 50EF MOVF INDF0, W, ACCESS
         131 0104 E00B BZ 0x11C
         132 0106 50EF MOVF INDF0, W, ACCESS
         133 0108 60E7 CPFSLT INDF1, ACCESS
         134 010A D003 BRA 0x112
         135 010C 0E01 MOVLW 0x1
         136 010E 6E7F MOVWF 0xF7F, ACCESS
         137 0110 0C01 RETLW 0x1
         138 0112 50E6 MOVF POSTINC1, W, ACCESS
         139 0114 60EE CPFSLT POSTINC0, ACCESS
         140 0116 D7F5 BRA 0x102
         141 0118 687F SETF 0xF7F, ACCESS
         142 011A 0CFF RETLW 0xFF
         143 011C 6A7F CLRF 0xF7F, ACCESS
         144 011E 0C00 RETLW 0x0
         145 0120 6E7F MOVWF 0xF7F, ACCESS
         146 0122 CF7F MOVFF 0xF7F, FSR0
         147 0124 FFE9 NOP
         148 0126 6AEA CLRF FSR0H, ACCESS
         149 0128 CF7F MOVFF 0xF7F, FSR1
         150 012A FFE1 NOP
         151 012C 6AE2 CLRF FSR1H, ACCESS
         152 012E 507F MOVF 0xF7F, W, ACCESS
         153 0130 E00D BZ 0x14C
         154 0132 50EF MOVF INDF0, W, ACCESS
         155 0134 60E7 CPFSLT INDF1, ACCESS
         156 0136 D003 BRA 0x13E
         157 0138 0E01 MOVLW 0x1
         158 013A 6E7F MOVWF 0xF7F, ACCESS
         159 013C 0C01 RETLW 0x1
         160 013E 50E6 MOVF POSTINC1, W, ACCESS
         161 0140 60EE CPFSLT POSTINC0, ACCESS
         162 0142 D002 BRA 0x148
         163 0144 687F SETF 0xF7F, ACCESS
         164 0146 0CFF RETLW 0xFF
         165 0148 067F DECF 0xF7F, F, ACCESS
         166 014A D7F1 BRA 0x12E
         167 014C 6A7F CLRF 0xF7F, ACCESS
         168 014E 0C00 RETLW 0x0
         169 0150 0E03 MOVLW 0x3
         170 0152 640A CPFSGT 0xA, ACCESS
         171 0154 D002 BRA 0x15A
         172 0156 6809 SETF 0x9, ACCESS
         173 0158 6E0A MOVWF 0xA, ACCESS
         174 015A 5009 MOVF 0x9, W, ACCESS
         175 015C 6E15 MOVWF 0x15, ACCESS
         176 015E 500A MOVF 0xA, W, ACCESS
         177 0160 6E18 MOVWF 0x18, ACCESS
         178 0162 0E06 MOVLW 0x6
         179 0164 6E17 MOVWF 0x17, ACCESS
         180 0166 3218 RRCF 0x18, F, ACCESS
         181 0168 3215 RRCF 0x15, F, ACCESS
         182 016A 2E17 DECFSZ 0x17, F, ACCESS
         183 016C D7FC BRA 0x166
         184 016E 0E3F MOVLW 0x3F
         185 0170 1409 ANDWF 0x9, W, ACCESS
         186 0172 6E16 MOVWF 0x16, ACCESS
         187 0174 90D8 BCF STATUS, 0, ACCESS
         188 0176 3415 RLCF 0x15, W, ACCESS
         189 0178 240B ADDWF 0xB, W, ACCESS
         190 017A DB43 RCALL 0x802
         191 017C 6E0C MOVWF 0xC, ACCESS
         192 017E 000B TBLRD+*
         193 0180 50F5 MOVF TABLAT, W, ACCESS
         194 0182 6E0D MOVWF 0xD, ACCESS
         195 0184 90D8 BCF STATUS, 0, ACCESS
         196 0186 3415 RLCF 0x15, W, ACCESS
         197 0188 0F02 ADDLW 0x2
         198 018A 240B ADDWF 0xB, W, ACCESS
         199 018C DB3A RCALL 0x802
         200 018E 6E0E MOVWF 0xE, ACCESS
         201 0190 000B TBLRD+*
         202 0192 50F5 MOVF TABLAT, W, ACCESS
         203 0194 6E0F MOVWF 0xF, ACCESS
         204 0196 500C MOVF 0xC, W, ACCESS
         205 0198 5C0E SUBWF 0xE, W, ACCESS
         206 019A 6E10 MOVWF 0x10, ACCESS
         207 019C 500D MOVF 0xD, W, ACCESS
         208 019E 580F SUBWFB 0xF, W, ACCESS
         209 01A0 6E11 MOVWF 0x11, ACCESS
         210 01A2 5016 MOVF 0x16, W, ACCESS
         211 01A4 0210 MULWF 0x10, ACCESS
         212 01A6 CFF3 MOVFF PROD, 0x12
         213 01A8 F012 NOP
         214 01AA CFF4 MOVFF PRODH, 0x13
         215 01AC F013 NOP
         216 01AE 6A14 CLRF 0x14, ACCESS
         217 01B0 0211 MULWF 0x11, ACCESS
         218 01B2 50F3 MOVF PROD, W, ACCESS
         219 01B4 2613 ADDWF 0x13, F, ACCESS
         220 01B6 50F4 MOVF PRODH, W, ACCESS
         221 01B8 2214 ADDWFC 0x14, F, ACCESS
         222 01BA AE11 BTFSS 0x11, 7, ACCESS
         223 01BC D002 BRA 0x1C2
         224 01BE 5016 MOVF 0x16, W, ACCESS
         225 01C0 5E14 SUBWF 0x14, F, ACCESS
         226 01C2 0E06 MOVLW 0x6
         227 01C4 6E17 MOVWF 0x17, ACCESS
         228 01C6 3414 RLCF 0x14, W, ACCESS
         229 01C8 3214 RRCF 0x14, F, ACCESS
         230 01CA 3213 RRCF 0x13, F, ACCESS
         231 01CC 3212 RRCF 0x12, F, ACCESS
         232 01CE 2E17 DECFSZ 0x17, F, ACCESS
         233 01D0 D7FA BRA 0x1C6
         234 01D2 5012 MOVF 0x12, W, ACCESS
         235 01D4 260C ADDWF 0xC, F, ACCESS
         236 01D6 5013 MOVF 0x13, W, ACCESS
         237 01D8 220D ADDWFC 0xD, F, ACCESS
         238 01DA 500C MOVF 0xC, W, ACCESS
         239 01DC 0012 RETURN 0
         240 01DE 6E0A MOVWF 0xA, ACCESS
         241 01E0 C007 MOVFF 0x7, FSR0
         242 01E2 FFE9 NOP
         243 01E4 6AEA CLRF FSR0H, ACCESS
         244 01E6 5008 MOVF 0x8, W, ACCESS
         245 01E8 5CEE SUBWF POSTINC0, W, ACCESS
         246 01EA 6E0B MOVWF 0xB, ACCESS
         247 01EC 5009 MOVF 0x9, W, ACCESS
         248 01EE 58EF SUBWFB INDF0, W, ACCESS
         249 01F0 6E0C MOVWF 0xC, ACCESS
         250 01F2 0E07 MOVLW 0x7
         251 01F4 160A ANDWF 0xA, F, ACCESS
         252 01F6 E00E BZ 0x214
         253 01F8 500B MOVF 0xB, W, ACCESS
         254 01FA 100C IORWF 0xC, W, ACCESS
         255 01FC E00B BZ 0x214
         256 01FE 340C RLCF 0xC, W, ACCESS
         257 0200 320C RRCF 0xC, F, ACCESS
         258 0202 320B RRCF 0xB, F, ACCESS
         259 0204 2E0A DECFSZ 0xA, F, ACCESS
         260 0206 D7FB BRA 0x1FE
         261 0208 500B MOVF 0xB, W, ACCESS
         262 020A 100C IORWF 0xC, W, ACCESS
         263 020C E103 BNZ 0x214
         264 020E 2A0B INCF 0xB, F, ACCESS
         265 0210 0E00 MOVLW 0x0
         266 0212 220C ADDWFC 0xC, F, ACCESS
         267 0214 C007 MOVFF 0x7, FSR0
         268 0216 FFE9 NOP
         269 0218 6AEA CLRF FSR0H, ACCESS
         270 021A 500B MOVF 0xB, W, ACCESS
         271 021C 5EEE SUBWF POSTINC0, F, ACCESS
         272 021E 500C MOVF 0xC, W, ACCESS
         273 0220 5AEF SUBWFB INDF0, F, ACCESS
         274 0222 0012 RETURN 0
         275 0224 B2C2 BTFSC ADCON0, 1, ACCESS
         276 0226 D044 BRA 0x2B0
         277 0228 CFC3 MOVFF ADRES, 0x3
         278 022A F003 NOP
         279 022C CFC4 MOVFF ADRESH, 0x4
         280 022E F004 NOP
         281 0230 0E06 MOVLW 0x6
         282 0232 6EC1 MOVWF ADCON1, ACCESS
         283 0234 0E9D MOVLW 0x9D
         284 0236 6EC0 MOVWF ADCON2, ACCESS
         285 0238 0E03 MOVLW 0x3
         286 023A 6E05 MOVWF 0x5, ACCESS
         287 023C BE19 BTFSC 0x19, 7, ACCESS
         288 023E D002 BRA 0x244
         289 0240 0E01 MOVLW 0x1
         290 0242 6E05 MOVWF 0x5, ACCESS
         291 0244 B219 BTFSC 0x19, 1, ACCESS
         292 0246 6A05 CLRF 0x5, ACCESS
         293 0248 2A38 INCF 0x38, F, ACCESS
         294 024A 5038 MOVF 0x38, W, ACCESS
         295 024C 0A01 XORLW 0x1
         296 024E E009 BZ 0x262
         297 0250 0A03 XORLW 0x3
         298 0252 E00C BZ 0x26C
         299 0254 0A01 XORLW 0x1
         300 0256 E00F BZ 0x276
         301 0258 0A07 XORLW 0x7
         302 025A E012 BZ 0x280
         303 025C 0A01 XORLW 0x1
         304 025E E015 BZ 0x28A
         305 0260 D019 BRA 0x294
         306 0262 0E05 MOVLW 0x5
         307 0264 6EC2 MOVWF ADCON0, ACCESS
         308 0266 0E25 MOVLW 0x25
         309 0268 6E06 MOVWF 0x6, ACCESS
         310 026A D019 BRA 0x29E
         311 026C 0E09 MOVLW 0x9
         312 026E 6EC2 MOVWF ADCON0, ACCESS
         313 0270 0E27 MOVLW 0x27
         314 0272 6E06 MOVWF 0x6, ACCESS
         315 0274 D014 BRA 0x29E
         316 0276 0E0D MOVLW 0xD
         317 0278 6EC2 MOVWF ADCON0, ACCESS
         318 027A 0E29 MOVLW 0x29
         319 027C 6E06 MOVWF 0x6, ACCESS
         320 027E D00F BRA 0x29E
         321 0280 0E11 MOVLW 0x11
         322 0282 6EC2 MOVWF ADCON0, ACCESS
         323 0284 0E2B MOVLW 0x2B
         324 0286 6E06 MOVWF 0x6, ACCESS
         325 0288 D00A BRA 0x29E
         326 028A 0E21 MOVLW 0x21
         327 028C 6EC2 MOVWF ADCON0, ACCESS
         328 028E 0E2D MOVLW 0x2D
         329 0290 6E06 MOVWF 0x6, ACCESS
         330 0292 D005 BRA 0x29E
         331 0294 0E01 MOVLW 0x1
         332 0296 6EC2 MOVWF ADCON0, ACCESS
         333 0298 0E2F MOVLW 0x2F
         334 029A 6E06 MOVWF 0x6, ACCESS
         335 029C 6A38 CLRF 0x38, ACCESS
         336 029E C006 MOVFF 0x6, 0x7
         337 02A0 F007 NOP
         338 02A2 C003 MOVFF 0x3, 0x8
         339 02A4 F008 NOP
         340 02A6 C004 MOVFF 0x4, 0x9
         341 02A8 F009 NOP
         342 02AA 5005 MOVF 0x5, W, ACCESS
         343 02AC DF98 RCALL 0x1DE
         344 02AE 82C2 BSF ADCON0, 1, ACCESS
         345 02B0 0012 RETURN 0
         346 02B2 EE00 LFSR 0, 0x0
         347 02B4 F000 NOP
         348 02B6 0E03 MOVLW 0x3
         349 02B8 6AEE CLRF POSTINC0, ACCESS
         350 02BA 62EA CPFSEQ FSR0H, ACCESS
         351 02BC D7FD BRA 0x2B8
         352 02BE 6A80 CLRF PORTA, ACCESS
         353 02C0 0E04 MOVLW 0x4
         354 02C2 6E81 MOVWF PORTB, ACCESS
         355 02C4 0E40 MOVLW 0x40
         356 02C6 6E82 MOVWF PORTC, ACCESS
         357 02C8 0E2F MOVLW 0x2F
         358 02CA 6E92 MOVWF TRISA, ACCESS
         359 02CC 0EDA MOVLW 0xDA
         360 02CE 6E93 MOVWF TRISB, ACCESS
         361 02D0 6A94 CLRF TRISC, ACCESS
         362 02D2 0E06 MOVLW 0x6
         363 02D4 6EC1 MOVWF ADCON1, ACCESS
         364 02D6 0E9D MOVLW 0x9D
         365 02D8 6EC0 MOVWF ADCON2, ACCESS
         366 02DA 0012 RETURN 0
         367 02DC 9ED0 BCF RCON, 7, ACCESS
         368 02DE 8CF2 BSF INTCON, 6, ACCESS
         369 02E0 8EF2 BSF INTCON, 7, ACCESS
         370 02E2 BE19 BTFSC 0x19, 7, ACCESS
         371 02E4 D007 BRA 0x2F4
         372 02E6 0E73 MOVLW 0x73
         373 02E8 14D3 ANDWF OSCCON, W, ACCESS
         374 02EA 0A33 XORLW 0x33
         375 02EC E009 BZ 0x300
         376 02EE 0E33 MOVLW 0x33
         377 02F0 6ED3 MOVWF OSCCON, ACCESS
         378 02F2 D006 BRA 0x300
         379 02F4 0E73 MOVLW 0x73
         380 02F6 14D3 ANDWF OSCCON, W, ACCESS
         381 02F8 0A73 XORLW 0x73
         382 02FA E002 BZ 0x300
         383 02FC 0E73 MOVLW 0x73
         384 02FE 6ED3 MOVWF OSCCON, ACCESS
         385 0300 0E2F MOVLW 0x2F
         386 0302 6E92 MOVWF TRISA, ACCESS
         387 0304 0EDA MOVLW 0xDA
         388 0306 6E93 MOVWF TRISB, ACCESS
         389 0308 6A94 CLRF TRISC, ACCESS
         390 030A 0012 RETURN 0
         391 030C AA19 BTFSS 0x19, 5, ACCESS
         392 030E D004 BRA 0x318
         393 0310 0E03 MOVLW 0x3
         394 0312 6433 CPFSGT 0x33, ACCESS
         395 0314 D001 BRA 0x318
         396 0316 6E33 MOVWF 0x33, ACCESS
         397 0318 BC19 BTFSC 0x19, 6, ACCESS
         398 031A 6A33 CLRF 0x33, ACCESS
         399 031C AE19 BTFSS 0x19, 7, ACCESS
         400 031E D008 BRA 0x330
         401 0320 A419 BTFSS 0x19, 2, ACCESS
         402 0322 D006 BRA 0x330
         403 0324 5233 MOVF 0x33, F, ACCESS
         404 0326 E004 BZ 0x330
         405 0328 B819 BTFSC 0x19, 4, ACCESS
         406 032A D002 BRA 0x330
         407 032C B031 BTFSC 0x31, 0, ACCESS
         408 032E D008 BRA 0x340
         409 0330 6A32 CLRF 0x32, ACCESS
         410 0332 6A39 CLRF 0x39, ACCESS
         411 0334 9082 BCF PORTC, 0, ACCESS
         412 0336 9282 BCF PORTC, 1, ACCESS
         413 0338 9A81 BCF PORTB, 5, ACCESS
         414 033A 9682 BCF PORTC, 3, ACCESS
         415 033C 9882 BCF PORTC, 4, ACCESS
         416 033E D092 BRA 0x464
         417 0340 A019 BTFSS 0x19, 0, ACCESS
         418 0342 D002 BRA 0x348
         419 0344 6639 TSTFSZ 0x39, ACCESS
         420 0346 0639 DECF 0x39, F, ACCESS
         421 0348 5032 MOVF 0x32, W, ACCESS
         422 034A E00B BZ 0x362
         423 034C 0A01 XORLW 0x1
         424 034E E017 BZ 0x37E
         425 0350 0A03 XORLW 0x3
         426 0352 E02C BZ 0x3AC
         427 0354 0A01 XORLW 0x1
         428 0356 E044 BZ 0x3E0
         429 0358 0A07 XORLW 0x7
         430 035A E05C BZ 0x414
         431 035C 0A01 XORLW 0x1
         432 035E E072 BZ 0x444
         433 0360 D080 BRA 0x462
         434 0362 5233 MOVF 0x33, F, ACCESS
         435 0364 E004 BZ 0x36E
         436 0366 0E01 MOVLW 0x1
         437 0368 6E32 MOVWF 0x32, ACCESS
         438 036A 0E0A MOVLW 0xA
         439 036C 6E39 MOVWF 0x39, ACCESS
         440 036E 6633 TSTFSZ 0x33, ACCESS
         441 0370 D079 BRA 0x464
         442 0372 9082 BCF PORTC, 0, ACCESS
         443 0374 9282 BCF PORTC, 1, ACCESS
         444 0376 9A81 BCF PORTB, 5, ACCESS
         445 0378 9682 BCF PORTC, 3, ACCESS
         446 037A 9882 BCF PORTC, 4, ACCESS
         447 037C D073 BRA 0x464
         448 037E 6633 TSTFSZ 0x33, ACCESS
         449 0380 D002 BRA 0x386
         450 0382 6A32 CLRF 0x32, ACCESS
         451 0384 6A39 CLRF 0x39, ACCESS
         452 0386 6639 TSTFSZ 0x39, ACCESS
         453 0388 D002 BRA 0x38E
         454 038A 2C33 DECFSZ 0x33, W, ACCESS
         455 038C D005 BRA 0x398
         456 038E 9082 BCF PORTC, 0, ACCESS
         457 0390 8282 BSF PORTC, 1, ACCESS
         458 0392 9A81 BCF PORTB, 5, ACCESS
         459 0394 9682 BCF PORTC, 3, ACCESS
         460 0396 9882 BCF PORTC, 4, ACCESS
         461 0398 6639 TSTFSZ 0x39, ACCESS
         462 039A D064 BRA 0x464
         463 039C 0E01 MOVLW 0x1
         464 039E 6433 CPFSGT 0x33, ACCESS
         465 03A0 D061 BRA 0x464
         466 03A2 0E02 MOVLW 0x2
         467 03A4 6E32 MOVWF 0x32, ACCESS
         468 03A6 0E0A MOVLW 0xA
         469 03A8 6E39 MOVWF 0x39, ACCESS
         470 03AA D05C BRA 0x464
         471 03AC 0E02 MOVLW 0x2
         472 03AE 6033 CPFSLT 0x33, ACCESS
         473 03B0 D003 BRA 0x3B8
         474 03B2 0E01 MOVLW 0x1
         475 03B4 6E32 MOVWF 0x32, ACCESS
         476 03B6 6A39 CLRF 0x39, ACCESS
         477 03B8 6639 TSTFSZ 0x39, ACCESS
         478 03BA D003 BRA 0x3C2
         479 03BC 0E02 MOVLW 0x2
         480 03BE 6233 CPFSEQ 0x33, ACCESS
         481 03C0 D005 BRA 0x3CC
         482 03C2 9082 BCF PORTC, 0, ACCESS
         483 03C4 8282 BSF PORTC, 1, ACCESS
         484 03C6 9A81 BCF PORTB, 5, ACCESS
         485 03C8 8682 BSF PORTC, 3, ACCESS
         486 03CA 9882 BCF PORTC, 4, ACCESS
         487 03CC 6639 TSTFSZ 0x39, ACCESS
         488 03CE D04A BRA 0x464
         489 03D0 0E02 MOVLW 0x2
         490 03D2 6433 CPFSGT 0x33, ACCESS
         491 03D4 D047 BRA 0x464
         492 03D6 0E03 MOVLW 0x3
         493 03D8 6E32 MOVWF 0x32, ACCESS
         494 03DA 0E0A MOVLW 0xA
         495 03DC 6E39 MOVWF 0x39, ACCESS
         496 03DE D042 BRA 0x464
         497 03E0 0E03 MOVLW 0x3
         498 03E2 6033 CPFSLT 0x33, ACCESS
         499 03E4 D003 BRA 0x3EC
         500 03E6 0E02 MOVLW 0x2
         501 03E8 6E32 MOVWF 0x32, ACCESS
         502 03EA 6A39 CLRF 0x39, ACCESS
         503 03EC 6639 TSTFSZ 0x39, ACCESS
         504 03EE D003 BRA 0x3F6
         505 03F0 0E03 MOVLW 0x3
         506 03F2 6233 CPFSEQ 0x33, ACCESS
         507 03F4 D005 BRA 0x400
         508 03F6 8082 BSF PORTC, 0, ACCESS
         509 03F8 8282 BSF PORTC, 1, ACCESS
         510 03FA 9A81 BCF PORTB, 5, ACCESS
         511 03FC 8682 BSF PORTC, 3, ACCESS
         512 03FE 9882 BCF PORTC, 4, ACCESS
         513 0400 6639 TSTFSZ 0x39, ACCESS
         514 0402 D030 BRA 0x464
         515 0404 0E03 MOVLW 0x3
         516 0406 6433 CPFSGT 0x33, ACCESS
         517 0408 D02D BRA 0x464
         518 040A 0E04 MOVLW 0x4
         519 040C 6E32 MOVWF 0x32, ACCESS
         520 040E 0E19 MOVLW 0x19
         521 0410 6E39 MOVWF 0x39, ACCESS
         522 0412 D028 BRA 0x464
         523 0414 0E04 MOVLW 0x4
         524 0416 6033 CPFSLT 0x33, ACCESS
         525 0418 D003 BRA 0x420
         526 041A 0E03 MOVLW 0x3
         527 041C 6E32 MOVWF 0x32, ACCESS
         528 041E 6A39 CLRF 0x39, ACCESS
         529 0420 6639 TSTFSZ 0x39, ACCESS
         530 0422 D003 BRA 0x42A
         531 0424 0E04 MOVLW 0x4
         532 0426 6233 CPFSEQ 0x33, ACCESS
         533 0428 D005 BRA 0x434
         534 042A 8082 BSF PORTC, 0, ACCESS
         535 042C 8282 BSF PORTC, 1, ACCESS
         536 042E 9A81 BCF PORTB, 5, ACCESS
         537 0430 8682 BSF PORTC, 3, ACCESS
         538 0432 8882 BSF PORTC, 4, ACCESS
         539 0434 6639 TSTFSZ 0x39, ACCESS
         540 0436 D016 BRA 0x464
         541 0438 0E04 MOVLW 0x4
         542 043A 6433 CPFSGT 0x33, ACCESS
         543 043C D013 BRA 0x464
         544 043E 0E05 MOVLW 0x5
         545 0440 6E32 MOVWF 0x32, ACCESS
         546 0442 D010 BRA 0x464
         547 0444 0E05 MOVLW 0x5
         548 0446 6033 CPFSLT 0x33, ACCESS
         549 0448 D003 BRA 0x450
         550 044A 0E04 MOVLW 0x4
         551 044C 6E32 MOVWF 0x32, ACCESS
         552 044E 6A39 CLRF 0x39, ACCESS
         553 0450 0E04 MOVLW 0x4
         554 0452 6433 CPFSGT 0x33, ACCESS
         555 0454 D007 BRA 0x464
         556 0456 8082 BSF PORTC, 0, ACCESS
         557 0458 8282 BSF PORTC, 1, ACCESS
         558 045A 8A81 BSF PORTB, 5, ACCESS
         559 045C 8682 BSF PORTC, 3, ACCESS
         560 045E 8882 BSF PORTC, 4, ACCESS
         561 0460 D001 BRA 0x464
         562 0462 6A32 CLRF 0x32, ACCESS
         563 0464 0012 RETURN 0
         564 0466 BE19 BTFSC 0x19, 7, ACCESS
         565 0468 D002 BRA 0x46E
         566 046A 9E82 BCF PORTC, 7, ACCESS
         567 046C 0012 RETURN 0
         568 046E B419 BTFSC 0x19, 2, ACCESS
         569 0470 D004 BRA 0x47A
         570 0472 0E05 MOVLW 0x5
         571 0474 6E03 MOVWF 0x3, ACCESS
         572 0476 6E04 MOVWF 0x4, ACCESS
         573 0478 D00D BRA 0x494
         574 047A B819 BTFSC 0x19, 4, ACCESS
         575 047C D002 BRA 0x482
         576 047E AC19 BTFSS 0x19, 6, ACCESS
         577 0480 D005 BRA 0x48C
         578 0482 0E14 MOVLW 0x14
         579 0484 6E03 MOVWF 0x3, ACCESS
         580 0486 0E0A MOVLW 0xA
         581 0488 6E04 MOVWF 0x4, ACCESS
         582 048A D004 BRA 0x494
         583 048C 0E28 MOVLW 0x28
         584 048E 6E03 MOVWF 0x3, ACCESS
         585 0490 0E0A MOVLW 0xA
         586 0492 6E04 MOVWF 0x4, ACCESS
         587 0494 BE82 BTFSC PORTC, 7, ACCESS
         588 0496 D006 BRA 0x4A4
         589 0498 501C MOVF 0x1C, W, ACCESS
         590 049A 6004 CPFSLT 0x4, ACCESS
         591 049C D008 BRA 0x4AE
         592 049E C004 MOVFF 0x4, 0x1C
         593 04A0 F01C NOP
         594 04A2 D005 BRA 0x4AE
         595 04A4 501C MOVF 0x1C, W, ACCESS
         596 04A6 6003 CPFSLT 0x3, ACCESS
         597 04A8 D002 BRA 0x4AE
         598 04AA C003 MOVFF 0x3, 0x1C
         599 04AC F01C NOP
         600 04AE 661C TSTFSZ 0x1C, ACCESS
         601 04B0 D009 BRA 0x4C4
         602 04B2 BE82 BTFSC PORTC, 7, ACCESS
         603 04B4 D004 BRA 0x4BE
         604 04B6 8E82 BSF PORTC, 7, ACCESS
         605 04B8 C003 MOVFF 0x3, 0x1C
         606 04BA F01C NOP
         607 04BC D003 BRA 0x4C4
         608 04BE 9E82 BCF PORTC, 7, ACCESS
         609 04C0 C004 MOVFF 0x4, 0x1C
         610 04C2 F01C NOP
         611 04C4 0012 RETURN 0
         612 04C6 BE19 BTFSC 0x19, 7, ACCESS
         613 04C8 D005 BRA 0x4D4
         614 04CA 9819 BCF 0x19, 4, ACCESS
         615 04CC 9482 BCF PORTC, 2, ACCESS
         616 04CE 0E01 MOVLW 0x1
         617 04D0 6E3A MOVWF 0x3A, ACCESS
         618 04D2 0012 RETURN 0
         619 04D4 503A MOVF 0x3A, W, ACCESS
         620 04D6 0A01 XORLW 0x1
         621 04D8 E005 BZ 0x4E4
         622 04DA 0A03 XORLW 0x3
         623 04DC E008 BZ 0x4EE
         624 04DE 0A01 XORLW 0x1
         625 04E0 E029 BZ 0x534
         626 04E2 D045 BRA 0x56E
         627 04E4 0E05 MOVLW 0x5
         628 04E6 6E20 MOVWF 0x20, ACCESS
         629 04E8 0E02 MOVLW 0x2
         630 04EA 6E3A MOVWF 0x3A, ACCESS
         631 04EC D043 BRA 0x574
         632 04EE B482 BTFSC PORTC, 2, ACCESS
         633 04F0 D002 BRA 0x4F6
         634 04F2 8482 BSF PORTC, 2, ACCESS
         635 04F4 D001 BRA 0x4F8
         636 04F6 9482 BCF PORTC, 2, ACCESS
         637 04F8 502A MOVF 0x2A, W, ACCESS
         638 04FA E103 BNZ 0x502
         639 04FC 0E96 MOVLW 0x96
         640 04FE 6429 CPFSGT 0x29, ACCESS
         641 0500 D008 BRA 0x512
         642 0502 6620 TSTFSZ 0x20, ACCESS
         643 0504 D006 BRA 0x512
         644 0506 0E03 MOVLW 0x3
         645 0508 6E3A MOVWF 0x3A, ACCESS
         646 050A 0E05 MOVLW 0x5
         647 050C 6E20 MOVWF 0x20, ACCESS
         648 050E 9482 BCF PORTC, 2, ACCESS
         649 0510 D031 BRA 0x574
         650 0512 502A MOVF 0x2A, W, ACCESS
         651 0514 E109 BNZ 0x528
         652 0516 0E64 MOVLW 0x64
         653 0518 6029 CPFSLT 0x29, ACCESS
         654 051A D006 BRA 0x528
         655 051C 6620 TSTFSZ 0x20, ACCESS
         656 051E D004 BRA 0x528
         657 0520 0E01 MOVLW 0x1
         658 0522 6E3A MOVWF 0x3A, ACCESS
         659 0524 9482 BCF PORTC, 2, ACCESS
         660 0526 D026 BRA 0x574
         661 0528 6620 TSTFSZ 0x20, ACCESS
         662 052A D024 BRA 0x574
         663 052C 0E01 MOVLW 0x1
         664 052E 6E3A MOVWF 0x3A, ACCESS
         665 0530 9482 BCF PORTC, 2, ACCESS
         666 0532 D020 BRA 0x574
         667 0534 502A MOVF 0x2A, W, ACCESS
         668 0536 E103 BNZ 0x53E
         669 0538 0E96 MOVLW 0x96
         670 053A 6429 CPFSGT 0x29, ACCESS
         671 053C D006 BRA 0x54A
         672 053E 6620 TSTFSZ 0x20, ACCESS
         673 0540 D004 BRA 0x54A
         674 0542 0E01 MOVLW 0x1
         675 0544 6E3A MOVWF 0x3A, ACCESS
         676 0546 9819 BCF 0x19, 4, ACCESS
         677 0548 D015 BRA 0x574
         678 054A 502A MOVF 0x2A, W, ACCESS
         679 054C E109 BNZ 0x560
         680 054E 0E96 MOVLW 0x96
         681 0550 6029 CPFSLT 0x29, ACCESS
         682 0552 D006 BRA 0x560
         683 0554 6620 TSTFSZ 0x20, ACCESS
         684 0556 D004 BRA 0x560
         685 0558 0E01 MOVLW 0x1
         686 055A 6E3A MOVWF 0x3A, ACCESS
         687 055C 8819 BSF 0x19, 4, ACCESS
         688 055E D00A BRA 0x574
         689 0560 6620 TSTFSZ 0x20, ACCESS
         690 0562 D008 BRA 0x574
         691 0564 0E01 MOVLW 0x1
         692 0566 6E3A MOVWF 0x3A, ACCESS
         693 0568 9482 BCF PORTC, 2, ACCESS
         694 056A 9819 BCF 0x19, 4, ACCESS
         695 056C D003 BRA 0x574
         696 056E 0E01 MOVLW 0x1
         697 0570 6E3A MOVWF 0x3A, ACCESS
         698 0572 9819 BCF 0x19, 4, ACCESS
         699 0574 0012 RETURN 0
         700 0576 BE19 BTFSC 0x19, 7, ACCESS
         701 0578 D00A BRA 0x58E
         702 057A 9081 BCF PORTB, 0, ACCESS
         703 057C 9A82 BCF PORTC, 5, ACCESS
         704 057E 0EC8 MOVLW 0xC8
         705 0580 6E34 MOVWF 0x34, ACCESS
         706 0582 6A35 CLRF 0x35, ACCESS
         707 0584 6E36 MOVWF 0x36, ACCESS
         708 0586 6A37 CLRF 0x37, ACCESS
         709 0588 0E05 MOVLW 0x5
         710 058A 6E3B MOVWF 0x3B, ACCESS
         711 058C D0AC BRA 0x6E6
         712 058E 8081 BSF PORTB, 0, ACCESS
         713 0590 8A82 BSF PORTC, 5, ACCESS
         714 0592 A019 BTFSS 0x19, 0, ACCESS
         715 0594 D06C BRA 0x66E
         716 0596 523B MOVF 0x3B, F, ACCESS
         717 0598 E002 BZ 0x59E
         718 059A 063B DECF 0x3B, F, ACCESS
         719 059C D068 BRA 0x66E
         720 059E B231 BTFSC 0x31, 1, ACCESS
         721 05A0 D00B BRA 0x5B8
         722 05A2 8231 BSF 0x31, 1, ACCESS
         723 05A4 C02F MOVFF 0x2F, 0x6
         724 05A6 F006 NOP
         725 05A8 C030 MOVFF 0x30, 0x7
         726 05AA F007 NOP
         727 05AC C027 MOVFF 0x27, 0x3
         728 05AE F003 NOP
         729 05B0 C028 MOVFF 0x28, 0x4
         730 05B2 F004 NOP
         731 05B4 6A05 CLRF 0x5, ACCESS
         732 05B6 D00A BRA 0x5CC
         733 05B8 9231 BCF 0x31, 1, ACCESS
         734 05BA C02D MOVFF 0x2D, 0x6
         735 05BC F006 NOP
         736 05BE C02E MOVFF 0x2E, 0x7
         737 05C0 F007 NOP
         738 05C2 C025 MOVFF 0x25, 0x3
         739 05C4 F003 NOP
         740 05C6 C026 MOVFF 0x26, 0x4
         741 05C8 F004 NOP
         742 05CA 6A05 CLRF 0x5, ACCESS
         743 05CC 90D8 BCF STATUS, 0, ACCESS
         744 05CE 3207 RRCF 0x7, F, ACCESS
         745 05D0 3206 RRCF 0x6, F, ACCESS
         746 05D2 90D8 BCF STATUS, 0, ACCESS
         747 05D4 3207 RRCF 0x7, F, ACCESS
         748 05D6 3206 RRCF 0x6, F, ACCESS
         749 05D8 5005 MOVF 0x5, W, ACCESS
         750 05DA 0DFF MULLW 0xFF
         751 05DC CFF3 MOVFF PROD, 0x5
         752 05DE F005 NOP
         753 05E0 5004 MOVF 0x4, W, ACCESS
         754 05E2 0DFF MULLW 0xFF
         755 05E4 CFF3 MOVFF PROD, 0x4
         756 05E6 F004 NOP
         757 05E8 50F4 MOVF PRODH, W, ACCESS
         758 05EA 2605 ADDWF 0x5, F, ACCESS
         759 05EC 5003 MOVF 0x3, W, ACCESS
         760 05EE 0DFF MULLW 0xFF
         761 05F0 CFF3 MOVFF PROD, 0x3
         762 05F2 F003 NOP
         763 05F4 50F4 MOVF PRODH, W, ACCESS
         764 05F6 2604 ADDWF 0x4, F, ACCESS
         765 05F8 0E00 MOVLW 0x0
         766 05FA 2205 ADDWFC 0x5, F, ACCESS
         767 05FC 5003 MOVF 0x3, W, ACCESS
         768 05FE 6E0A MOVWF 0xA, ACCESS
         769 0600 5004 MOVF 0x4, W, ACCESS
         770 0602 6E0B MOVWF 0xB, ACCESS
         771 0604 5005 MOVF 0x5, W, ACCESS
         772 0606 6E0C MOVWF 0xC, ACCESS
         773 0608 6A0D CLRF 0xD, ACCESS
         774 060A 0E18 MOVLW 0x18
         775 060C 6E09 MOVWF 0x9, ACCESS
         776 060E 360A RLCF 0xA, F, ACCESS
         777 0610 360B RLCF 0xB, F, ACCESS
         778 0612 360C RLCF 0xC, F, ACCESS
         779 0614 360D RLCF 0xD, F, ACCESS
         780 0616 E203 BC 0x61E
         781 0618 5006 MOVF 0x6, W, ACCESS
         782 061A 5C0D SUBWF 0xD, W, ACCESS
         783 061C E303 BNC 0x624
         784 061E 5006 MOVF 0x6, W, ACCESS
         785 0620 5E0D SUBWF 0xD, F, ACCESS
         786 0622 80D8 BSF STATUS, 0, ACCESS
         787 0624 3603 RLCF 0x3, F, ACCESS
         788 0626 3604 RLCF 0x4, F, ACCESS
         789 0628 3605 RLCF 0x5, F, ACCESS
         790 062A 2E09 DECFSZ 0x9, F, ACCESS
         791 062C D7F0 BRA 0x60E
         792 062E 5005 MOVF 0x5, W, ACCESS
         793 0630 E103 BNZ 0x638
         794 0632 0E03 MOVLW 0x3
         795 0634 6404 CPFSGT 0x4, ACCESS
         796 0636 D004 BRA 0x640
         797 0638 6803 SETF 0x3, ACCESS
         798 063A 0E03 MOVLW 0x3
         799 063C 6E04 MOVWF 0x4, ACCESS
         800 063E 6A05 CLRF 0x5, ACCESS
         801 0640 B231 BTFSC 0x31, 1, ACCESS
         802 0642 D00B BRA 0x65A
         803 0644 C003 MOVFF 0x3, 0x9
         804 0646 F009 NOP
         805 0648 C004 MOVFF 0x4, 0xA
         806 064A F00A NOP
         807 064C 6A0B CLRF 0xB, ACCESS
         808 064E DD80 RCALL 0x150
         809 0650 C00C MOVFF 0xC, 0x34
         810 0652 F034 NOP
         811 0654 C00D MOVFF 0xD, 0x35
         812 0656 F035 NOP
         813 0658 D00A BRA 0x66E
         814 065A C003 MOVFF 0x3, 0x9
         815 065C F009 NOP
         816 065E C004 MOVFF 0x4, 0xA
         817 0660 F00A NOP
         818 0662 6A0B CLRF 0xB, ACCESS
         819 0664 DD75 RCALL 0x150
         820 0666 C00C MOVFF 0xC, 0x36
         821 0668 F036 NOP
         822 066A C00D MOVFF 0xD, 0x37
         823 066C F037 NOP
         824 066E BE35 BTFSC 0x35, 7, ACCESS
         825 0670 D005 BRA 0x67C
         826 0672 0E53 MOVLW 0x53
         827 0674 5C34 SUBWF 0x34, W, ACCESS
         828 0676 0E03 MOVLW 0x3
         829 0678 5835 SUBWFB 0x35, W, ACCESS
         830 067A E207 BC 0x68A
         831 067C BE37 BTFSC 0x37, 7, ACCESS
         832 067E D006 BRA 0x68C
         833 0680 0E53 MOVLW 0x53
         834 0682 5C36 SUBWF 0x36, W, ACCESS
         835 0684 0E03 MOVLW 0x3
         836 0686 5837 SUBWFB 0x37, W, ACCESS
         837 0688 B0D8 BTFSC STATUS, 0, ACCESS
         838 068A 8A19 BSF 0x19, 5, ACCESS
         839 068C BE35 BTFSC 0x35, 7, ACCESS
         840 068E D005 BRA 0x69A
         841 0690 0E20 MOVLW 0x20
         842 0692 5C34 SUBWF 0x34, W, ACCESS
         843 0694 0E03 MOVLW 0x3
         844 0696 5835 SUBWFB 0x35, W, ACCESS
         845 0698 E208 BC 0x6AA
         846 069A BE37 BTFSC 0x37, 7, ACCESS
         847 069C D005 BRA 0x6A8
         848 069E 0E20 MOVLW 0x20
         849 06A0 5C36 SUBWF 0x36, W, ACCESS
         850 06A2 0E03 MOVLW 0x3
         851 06A4 5837 SUBWFB 0x37, W, ACCESS
         852 06A6 A0D8 BTFSS STATUS, 0, ACCESS
         853 06A8 9A19 BCF 0x19, 5, ACCESS
         854 06AA BE35 BTFSC 0x35, 7, ACCESS
         855 06AC D005 BRA 0x6B8
         856 06AE 0EE9 MOVLW 0xE9
         857 06B0 5C34 SUBWF 0x34, W, ACCESS
         858 06B2 0E03 MOVLW 0x3
         859 06B4 5835 SUBWFB 0x35, W, ACCESS
         860 06B6 E207 BC 0x6C6
         861 06B8 BE37 BTFSC 0x37, 7, ACCESS
         862 06BA D006 BRA 0x6C8
         863 06BC 0EE9 MOVLW 0xE9
         864 06BE 5C36 SUBWF 0x36, W, ACCESS
         865 06C0 0E03 MOVLW 0x3
         866 06C2 5837 SUBWFB 0x37, W, ACCESS
         867 06C4 B0D8 BTFSC STATUS, 0, ACCESS
         868 06C6 8C19 BSF 0x19, 6, ACCESS
         869 06C8 BE35 BTFSC 0x35, 7, ACCESS
         870 06CA D005 BRA 0x6D6
         871 06CC 0EB6 MOVLW 0xB6
         872 06CE 5C34 SUBWF 0x34, W, ACCESS
         873 06D0 0E03 MOVLW 0x3
         874 06D2 5835 SUBWFB 0x35, W, ACCESS
         875 06D4 E208 BC 0x6E6
         876 06D6 BE37 BTFSC 0x37, 7, ACCESS
         877 06D8 D005 BRA 0x6E4
         878 06DA 0EB6 MOVLW 0xB6
         879 06DC 5C36 SUBWF 0x36, W, ACCESS
         880 06DE 0E03 MOVLW 0x3
         881 06E0 5837 SUBWFB 0x37, W, ACCESS
         882 06E2 A0D8 BTFSS STATUS, 0, ACCESS
         883 06E4 9C19 BCF 0x19, 6, ACCESS
         884 06E6 0012 RETURN 0
         885 06E8 502C MOVF 0x2C, W, ACCESS
         886 06EA E102 BNZ 0x6F0
         887 06EC 0EFB MOVLW 0xFB
         888 06EE 602B CPFSLT 0x2B, ACCESS
         889 06F0 8431 BSF 0x31, 2, ACCESS
         890 06F2 502C MOVF 0x2C, W, ACCESS
         891 06F4 E103 BNZ 0x6FC
         892 06F6 0EC7 MOVLW 0xC7
         893 06F8 642B CPFSGT 0x2B, ACCESS
         894 06FA 9431 BCF 0x31, 2, ACCESS
         895 06FC B881 BTFSC PORTB, 4, ACCESS
         896 06FE D002 BRA 0x704
         897 0700 0E05 MOVLW 0x5
         898 0702 6E1F MOVWF 0x1F, ACCESS
         899 0704 521F MOVF 0x1F, F, ACCESS
         900 0706 E002 BZ 0x70C
         901 0708 8419 BSF 0x19, 2, ACCESS
         902 070A D001 BRA 0x70E
         903 070C 9419 BCF 0x19, 2, ACCESS
         904 070E B419 BTFSC 0x19, 2, ACCESS
         905 0710 D002 BRA 0x716
         906 0712 A431 BTFSS 0x31, 2, ACCESS
         907 0714 D002 BRA 0x71A
         908 0716 0E96 MOVLW 0x96
         909 0718 6E1E MOVWF 0x1E, ACCESS
         910 071A 521E MOVF 0x1E, F, ACCESS
         911 071C E002 BZ 0x722
         912 071E 8E19 BSF 0x19, 7, ACCESS
         913 0720 D006 BRA 0x72E
         914 0722 9E19 BCF 0x19, 7, ACCESS
         915 0724 6A3C CLRF 0x3C, ACCESS
         916 0726 6A33 CLRF 0x33, ACCESS
         917 0728 6A3D CLRF 0x3D, ACCESS
         918 072A 0E64 MOVLW 0x64
         919 072C 6E21 MOVWF 0x21, ACCESS
         920 072E AE19 BTFSS 0x19, 7, ACCESS
         921 0730 D04C BRA 0x7CA
         922 0732 503C MOVF 0x3C, W, ACCESS
         923 0734 E005 BZ 0x740
         924 0736 0A01 XORLW 0x1
         925 0738 E008 BZ 0x74A
         926 073A 0A03 XORLW 0x3
         927 073C E00D BZ 0x758
         928 073E D045 BRA 0x7CA
         929 0740 B431 BTFSC 0x31, 2, ACCESS
         930 0742 D043 BRA 0x7CA
         931 0744 0E01 MOVLW 0x1
         932 0746 6E3C MOVWF 0x3C, ACCESS
         933 0748 D040 BRA 0x7CA
         934 074A 0E64 MOVLW 0x64
         935 074C 6E1D MOVWF 0x1D, ACCESS
         936 074E A431 BTFSS 0x31, 2, ACCESS
         937 0750 D03C BRA 0x7CA
         938 0752 0E02 MOVLW 0x2
         939 0754 6E3C MOVWF 0x3C, ACCESS
         940 0756 D039 BRA 0x7CA
         941 0758 661D TSTFSZ 0x1D, ACCESS
         942 075A D002 BRA 0x760
         943 075C 6A3C CLRF 0x3C, ACCESS
         944 075E D035 BRA 0x7CA
         945 0760 B431 BTFSC 0x31, 2, ACCESS
         946 0762 D033 BRA 0x7CA
         947 0764 C01D MOVFF 0x1D, 0x3
         948 0766 F003 NOP
         949 0768 6804 SETF 0x4, ACCESS
         950 076A 0E60 MOVLW 0x60
         951 076C 6003 CPFSLT 0x3, ACCESS
         952 076E D022 BRA 0x7B4
         953 0770 0E55 MOVLW 0x55
         954 0772 6403 CPFSGT 0x3, ACCESS
         955 0774 D002 BRA 0x77A
         956 0776 6A04 CLRF 0x4, ACCESS
         957 0778 D01D BRA 0x7B4
         958 077A 0E4B MOVLW 0x4B
         959 077C 6403 CPFSGT 0x3, ACCESS
         960 077E D003 BRA 0x786
         961 0780 0E01 MOVLW 0x1
         962 0782 6E04 MOVWF 0x4, ACCESS
         963 0784 D017 BRA 0x7B4
         964 0786 0E41 MOVLW 0x41
         965 0788 6403 CPFSGT 0x3, ACCESS
         966 078A D003 BRA 0x792
         967 078C 0E02 MOVLW 0x2
         968 078E 6E04 MOVWF 0x4, ACCESS
         969 0790 D011 BRA 0x7B4
         970 0792 0E37 MOVLW 0x37
         971 0794 6403 CPFSGT 0x3, ACCESS
         972 0796 D003 BRA 0x79E
         973 0798 0E03 MOVLW 0x3
         974 079A 6E04 MOVWF 0x4, ACCESS
         975 079C D00B BRA 0x7B4
         976 079E 0E2D MOVLW 0x2D
         977 07A0 6403 CPFSGT 0x3, ACCESS
         978 07A2 D003 BRA 0x7AA
         979 07A4 0E04 MOVLW 0x4
         980 07A6 6E04 MOVWF 0x4, ACCESS
         981 07A8 D005 BRA 0x7B4
         982 07AA 0E23 MOVLW 0x23
         983 07AC 6403 CPFSGT 0x3, ACCESS
         984 07AE D002 BRA 0x7B4
         985 07B0 0E05 MOVLW 0x5
         986 07B2 6E04 MOVWF 0x4, ACCESS
         987 07B4 4804 INFSNZ 0x4, W, ACCESS
         988 07B6 D008 BRA 0x7C8
         989 07B8 503D MOVF 0x3D, W, ACCESS
         990 07BA 6204 CPFSEQ 0x4, ACCESS
         991 07BC D003 BRA 0x7C4
         992 07BE C004 MOVFF 0x4, 0x33
         993 07C0 F033 NOP
         994 07C2 D002 BRA 0x7C8
         995 07C4 C004 MOVFF 0x4, 0x3D
         996 07C6 F03D NOP
         997 07C8 6A3C CLRF 0x3C, ACCESS
         998 07CA 0012 RETURN 0
         999 07CC 5221 MOVF 0x21, F, ACCESS
        1000 07CE E002 BZ 0x7D4
        1001 07D0 9031 BCF 0x31, 0, ACCESS
        1002 07D2 D001 BRA 0x7D6
        1003 07D4 8031 BSF 0x31, 0, ACCESS
        1004 07D6 0012 RETURN 0
        1005 07D8 9031 BCF 0x31, 0, ACCESS
        1006 07DA 0E64 MOVLW 0x64
        1007 07DC 6E21 MOVWF 0x21, ACCESS
        1008 07DE 0012 RETURN 0

                                    
        1009 07E0 DD68 RCALL 0x2B2
        1010 07E2 DC64 RCALL 0xAC
        1011 07E4 DFF9 RCALL 0x7D8
        1012 07E6 DD7A RCALL 0x2DC
        1013 07E8 DF7F RCALL 0x6E8
        1014 07EA DFF0 RCALL 0x7CC
        1015 07EC 0004 CLRWDT
        1016 07EE DD8E RCALL 0x30C
        1017 07F0 DE3A RCALL 0x466
        1018 07F2 0004 CLRWDT
        1019 07F4 DEC0 RCALL 0x576
        1020 07F6 DE67 RCALL 0x4C6
        1021 07F8 0004 CLRWDT
        1022 07FA DD14 RCALL 0x224
        1023 07FC DC62 RCALL 0xC2
        1024 07FE 0004 CLRWDT
        1025 0800 D7F2 BRA 0x7E6
        1026 0802 6E17 MOVWF 0x17, ACCESS
        1027 0804 0F16 ADDLW 0x16
        1028 0806 6EF6 MOVWF TBLPTR, ACCESS
        1029 0808 0E08 MOVLW 0x8
        1030 080A 6AF7 CLRF TBLPTRH, ACCESS
        1031 080C 22F7 ADDWFC TBLPTRH, F, ACCESS
        1032 080E 6AF8 CLRF TBLPTRU, ACCESS
        1033 0810 0008 TBLRD*
        1034 0812 50F5 MOVF TABLAT, W, ACCESS
        1035 0814 0012 RETURN 0
        1036 0816 05E5 DECF 0xE5, W, BANKED
        1037 0818 05E5 DECF 0xE5, W, BANKED
        1038 081A 0479 DECF 0xF79, W, ACCESS
        1039 081C 03B1 MULWF 0xB1, BANKED
        1040 081E 0323 MULWF 0x23, BANKED
        1041 0820 02B3 MULWF TMR3H, ACCESS
        1042 0822 0253 MULWF 0x53, ACCESS
        1043 0824 01FD MOVLB 0xD
        1044 0826 01AB MOVLB 0xB
        1045 0828 015C MOVLB 0xC
        1046 082A 010B MOVLB 0xB
        1047 082C 00B4
        1048 082E 0051
        1049 0830 FFD3 NOP
        1050 0832 FEFB NOP

     
    with a goto to 7e0 whats going on around 82e ?
     

    David
    I support http://picforum.ric323.com because this forum is often too broken to use!
    #6
    John Mayer
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/05/21 17:30:01
    • Location: Portland, Oregon
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 14:43:49 (permalink)
    0
    No, I haven't tried copying the code to another chip. At the moment the only development tool I have is the PICkit 3. I suppose I should probably invest in some more development tools...
     
    #7
    John Mayer
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/05/21 17:30:01
    • Location: Portland, Oregon
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 14:59:25 (permalink)
    0
    NKurzman
    If you read the data from the chip and import it in to MPLab it will display the code in pic ASM. But pic ASM is far from C++



    This is definitely a step I would like to take, but I can't figure out how to open the hex file as anything other than text. Can you explain the steps to take after importing to see the pic ASM?
    #8
    John Mayer
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2018/05/21 17:30:01
    • Location: Portland, Oregon
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 15:07:30 (permalink)
    0
    Mysil
    Hi,
    As far as I can recall, Think City was designed in Norway by a Norwegian company, and produced in  Finland by Valmet Automotive in Uusikaupunki.
    Saab-Valmet was once upon a time founded by Valmet, a Finnish company and Saab which was a Swedish company.
     
       Mysil




    Yes, you are correct! I didn't know about any relationship to Saab, but Ford was involved for some time. There are some older Ford Thinks that are neighborhood electric vehicles that ran on lead-acid batteries. Those were more like golf carts-- total unable to go on a freeway. You can still find plenty of parts on the 2011 Think City's with FoMoCo embossed.
     
    All the 2011 Thinks in North America were partially manufactured at Valmet in Finland and then sent to a manufacturing facility in Elkhart, Indiana USA for installation of the drivetrain including the Li-ion battery made by EnerDel in Indianapolis, Indiana.
    #9
    1and0
    Access is Denied
    • Total Posts : 8337
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 15:10:16 (permalink)
    0
    whats going on around 82e ?

    Look like a lookup table
    #10
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 15:18:17 (permalink)
    0
    1and0
    Look like a lookup table

    Indeed.
    This looks like the data, with values decreasing from 0x05E5 to 0051
       1036 0816 05E5 DECF 0xE5, W, BANKED 
        1037 0818 05E5 DECF 0xE5, W, BANKED
        1038 081A 0479 DECF 0xF79, W, ACCESS
        1039 081C 03B1 MULWF 0xB1, BANKED
        1040 081E 0323 MULWF 0x23, BANKED
        1041 0820 02B3 MULWF TMR3H, ACCESS
        1042 0822 0253 MULWF 0x53, ACCESS
        1043 0824 01FD MOVLB 0xD
        1044 0826 01AB MOVLB 0xB
        1045 0828 015C MOVLB 0xC
        1046 082A 010B MOVLB 0xB
        1047 082C 00B4
        1048 082E 0051

    and this looks like the routine to access it (Note it adds 0x0816 to a variable value):
        1026 0802 6E17 MOVWF 0x17, ACCESS 
        1027 0804 0F16 ADDLW 0x16
        1028 0806 6EF6 MOVWF TBLPTR, ACCESS
        1029 0808 0E08 MOVLW 0x8
        1030 080A 6AF7 CLRF TBLPTRH, ACCESS
        1031 080C 22F7 ADDWFC TBLPTRH, F, ACCESS
        1032 080E 6AF8 CLRF TBLPTRU, ACCESS
        1033 0810 0008 TBLRD*
        1034 0812 50F5 MOVF TABLAT, W, ACCESS
        1035 0814 0012 RETURN 0


    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #11
    David
    Super Member
    • Total Posts : 1277
    • Reward points : 0
    • Joined: 2007/12/17 23:19:53
    • Location: uk sussex
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 16:34:14 (permalink)
    0
    part of a PM from John Mayer posted with his permission...
     
     
    That seems like a very simple question, and I would like to answer it, but there's quite a lot I'm going to need to do before I get to that point.
     
    The only development tool I have at this point is the PICkit3, and I'm connecting directly to the circuit board of a failed PTC heater. I don't have a car that I can install the heater into...
     
    The only task I have used the PICkit3 for is to pull the program memory from the chip, and it indicated that it did that successfully. I suppose I could try writing to the chip, but I'm not sure (1) what I would write to the chip or (2) how I would be able to test the chip afterward. (I suppose I could just clear the memory, verify that the memory is clear, write the same code back to it, read it back and verify that it's the same.
     
    I also have a few more failed PTC heaters that I could pull the code from and compare.
     
    But before I really get anything accomplished with this I'm going to have to invest in some more development tools. Eventually that will include all the electronic components of a car in such a way that I can monitor inputs, outputs and interactions between control modules and sensors.
     
    What I was really hoping for from this thread was learning to do for myself what you have posted as [ code], and preferably taking it to a higher level of abstraction to make sense of it more easily.

    David
    I support http://picforum.ric323.com because this forum is often too broken to use!
    #12
    1and0
    Access is Denied
    • Total Posts : 8337
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 20:31:57 (permalink)
    0

    This looks like the data, with values decreasing from 0x05E5 to 0051

    It's more like values from 0x05E5 to 0xFEFB (1509 to -261):
    1036 0816 05E5 DECF 0xe5, W, BANKED 
    1037 0818 05E5 DECF 0xe5, W, BANKED
    1038 081A 0479 DECF 0xf79, W, ACCESS
    1039 081C 03B1 MULWF 0xb1, BANKED
    1040 081E 0323 MULWF 0x23, BANKED
    1041 0820 02B3 MULWF TMR3H, ACCESS
    1042 0822 0253 MULWF 0x53, ACCESS
    1043 0824 01FD
    1044 0826 01AB
    1045 0828 015C
    1046 082A 010B MOVLB 0xb
    1047 082C 00B4
    1048 082E 0051
    1049 0830 FFD3 NOP
    1050 0832 FEFB NOP
    1051 0834 FEFB NOP
    1052 0836 FEFB NOP
    #13
    1and0
    Access is Denied
    • Total Posts : 8337
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 20:35:09 (permalink)
    +1 (1)
    What I was really hoping for from this thread was learning to do for myself what you have posted as [ code], and preferably taking it to a higher level of abstraction to make sense of it more easily.

    In MPLAB v8.92,

    1. Click Configue > Select Device and select PIC18F2480.
    2. Click File > Import and select .HEX file.
    3. Click View > Program Memory and select Symbolic tab.
    4. Right click in the Program Memory window and select Output To File.
    5. Enter a file name and click Save.

    That said, Google is your friend as there are PIC symbolic disassemblers out there. How good these disassemblers are is another matter.
    #14
    1and0
    Access is Denied
    • Total Posts : 8337
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/26 21:03:50 (permalink)
    0
    JorgeF
    And also a number of bit manipulations in sequence directly to the PORT registers, the original programmer was not too warried with the R-M-W risk.

    Look like the original programmer does not know about the LAT registers and the Fast Register Stack.
           5 0008 CFD8 MOVFF STATUS, 0x0 
    6 000A F000 NOP
    7 000C CFE0 MOVFF BSR, 0x1
    8 000E F001 NOP
    9 0010 6E02 MOVWF 0x2, ACCESS
    ; ...
    16 001E 5002 MOVF 0x2, W, ACCESS
    17 0020 C001 MOVFF 0x1, BSR
    18 0022 FFE0 NOP
    19 0024 C000 MOVFF 0x0, STATUS
    20 0026 FFD8 NOP
    21 0028 0010 RETFIE 0
    #15
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/27 02:46:49 (permalink)
    0
    Good job!! well done

    GENOVA :D :D ! GODO
    #16
    1and0
    Access is Denied
    • Total Posts : 8337
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/27 11:00:19 (permalink)
    0
    Something weird is going on here
     48 005E 6E7F MOVWF 0xF7F, ACCESS
    49 0060 507F MOVF 0xF7F, W, ACCESS
    50 0062 E00B BZ 0x7A
    51 0064 CF7F MOVFF 0xF7F, 0xF7F    ; 0xF7F is unimplemented on this PIC
    52 0066 FF7F NOP                   ; and why move it to itself ?
    53 0068 CF7F MOVFF 0xF7F, FSR0     ; and then move to FSR0L
    54 006A FFE9 NOP
    55 006C 6AEA CLRF FSR0H, ACCESS
    56 006E 50EF MOVF INDF0, W, ACCESS
    57 0070 DFDC RCALL 0x2A
    58 0072 2A7F INCF 0xF7F, F, ACCESS
    59 0074 2A7F INCF 0xF7F, F, ACCESS
    60 0076 067F DECF 0xF7F, F, ACCESS ; why increment twice and decrement once ?
    61 0078 D7F3 BRA 0x60
    62 007A 0012 RETURN 0

    as data memory location 0xF7F is unimplemented according to the PIC18F2480 datasheet.
    #17
    JorgeF
    Super Member
    • Total Posts : 3281
    • Reward points : 0
    • Joined: 2011/07/09 11:56:58
    • Location: PT/EU @ Third rock from the Sun
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/27 13:45:05 (permalink)
    0
    Hi
     
    Spoted a few curiousities in the code.
     
    After isolating the program entry point, the initialization sequence and the main loop

                     org 0x07e0
    ; ----- Program entry point -----
    Lbl_7e0:
     
    ; Initializations  ??????
        rcall Lbl_2b2   ; Init_I
        rcall Lbl_0ac   ; Init_II
        rcall Lbl_7d8  ; Init_III
     
                     org 0x07e6
    ; Main Loop
    Lbl_7e6:

        rcall Lbl_2dc   ; Routine_A
        rcall Lbl_6e8
        rcall Lbl_7cc
        clrwdt
        rcall Lbl_30c
        rcall Lbl_466
        clrwdt
        rcall Lbl_576
        rcall Lbl_4c6
        clrwdt
        rcall Lbl_224
        rcall Lbl_0c2
        clrwdt
        bra Lbl_7e6 ; goto Main Loop
     

    I went to look for the first initialization routine at address 0x02dc  different routines and found this stretch of code at address 0x02dc with  at least 3 a couple of peculiarities.

                       org 0x02dc
    ; ----- Routine_A
    Routine_A:
    Lbl_2dc:
        bcf RCON, IPEN, A ; Disable interrupt priorities
        bsf INTCON, PEIE, A ; Enable peripheral interrupts
        bsf INTCON, GIE, A ; Global enable interrupts
        btfsc Flag_019_7, A ; Var_019 bit 7    ; NOT INITIALIZED AT POR - RETAINED ON OTHER RESETS
        bra Lbl_2f4
     
    ; ??????   if (clock is not 500KHz internal) set clock 500KHz internal ????????
    ; Why not just set the desired clock config?
    ; Is this a redundant test or am I missing something?
     
        movlw Const_073
        andwf OSCCON, W, A
        xorlw Const_033
        bz Lbl_300 ; Flag_019_7 is 0 and clock is 500KHz internal
        movlw Const_033
        movwf OSCCON, A ; Set clock 500KHz internal
        bra Lbl_300
     
     ; ??????   if (clock is not 8MHz internal) set clock 8MHz internal ????????
    ; Same as before
     
    Lbl_2f4:
        movlw Const_073
        andwf OSCCON, W, A
        xorlw Const_073
        bz Lbl_300 ; Flag_019_7 is 1 and clock is internal 8MHz
        movlw Const_073
        movwf OSCCON, A ; Set clock internal 8MHz
     
                       org 0x0300
    Lbl_300:
    ; Config digital I/O direction
        movlw Const_02f
        movwf TRISA, A ; Set RA<5:0> as inputs / RA<7:6> External xtal oscilator ? To be checked
        movlw Const_0da
        movwf TRISB, A ; Set RB7, RB6, RB4, RB3, RB1 as inputs / Set RB5, RB2, RB0 as outputs
        clrf TRISC, A ; Set RC<7:0> as outputs
        return .0
    Routine_A_End:
     

    It looks like the original programmer believed that RAM will power up cleared or just forgot about its randomness at POR.
    RAM its initialized, I had just missed it. See next post by 1and0.
     
     
    EDIT ADD:
    Also noticed a dangerous approach in configuring pins as outputs (TRISx) before initialing them (PORTx) to a safe state.
    This lack of correct initializations might be related to the problems reported by the OP when a quick "ignition off" (*), "ignition on" sequence happens.
     
    (*) Using the term "ignition" when talking about an electric car feels a bit odd.
     
    EDIT:
    This routine is aclled at every cycle of the main loop.
     
    EDIT: Sorry I missed the correct initialization sequence, as 1and0 noticed (post bellow).
     
     
     
    Best regards
    Jorge
     
    post edited by JorgeF - 2018/05/27 15:12:33
    #18
    1and0
    Access is Denied
    • Total Posts : 8337
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/27 14:45:20 (permalink)
    0
    JorgeF
    It looks like the original programmer believed that RAM will power up cleared or just forgot about its randomness at POR.

    Clear RAM 0x000 to 0x2FF is located at code org 0x2B2.
     
    Edit:
    JorgeF
    Also noticed a dangerous approach in configuring pins as outputs (TRISx) before initialing them (PORTx) to a safe state.

    PORTx are initialized before TRISx at 0x2B2.
    post edited by 1and0 - 2018/05/27 14:54:29
    #19
    JorgeF
    Super Member
    • Total Posts : 3281
    • Reward points : 0
    • Joined: 2011/07/09 11:56:58
    • Location: PT/EU @ Third rock from the Sun
    • Status: offline
    Re: Disassembler / Decompiler 2018/05/27 15:01:03 (permalink)
    0
    Hi
    1and0
    JorgeF
    It looks like the original programmer believed that RAM will power up cleared or just forgot about its randomness at POR.

    Clear RAM 0x000 to 0x2FF is located at code org 0x2B2.
     
    Edit:
    JorgeF
    Also noticed a dangerous approach in configuring pins as outputs (TRISx) before initialing them (PORTx) to a safe state.

    PORTx are initialized before TRISx at 0x2B2.



    Hi
     
    Thank you 1and0.
    Just noticed it, while you were posting.
    Going to correcting my previous post.
     
     
    Best regards
    Jorge
     
     
    post edited by JorgeF - 2018/05/27 15:13:23
    #20
    Page: 1234 > Showing page 1 of 4
    Jump to:
    © 2018 APG vNext Commercial Version 4.5