glenjoy
Joined: 01 Jan 2004 Posts: 1028 Helped: 47 Location: Philippines
|
09 Aug 2005 20:12 pic 16f628 disassembler |
|
|
|
|
This is the code I want to convert,
| Code: |
; Generated by WinDis84, (c) Nigel Goodwin 1998.
LIST P=16F84, F=INHX8M
include "P16FXX.inc"
ORG 0x0000
MOVLW 0x00
MOVWF PCLATH
GOTO Label_0001
NOP
Label_0016 MOVLW 0x21
MOVWF FSR
MOVF INDF , W
BTFSC STATUS , Z
GOTO Label_0002
Label_0006 MOVLW 0x01
MOVWF 0x0D
Label_0004 CLRF 0x0C
Label_0003 DECFSZ 0x0C , f
GOTO Label_0003
DECFSZ 0x0D , f
GOTO Label_0004
MOVLW 0x4A
MOVWF 0x0C
Label_0005 DECFSZ 0x0C , f
GOTO Label_0005
NOP
NOP
DECFSZ INDF , f
GOTO Label_0006
Label_0002 RETLW 0x00
Label_0018 MOVLW 0x08
MOVWF 0x0C
BSF STATUS , RP0
BSF TRISB , 04
BCF STATUS , RP0
Label_0007 BTFSC PORTB , 04
GOTO Label_0007
CLRF 0x21
BSF 0x0C , 07
GOTO Label_0008
Label_000C BCF 0x0C , 07
GOTO Label_0008
Label_0009 BCF STATUS , C
RRF 0x21 , f
BTFSC PORTB , 04
BSF 0x21 , 07
BSF 0x0C , 06
GOTO Label_0008
Label_000D BCF 0x0C , 06
DECFSZ 0x0C , f
GOTO Label_0009
BSF 0x0C , 05
GOTO Label_0008
Label_000E BCF 0x0C , 05
MOVF 0x21 , W
MOVWF 0x0D
GOTO Label_000A
Label_0008 MOVLW 0x1C
BTFSC 0x0C , 07
MOVLW 0x07
MOVWF 0x0D
Label_000B DECFSZ 0x0D , f
GOTO Label_000B
NOP
BTFSC 0x0C , 07
GOTO Label_000C
BTFSC 0x0C , 06
GOTO Label_000D
BTFSC 0x0C , 05
GOTO Label_000E
GOTO Label_0009
Label_000A RETLW 0x00
Label_0025 CLRF 0x23
BSF STATUS , RP0
BCF TRISB , 05
BCF STATUS , RP0
BCF PORTB , 05
MOVLW 0x08
MOVWF 0x0D
NOP
NOP
NOP
BSF 0x0D , 07
GOTO Label_000F
Label_0012 BCF 0x0D , 07
Label_0010 MOVF 0x22 , W
XORWF 0x23 , f
RRF 0x22 , f
BTFSC STATUS , C
BSF PORTB , 05
BTFSS STATUS , C
BCF PORTB , 05
BSF 0x0D , 06
GOTO Label_000F
Label_0013 BCF 0x0D , 06
DECFSZ 0x0D , f
GOTO Label_0010
NOP
NOP
NOP
BTFSS 0x23 , 00
BSF PORTB , 05
BTFSC 0x23 , 00
BCF PORTB , 05
BSF 0x0D , 05
GOTO Label_000F
Label_0014 BCF 0x0D , 05
BSF PORTB , 05
GOTO Label_000F
Label_000F MOVLW 0x1C
MOVWF FSR
Label_0011 DECFSZ FSR , f
GOTO Label_0011
NOP
BTFSC 0x0D , 07
GOTO Label_0012
BTFSC 0x0D , 06
GOTO Label_0013
BTFSC 0x0D , 05
GOTO Label_0014
GOTO Label_0015
Label_0001 CLRF FSR
MOVLW 0x1F
ANDWF STATUS , f
BSF STATUS , RP0
BCF TRISB , 05
BCF STATUS , RP0
BSF PORTB , 05
MOVLW 0x1F
MOVWF 0x0E
MOVLW 0x48
MOVWF 0x0F
CLRF 0x10
MOVLW 0x4E
MOVWF 0x11
CLRF 0x12
MOVLW 0x02
MOVWF 0x13
MOVLW 0x01
MOVWF 0x14
MOVLW 0x1F
MOVWF 0x15
CLRF 0x16
MOVLW 0x48
MOVWF 0x17
MOVLW 0x7F
MOVWF 0x18
CLRF 0x19
CLRF 0x1A
CLRF 0x1B
BSF STATUS , RP0
BCF TRISB , 05
BCF STATUS , RP0
BSF PORTB , 05
MOVLW 0x01
MOVWF 0x21
CALL Label_0016
BSF PORTA , 01
BSF STATUS , RP0
BCF TRISA , 01
BCF STATUS , RP0
BSF PORTA , 03
BSF STATUS , RP0
BCF TRISA , 03
BCF STATUS , RP0
BSF PORTA , 02
BSF STATUS , RP0
BCF TRISA , 02
BCF STATUS , RP0
Label_0027 CLRF 0x1B
Label_001B MOVLW 0x07
SUBWF 0x1B , W
BTFSC STATUS , C
GOTO Label_0017
CALL Label_0018
MOVF 0x0D , W
MOVWF 0x1C
MOVLW 0x0E
ADDWF 0x1B , W
MOVWF FSR
MOVF INDF , W
SUBWF 0x1C , W
BTFSS STATUS , Z
GOTO Label_0019
INCF 0x1B , f
GOTO Label_001A
Label_0019 CLRF 0x1B
Label_001A GOTO Label_001B
Label_0017 CALL Label_0018
MOVF 0x0D , W
MOVWF 0x1D
CALL Label_0018
MOVF 0x0D , W
MOVWF 0x1E
CALL Label_0018
MOVF 0x0D , W
MOVWF 0x1F
MOVLW 0x08
MOVWF 0x21
CALL Label_0016
MOVF 0x1D , W
ANDLW 0x01
IORLW 0x00
BTFSS STATUS , Z
GOTO Label_001C
BCF PORTA , 01
GOTO Label_001D
Label_001C BSF PORTA , 01
Label_001D BSF STATUS , RP0
BCF TRISA , 01
BCF STATUS , RP0
MOVF 0x1D , W
ANDLW 0x02
IORLW 0x00
BTFSS STATUS , Z
GOTO Label_001E
BCF PORTA , 03
GOTO Label_001F
Label_001E BSF PORTA , 03
Label_001F BSF STATUS , RP0
BCF TRISA , 03
BCF STATUS , RP0
MOVF 0x1D , W
ANDLW 0x04
IORLW 0x00
BTFSS STATUS , Z
GOTO Label_0020
BCF PORTA , 02
GOTO Label_0021
Label_0020 BSF PORTA , 02
Label_0021 BSF STATUS , RP0
BCF TRISA , 02
BCF STATUS , RP0
MOVF 0x1E , W
MOVWF 0x19
CLRF 0x20
CLRF 0x1B
Label_0023 MOVLW 0x05
SUBWF 0x1B , W
BTFSC STATUS , C
GOTO Label_0022
MOVLW 0x15
ADDWF 0x1B , W
MOVWF FSR
MOVF INDF , W
XORWF 0x20 , f
INCF 0x1B , f
GOTO Label_0023
Label_0022 MOVF 0x20 , W
MOVWF 0x1A
CLRF 0x1B
Label_0026 MOVLW 0x06
SUBWF 0x1B , W
BTFSC STATUS , C
GOTO Label_0024
MOVLW 0x15
ADDWF 0x1B , W
MOVWF FSR
MOVF INDF , W
MOVWF 0x21
MOVWF 0x22
GOTO Label_0025
Label_0015 INCF 0x1B , f
GOTO Label_0026
Label_0024 BSF STATUS , RP0
BCF TRISB , 05
BCF STATUS , RP0
BSF PORTB , 05
GOTO Label_0027
SLEEP
ORG 0x2000
DATA 0x0F
DATA 0x0F
DATA 0x0F
DATA 0x0F
ORG 0x2007
DATA 0x19
ORG 0x2100
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
DATA 0xFF
END |
This is from the site of http://www.atrox.at/datacable/.
I am think if there is a possibility to convert the code into PIC16F628 to avoid the crystal oscillator.
I already tried changing the configuration bits, it runs but very unstable.
|
|
Buriedcode
Joined: 06 May 2004 Posts: 327 Helped: 34 Location: London
|
18 Aug 2005 5:16 pic16f628 disassembler |
|
|
|
|
My two cents...
When I migrate from the F84, to any higher-end micros, I nearly always have to change the start of the variables registers (cblock, if used). The F84 I believe starts at 0x0C, but because many 'newer' micros have more peripherals, the have many more peripheral control registers. Hence, the genral purpose registers start at a higher address, say, 0x20.
| Quote: |
Label_0006 MOVLW 0x01
MOVWF 0x0D
Label_0004 CLRF 0x0C
Label_0003 DECFSZ 0x0C |
Disassemblers never know the names people have given to registers, obviously, and here the addresses 0x0C, and 0x0D are used. Assuming these are used as general prupose registers in the original 16F84 context, in the 628, 0x0C is the 'PIR1' register, (peripheral interupt), and 0x0D is 'unimplemented'. Meaning, the program is inadvertantly changing the settings of the peripherals, and reading the registers wrong.
I would write a small piece of code to disable all the special features of the 628 (that the F84 doesn't have) and any file registers that are modified should have their addresses moved up. , by a minimum, of 14h (add 20 decimal).
ie: 0Ch -> 20h
0Dh -> 21h etc..
I don't know if you knew this already, or if it will solve your problem. Mike had a great point. If you want to convert it to run on 4Mhz, instead of 8, its gonna be tough.
Good Luck,
BuriedCode
|
|