It's OK to ask about Assembly language questions, especially when it's in the General category like you've posted it.

Originally Posted by
quentin
Hi
For some reason I am unable to write to PCL when simulating the most basic code in MPLAB.
A computed goto should also set PCLATH before changing PCL.
In your case, PCLATH has not been set, and when you add 10h to PCL, instead of jumping forward 16 addresses (0x0121), it will jump to (0x0021) which is in the middle of the bootloader.
But when simulating it in MPLAB, there is no bootloader, so that range of addresses is outside the range of compiled code.
Still not sure what you want to do ... a computed goto or a Table lookup, but if it's the latter, this might help ...
Code:
list p = 16f877a
include <p16f877a.inc>
;******Vectors***********************************
org 0x0100 ;reset vector address
goto Main
org 0x0110 ; start writing program from this address
;******Main Program******************************
Main
movlw high(table)
movwf PCLATH
movlw 010h
call table
goto Main
table
addwf PCL,f
retlw .0
retlw .1
retlw .2
retlw .3
retlw .4
retlw .5
retlw .6
retlw .7
retlw .8
retlw .9
retlw .10
retlw .11
retlw .12
retlw .13
retlw .14
retlw .15
retlw .16
retlw .17
retlw .18
retlw .19
retlw .20
retlw .21
retlw .22
end
Bookmarks