Доброе время суток!
Помогите плиз перевести код программы с Ассемблера на С.Заранее благодарю.
Код
; PROCESSOR DECLARATION
;------------------------------------------------------------------------------
LIST P=PIC18F26K20 ; list directive to define processor
#INCLUDE <P18F26K20.INC> ; processor specific variable definitions
;------------------------------------------------------------------------------
; CONFIGURATION WORD SETUP
;------------------------------------------------------------------------------
;Setup CONFIG11H
CONFIG FOSC = INTIO67, FCMEN = OFF, IESO = OFF
;Setup CONFIG2L
CONFIG PWRT = ON, BOREN = OFF, BORV = 18
;Setup CONFIG2H
CONFIG WDTEN = OFF, WDTPS = 1
;Setup CONFIG3H
CONFIG MCLRE = ON, HFOFST = OFF, LPT1OSC = OFF, PBADEN = OFF
;Setup CONFIG4L
CONFIG CCP2MX = PORTBE, STVREN = OFF, LVP = OFF, XINST = OFF, DEBUG = OFF
;Setup CONFIG5L
CONFIG CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
;Setup CONFIG5H
CONFIG CPB = OFF, CPD = OFF
;Setup CONFIG6L
CONFIG EBTR0 = OFF
;Setup CONFIG6H
CONFIG EBTR1 = OFF
;Setup CONFIG7L
CONFIG EBTR2 = OFF
;Setup CONFIG7H
CONFIG EBTR3 = OFF
;------------------------------------------------------------------------------
; VARIABLE DEFINITIONS
;------------------------------------------------------------------------------
W_TEMP EQU 0x0000 ; w register for context saving (ACCESS)
STATUS_TEMP EQU 0x0001 ; status used for context saving
BSR_TEMP EQU 0x0002; bank select used for ISR context saving
TMR1_l EQU 0x0060
TMR1_h EQU 0x0061
TMR1_u EQU 0x0062
RT_TEMP EQU 0x0063
ITERATOR EQU 0x0064
PROGRAM_4 EQU 0x0065
PROGRAM_2 EQU 0x0066
PROGRAM_1 EQU 0x0067
PORT_ON EQU 0x0068
PORT_OFF EQU 0x0069
PORT_4Hz EQU 0x006A
PORT_2Hz EQU 0x006B
PORT_1Hz EQU 0x006C
PORT_TEMP EQU 0x006D
;------------------------------------------------------------------------------
; RESET VECTOR
;------------------------------------------------------------------------------
RES_VECT
ORG 0x0000 ; processor reset vector
goto start ; go to beginning of program
;------------------------------------------------------------------------------
; HIGH PRIORITY INTERRUPT VECTOR
;------------------------------------------------------------------------------
ISRH
ORG 0x0008
goto HIGH_ISR ; Run the High Priority Interrupt Service Routine
;------------------------------------------------------------------------------
; LOW PRIORITY INTERRUPT VECTOR
;------------------------------------------------------------------------------
ISRL
ORG 0x0018
goto LOW_ISR ; Run the Low Priority Interrupt Service Routine
;------------------------------------------------------------------------------
ORG 0x0020
READ_TABLE:
movwf RT_TEMP
rlncf RT_TEMP,0
addwf PCL, 1
TABLE_PROGRAMM
nop
retlw b'11111111'
retlw b'01010101'
retlw b'00010001'
;------------------------------------------------------------------------------
; HIGH PRIORITY INTERRUPT SERVICE ROUTINE
;------------------------------------------------------------------------------
HIGH_ISR
; Context Saving for High ISR
movwf W_TEMP ; save W register
movff STATUS, STATUS_TEMP; save status register
movff BSR, BSR_TEMP ; save bankselect register
; Insert High Priority ISR Here
btfsc PIR1, TMR1IF ; TMR1 interrupt?
call TMR1_Interrupt ; YES
; Restore Context for High ISR
movf W_TEMP, 0 ; restore W register
movff STATUS_TEMP, STATUS; restore status register
movff BSR_TEMP, BSR ; restore bank select register
retfie
;------------------------------------------------------------------------------
; LOW PRIORITY INTERRUPT SERVICE ROUTINE
;------------------------------------------------------------------------------
LOW_ISR
; Context Saving for Low ISR
movwf W_TEMP ; save W register
movff STATUS, STATUS_TEMP; save status register
movff BSR, BSR_TEMP ; save bankselect register
; Insert Low Priority ISR Here
; Context Saving for Low ISR
movwf W_TEMP ; save W register
movff STATUS, STATUS_TEMP; save status register
movff BSR, BSR_TEMP ; save bankselect register
retfie
;------------------------------------------------------------------------------
; MAIN PROGRAM
;------------------------------------------------------------------------------
start
clrf PORTB
clrf TRISB ; PORTB,0-7 - out
clrf PORT_TEMP
call GET_PROGRAM
call GET_VALUE_PORT_DEFAULT
call TIMER1_Init
call GET_PRESCALER_FOR_TMR1
bsf RCON, IPEN ; Enable priority levels on interrupts
bsf INTCON, GIE ; Enable interrupts
MAIN
goto MAIN
;------------------------------------------------------------------------------
GET_PROGRAM ;Reading program
lfsr FSR0, PROGRAM_1
movlw 0x03
movwf ITERATOR
READ_TABLE_PROGRAMM
movf ITERATOR,0
call READ_TABLE
movwf POSTDEC0
decfsz ITERATOR,1
bra READ_TABLE_PROGRAMM
return
;------------------------------------------------------------------------------
GET_VALUE_PORT_DEFAULT
movlw b'10000000' ;PORTB 7 - ON
movwf PORT_ON
movlw b'00010000' ;PORTB 4 - OFF
movwf PORT_OFF
movlw b'00100011' ;PORTB 0,1,5 - 1Hz
movwf PORT_1Hz
movlw b'00001000' ;PORTB 3 - 2Hz
movwf PORT_2Hz
movlw b'01000100' ;PORTB 2,6 - 4Hz
movwf PORT_4Hz
return
;------------------------------------------------------------------------------
TIMER1_Init
movlw 0x80 ; Preload TMR1 register pair
movwf TMR1H
clrf TMR1L
movlw b'00001001' ; Configure for internal clock,
movwf T1CON ; Asynchronous operation, Internal oscillator
bsf PIE1, TMR1IE ; Enable Timer1 interrupt
bsf IPR1, TMR1IP ; Timer1 High priority
return
;------------------------------------------------------------------------------
GET_PRESCALER_FOR_TMR1
movlw 0x01
movwf TMR1_l
movlw 0x00
movwf TMR1_h
movlw 0x00
movwf TMR1_u
return
;------------------------------------------------------------------------------
TMR1_Interrupt
bcf PIR1, TMR1IF ; clear TMR1 Overflow Interrupt Flag bit
dcfsnz TMR1_l, 1
return
dcfsnz TMR1_h, 1
return
dcfsnz TMR1_u, 1
return
call GET_PRESCALER_FOR_TMR1
call SET_VALUE_PORT_USING_PROGRAM
return
;------------------------------------------------------------------------------
SET_VALUE_PORT_USING_PROGRAM
;PORT_TEMP='xxxxxxxx'
movf PORT_ON, 0 ;PORT_ON= '10000000'
iorwf PORT_TEMP, 1 ;PORT_TEMP='1xxxxxxx'
comf PORT_OFF, 0 ;PORT_OFF= '00010000'
andwf PORT_TEMP, 1 ;PORT_TEMP='1xx0xxxx'
lfsr FSR0, PROGRAM_1
lfsr FSR1, PORT_1Hz
movlw 0x03
movwf ITERATOR
READ_PROGRAMM
movf POSTDEC1, 0
btfsc INDF0, 0
xorwf PORT_TEMP, 1 ;PORT_TEMP='1ii0iiiii'
rrncf POSTDEC0, 1
decfsz ITERATOR,1
bra READ_PROGRAMM
movf PORT_TEMP, 0
movwf PORTB
return
;------------------------------------------------------------------------------
END