I think it is working correctly. I can't comment on the warning that
the assembler is generating since I can't reproduce it in MPLAB 6.1.
I looked at the opcode generation in a few test cases and it appears
that the address in the opcode is the address in 16-bit words, not in
bytes. Note that 0x1FF * 2 = 0x3FE. For example, if you write GOTO
0x004, MPASM generates EF02 F000, which goes to address 2. The data
sheet doesn't seem to mention this, but it can be deduced from the fact
that the PIC18 series has a 2 MB address space for program memory, but
the goto instruction only uses 20 bits, enough for 1 MB. The program
memory is still normally addressed in bytes so that the TBLRD and TBLWT
instructions can read and write individual bytes of program memory,
instead of being limited to word boundary operations. Anyway,
everything is working as you want it to.
Daniel Imfeld
On Saturday, March 08, 2003 5:50 PM, John Nall <spam_OUTjnall01TakeThisOuT
ALLTEL.NET>
wrote:
{Quote hidden}> Could someone explain to me why the following code produces a warning,
> and the address in the goto at address 0 is 1FF rather than 3FE?? I
> feel like it has to do with banks, but don't understand what I have to
> do to make it work. (Disclaimer: I'm new at this, but I'm working
> hard and reading the FM into the wee hours of the morning. And I
> know about the interrupt address and all that -- this only purpose of
> the code is to test the 20-bit address for the goto).
>
> LOC OBJECT CODE LINE SOURCE TEXT
> VALUE
>
> 00001 LIST P=18F452, F=INHX32
> 00002 #include <p18f452.inc>
>
> 0000 00004 org 0x00
> Warning [202] : Argument out of range. Least significant bits used.
> 0000 EFFF F001 00005 goto MyStart
> 03FE 00006 org 0x3fe
> 03FE 00007 MyStart:
> 03FE 6AE8 00008 clrf WREG
> 0400 6E82 00009 movwf PORTC
> 0402 6E94 00010 movwf TRISC
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads