It's to be run on a PIC16F628A (with 2 x 8-bit ports). All it's meant to do is just turn the bits of each pin on in groups of 2. Have I gotten this right or am I barking up the wrong tree?
Your code should look something more like this (assuming you're using MPLAB with the MPASM assembler):
Code:
include "P16F628A.INC"
__config _INTOSC_OSC_NOCLKOUT & _WDT_OFF & _LVP_OFF
cblock 0x20 ;start of general purpose registers
d1
endc
org 0x000
banksel TRISA ;bank 1
clrf TRISA
clrf TRISB
banksel PORTA ;bank 0
START movlw b'00000011'
movwf PORTA
call delay
movlw b'00001100'
movwf PORTA
call delay
movlw b'00110000'
movwf PORTA
call delay
movlw b'11000000'
movwf PORTA
call delay
movlw b'00000000'
movwf PORTA
call delay
movlw b'00000011'
movwf PORTB
call delay
movlw b'00001100'
movwf PORTB
call delay
movlw b'00110000'
movwf PORTB
call delay
movlw b'11000000'
movwf PORTB
call delay
movlw b'00000000'
movwf PORTB
call delay
goto START
delay movlw 0xff
movwf d1
del decfsz d1,f
goto del
return
end
0. You need to include P16F628A.inc so you can use the proper names for registers instead of confusing numbers. Use PORTA instead of 05h. Much clearer that way. Who wants to constantly be looking up numbers to see what register they are? Assembler is hard enough to read without purposely making it even more cryptic.
1. The config line assumes that you're using the internal oscillator.
2. The cblock lets you set up a block of variables in RAM. It's much clearer to use a variable name than the actual address number of the RAM byte you're using.
3. I like to use the banksel directive to do my bank changes, rather than (again) using numbers that I have to look up and are error prone. Easier to read.
4. It's just personal preference, but I
HATE all-uppercase code. Horribly unreadable.
5. Another personal preference thing is using (for instance) 0x3f instead of 3fh, as you you were doing. Using the h suffix is legal though, so do it if you prefer.
6. On lines like "del decfsz d1,f", use f/w instead of 0/1. Use f to store the result back in the register, and w to store the result in W. Once again, it's much clearer what you're doing. The equates for these are in the INC file.
7. You need an end statement at the end of the program. This tells the assembler to stop assembling there.