Код, который вы разместили, работает так, как вы хотите.
То, что вы, похоже, упустили, - это все дополнительные вещи, необходимые для нормальной работы PIC18F458.
Это ваш код, который работает в симуляторе MPLAB:
;
; Filename: main.asm
; Author: dan1138
; Target: PIC18F458
; Assembler: MPASMWIN v5.22
; Assembler mode: Absolute
;
; Files required: p18f458.inc
;
; Description:
;
; Increment a BCD value in the PORTB output latch register.
;
list P=18F458, r=dec, n=0, c=255
#include "p18f458.inc"
;
; Setup configuration words
config OSC = HS
config BOR = OFF
config BORV = 45
config PWRT = OFF
config WDTPS = 128
config WDT = OFF
config STVR = ON
config LVP = OFF
config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
config CPD = OFF, CPB = OFF
config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF
config WRTD = OFF, WRTB = OFF, WRTC = OFF
config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF
config EBTRB = OFF
;
; /* Specify the System clock frequency in Hz */
#define FSYS 10000000
; /* Specify the Peripheral clock frequency in Hz */
#define FCYC (FSYS/4)
;
; Power On Reset entry point
org 0
goto start
;
; Interrupt Service Routine entry point
org 0x08
ISR_vevtor:
retfie 1
;
; Declare application RAM in access bank
cblock 0x07
R1:1
R2:1
R3:1
R4:1
endc
;
; Main application start
start:
clrf INTCON ; Disable all interrupts
movlw 0x07
movwf ADCON1 ; Make ADC analog inputs digital I/O pins
movlw 0x07
movwf CMCON ; Make comparator analog inputs digital I/O pins
;
; Main application loop
CLRF TRISB ; Make PORTB pins digital output
MOVLW 00H
MOVWF R1 ; Set RAM location R1 to zero, don't know why.
MOVLW 00H ; Load WREG with initial BCD value
REP1:
MOVWF LATB ; Write the WREG to PORTB outputs
CALL DELAY ; Wait for about one second with a 10MHz system clock
INCF LATB,W ; Increment output latch, put result in the WREG
DAW ; Adjust the value in WREG to be BCD
GOTO REP1 ; Do it again.
DELAY:
MOVLW D'20' ; Delay for about one second.
MOVWF R4 ; You figure out how it works.
BACK:
MOVLW D'100'
MOVWF R3
AGAIN:
MOVLW D'250'
MOVWF R2
HERE:
NOP
NOP
DECF R2,F
BNZ HERE
DECF R3,F
BNZ AGAIN
DECF R4,F
BNZ BACK
RETURN
end