Reply by Edward Karpicz December 7, 20052005-12-07
David,

It's hard to remember all sizes of all instructions with IDX,IDX1 and IDX2
addressing modes. Plus some smart assemblers are automatically choosing the
best (shortest) form of IDX,IDX1,IDX2 when possible. I don't want to guess
would be -*-3,pc valid here or maybe -*-4,pc? Thats why I'm suggesting to
avoid "jsr subroutine-*-3,pc" and use maybe more ugly but IMO easier to
maintain:

jsr subroutine - next_instruction,pc
next_instruction:

Of course this makes sense only for those assemblers where ,pcr notation
isn't implemented.

Edward
From: "David Kelly" <dkelly@
Sent: Wednesday, December 07, 2005 4:55 PM

> On Wed, Dec 07, 2005 at 11:17:58AM +0200, Edward Karpicz wrote:
>> Try replacing
>>
>> > jsr subroutine,pcr
>>
>> by
>>
>> jsr subroutine-L1,pc
>> L1:
>>
>>
>> You can do the same for
>> > jmp [<InterruptVectorName>-$800,pcr]
>>
>> jmp [<InterruptVectorName>-$800-L2, pc]
>> L2:
>>
>> and for all other ,pcr lines except for MOVB and MOVW with ,pcr
>> addressing.
>
> I haven't been playing with HC12 assemblers but in some assemblers "*"
> is taken as the current PC address. If memory serves others may use "@"
> or ".". This could save the effort of defining a label after the
> instruction. Use something like "jsr subroutine-*-3,pc" adjusting for
> the size of the current instruction and argument.
>
> --
> David Kelly N4HHE, dkelly@dkel...
> ========================================================================
> Whom computers would destroy, they must first drive mad.


Reply by David Kelly December 7, 20052005-12-07
On Wed, Dec 07, 2005 at 11:17:58AM +0200, Edward Karpicz wrote:
> Try replacing
>
> > jsr subroutine,pcr
>
> by
>
> jsr subroutine-L1,pc
> L1: > You can do the same for
> > jmp [<InterruptVectorName>-$800,pcr]
>
> jmp [<InterruptVectorName>-$800-L2, pc]
> L2:
>
> and for all other ,pcr lines except for MOVB and MOVW with ,pcr
> addressing.

I haven't been playing with HC12 assemblers but in some assemblers "*"
is taken as the current PC address. If memory serves others may use "@"
or ".". This could save the effort of defining a label after the
instruction. Use something like "jsr subroutine-*-3,pc" adjusting for
the size of the current instruction and argument.

--
David Kelly N4HHE, dkelly@dkel...
========================================================================
Whom computers would destroy, they must first drive mad.



Reply by Edward Karpicz December 7, 20052005-12-07
> Thanks Edward for your information about movb and movw.
>
> And what about leax const-L,pc instead of leax const,pcr ? Is that right ?

Yes

> And for instructions like instr=ldab,ldx,dec,stab..., how could I replace
> instr
> var,pcr ?

The same way

LDAB xx-L1,pc
L1:
LDX yy-L2,pc
L2:
.... Edward >> > To be complete,
>> >
>> > I have to :
>> > - create a label L after each jsr instruction and write
>> > jsr subroutine-L,pc (or replace L by (*+offset) to point to next
>> > instruction)
>>
>> Exactly. Converted code will have a number of unique labels, for example
>> L1,L2,...
>>
>> CPU calculates PC relative target address by taking address of next
>> opcode
>> and adding to it specified offset. So the label at next instruction is
>> quite
>> easy and quite safe way to substitute ,pcr . But there is exception with
>> MOVB, MOVW's on older HC12s. Please read the docs of old CPU12 to find
>> the
>> difference. CPU12 was sometimes taking address from the middle of
>> instruction. S12 handles PC relative MOVs differently.
>>
>> Edward
>>
>>
>>
>> > - for
>> > leax const,pcr
>> > write
>> > leax const-L,pc ?
>> >
>> > - for
>> > const: fcb ...
>> > ...
>> > leax const,pcr
>> > write
>> > leax const-L,pc ?
>> > L:...
>> >
>> > - for instructions like instr=ldab,ldx,dec,stab...
>> > instr var,pcr
>> > write
>> > instr ???,pc
>> >
>> >
>> >
>> >>
>> >> Try replacing
>> >>
>> >> > jsr subroutine,pcr
>> >>
>> >> by
>> >>
>> >> jsr subroutine-L1,pc
>> >> L1:
>> >>
>> >>
>> >> You can do the same for
>> >> > jmp [<InterruptVectorName>-$800,pcr]
>> >>
>> >> jmp [<InterruptVectorName>-$800-L2, pc]
>> >> L2:
>> >>
>> >> and for all other ,pcr lines except for MOVB and MOVW with ,pcr
>> > addressing.
>> >>
>> >>
>> >> Edward
>> >>
>> >>
>> >> ----- Original Message -----
>> >> From: "yann_37" <y.sevin@f...>
>> >> To: <68HC12@68HC...>
>> >> Sent: Wednesday, December 07, 2005 10:50 AM
>> >> Subject: [68HC12] Bootloader for reprogramming Flash EEPROM
>> >>
>> >>
>> >> > Hello,
>> >> >
>> >> > I'm new with HC12.
>> >> > I'm trying to adapt the code found in application note AN1718
>> >> > (Serial Bootloader for Reprogramming the MC68HC912B32 Flash
>> > EEPROM)
>> >> > for a 912DT128A. The beggining of the program copies a part of
>> > the
>> >> > code from Flash to RAM and run it then.
>> >> > This code contains a "pcr" mnemonic (Program Counter Relative)
>> > but I
>> >> > don't really understand how it works. Has anybody used it ?
>> >> > How is this "pcr" initialized or updated ?
>> >> >
>> >> > If my assembler doesn't accept it, the note explains that I can
>> >> > replace for example
>> >> > jmp [<InterruptVectorName>-$800,pcr]
>> >> > by
>> >> > jmp [<InterruptVectorName>-$800-(*+4),pc]
>> >> > Farther in the code, there are some
>> >> > jsr subroutine,pcr
>> >> > How could I replace it ?
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > Yahoo! Groups Links
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
> >
> Yahoo! Groups Links >




Reply by y.se...@... December 7, 20052005-12-07
Thanks Edward for your information about movb and movw.

And what about leax const-L,pc instead of leax const,pcr ? Is that right ?
And for instructions like instr=ldab,ldx,dec,stab..., how could I replace instr
var,pcr ?
> > To be complete,
> >
> > I have to :
> > - create a label L after each jsr instruction and write
> > jsr subroutine-L,pc (or replace L by (*+offset) to point to next
> > instruction)
>
> Exactly. Converted code will have a number of unique labels, for example
> L1,L2,...
>
> CPU calculates PC relative target address by taking address of next opcode
> and adding to it specified offset. So the label at next instruction is quite
> easy and quite safe way to substitute ,pcr . But there is exception with
> MOVB, MOVW's on older HC12s. Please read the docs of old CPU12 to find the
> difference. CPU12 was sometimes taking address from the middle of
> instruction. S12 handles PC relative MOVs differently.
>
> Edward >
> > - for
> > leax const,pcr
> > write
> > leax const-L,pc ?
> >
> > - for
> > const: fcb ...
> > ...
> > leax const,pcr
> > write
> > leax const-L,pc ?
> > L:...
> >
> > - for instructions like instr=ldab,ldx,dec,stab...
> > instr var,pcr
> > write
> > instr ???,pc
> >
> >
> >
> >>
> >> Try replacing
> >>
> >> > jsr subroutine,pcr
> >>
> >> by
> >>
> >> jsr subroutine-L1,pc
> >> L1:
> >>
> >>
> >> You can do the same for
> >> > jmp [<InterruptVectorName>-$800,pcr]
> >>
> >> jmp [<InterruptVectorName>-$800-L2, pc]
> >> L2:
> >>
> >> and for all other ,pcr lines except for MOVB and MOVW with ,pcr
> > addressing.
> >>
> >>
> >> Edward
> >>
> >>
> >> ----- Original Message -----
> >> From: "yann_37" <y.sevin@f...>
> >> To: <68HC12@68HC...>
> >> Sent: Wednesday, December 07, 2005 10:50 AM
> >> Subject: [68HC12] Bootloader for reprogramming Flash EEPROM
> >>
> >>
> >> > Hello,
> >> >
> >> > I'm new with HC12.
> >> > I'm trying to adapt the code found in application note AN1718
> >> > (Serial Bootloader for Reprogramming the MC68HC912B32 Flash
> > EEPROM)
> >> > for a 912DT128A. The beggining of the program copies a part of
> > the
> >> > code from Flash to RAM and run it then.
> >> > This code contains a "pcr" mnemonic (Program Counter Relative)
> > but I
> >> > don't really understand how it works. Has anybody used it ?
> >> > How is this "pcr" initialized or updated ?
> >> >
> >> > If my assembler doesn't accept it, the note explains that I can
> >> > replace for example
> >> > jmp [<InterruptVectorName>-$800,pcr]
> >> > by
> >> > jmp [<InterruptVectorName>-$800-(*+4),pc]
> >> > Farther in the code, there are some
> >> > jsr subroutine,pcr
> >> > How could I replace it ?
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> > Yahoo! Groups Links >
>


Reply by Edward Karpicz December 7, 20052005-12-07
> To be complete,
>
> I have to :
> - create a label L after each jsr instruction and write
> jsr subroutine-L,pc (or replace L by (*+offset) to point to next
> instruction)

Exactly. Converted code will have a number of unique labels, for example
L1,L2,...

CPU calculates PC relative target address by taking address of next opcode
and adding to it specified offset. So the label at next instruction is quite
easy and quite safe way to substitute ,pcr . But there is exception with
MOVB, MOVW's on older HC12s. Please read the docs of old CPU12 to find the
difference. CPU12 was sometimes taking address from the middle of
instruction. S12 handles PC relative MOVs differently.

Edward
> - for
> leax const,pcr
> write
> leax const-L,pc ?
>
> - for
> const: fcb ...
> ...
> leax const,pcr
> write
> leax const-L,pc ?
> L:...
>
> - for instructions like instr=ldab,ldx,dec,stab...
> instr var,pcr
> write
> instr ???,pc >
>>
>> Try replacing
>>
>> > jsr subroutine,pcr
>>
>> by
>>
>> jsr subroutine-L1,pc
>> L1:
>>
>>
>> You can do the same for
>> > jmp [<InterruptVectorName>-$800,pcr]
>>
>> jmp [<InterruptVectorName>-$800-L2, pc]
>> L2:
>>
>> and for all other ,pcr lines except for MOVB and MOVW with ,pcr
> addressing.
>>
>>
>> Edward
>>
>>
>> ----- Original Message -----
>> From: "yann_37" <y.sevin@f...>
>> To: <68HC12@68HC...>
>> Sent: Wednesday, December 07, 2005 10:50 AM
>> Subject: [68HC12] Bootloader for reprogramming Flash EEPROM
>>
>>
>> > Hello,
>> >
>> > I'm new with HC12.
>> > I'm trying to adapt the code found in application note AN1718
>> > (Serial Bootloader for Reprogramming the MC68HC912B32 Flash
> EEPROM)
>> > for a 912DT128A. The beggining of the program copies a part of
> the
>> > code from Flash to RAM and run it then.
>> > This code contains a "pcr" mnemonic (Program Counter Relative)
> but I
>> > don't really understand how it works. Has anybody used it ?
>> > How is this "pcr" initialized or updated ?
>> >
>> > If my assembler doesn't accept it, the note explains that I can
>> > replace for example
>> > jmp [<InterruptVectorName>-$800,pcr]
>> > by
>> > jmp [<InterruptVectorName>-$800-(*+4),pc]
>> > Farther in the code, there are some
>> > jsr subroutine,pcr
>> > How could I replace it ?
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>> >
>> >
> > Yahoo! Groups Links >




Reply by yann_37 December 7, 20052005-12-07
To be complete,

I have to :
- create a label L after each jsr instruction and write
jsr subroutine-L,pc (or replace L by (*+offset) to point to next
instruction)
- for
leax const,pcr
write
leax const-L,pc ?

- for
const: fcb ...
...
leax const,pcr
write
leax const-L,pc ?
L:...

- for instructions like instr=ldab,ldx,dec,stab...
instr var,pcr
write
instr ???,pc
>
> Try replacing
>
> > jsr subroutine,pcr
>
> by
>
> jsr subroutine-L1,pc
> L1: > You can do the same for
> > jmp [<InterruptVectorName>-$800,pcr]
>
> jmp [<InterruptVectorName>-$800-L2, pc]
> L2:
>
> and for all other ,pcr lines except for MOVB and MOVW with ,pcr
addressing.
>
>
> Edward > ----- Original Message -----
> From: "yann_37" <y.sevin@f...>
> To: <68HC12@68HC...>
> Sent: Wednesday, December 07, 2005 10:50 AM
> Subject: [68HC12] Bootloader for reprogramming Flash EEPROM > > Hello,
> >
> > I'm new with HC12.
> > I'm trying to adapt the code found in application note AN1718
> > (Serial Bootloader for Reprogramming the MC68HC912B32 Flash
EEPROM)
> > for a 912DT128A. The beggining of the program copies a part of
the
> > code from Flash to RAM and run it then.
> > This code contains a "pcr" mnemonic (Program Counter Relative)
but I
> > don't really understand how it works. Has anybody used it ?
> > How is this "pcr" initialized or updated ?
> >
> > If my assembler doesn't accept it, the note explains that I can
> > replace for example
> > jmp [<InterruptVectorName>-$800,pcr]
> > by
> > jmp [<InterruptVectorName>-$800-(*+4),pc]
> > Farther in the code, there are some
> > jsr subroutine,pcr
> > How could I replace it ?
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>




Reply by yann_37 December 7, 20052005-12-07
Thanks for this information, but I know that routines are different.
My problem is only about "pcr". >
> At 08:50 07/12/2005 +0000, you wrote:
> >I'm trying to adapt the code found in application note AN1718
> >(Serial Bootloader for Reprogramming the MC68HC912B32 Flash
EEPROM)
> >for a 912DT128A.
>
> The MC68HC912B32 and MC68HC912DT128A different flash technologies.
> Using the low level Flash erase and programming routines is
different on
> these two parts - so you will likely need to completely change
these
> low-level routines
>
> Doron
> Nohau
> HC12 In-Circuit Emulators
> www.nohau.com/emul12pc.html >
>




Reply by Edward Karpicz December 7, 20052005-12-07
Try replacing

> jsr subroutine,pcr

by

jsr subroutine-L1,pc
L1: You can do the same for
> jmp [<InterruptVectorName>-$800,pcr]

jmp [<InterruptVectorName>-$800-L2, pc]
L2:

and for all other ,pcr lines except for MOVB and MOVW with ,pcr addressing. Edward ----- Original Message -----
From: "yann_37" <y...@y.se...>
To: <68HC12@68HC...>
Sent: Wednesday, December 07, 2005 10:50 AM
Subject: [68HC12] Bootloader for reprogramming Flash EEPROM > Hello,
>
> I'm new with HC12.
> I'm trying to adapt the code found in application note AN1718
> (Serial Bootloader for Reprogramming the MC68HC912B32 Flash EEPROM)
> for a 912DT128A. The beggining of the program copies a part of the
> code from Flash to RAM and run it then.
> This code contains a "pcr" mnemonic (Program Counter Relative) but I
> don't really understand how it works. Has anybody used it ?
> How is this "pcr" initialized or updated ?
>
> If my assembler doesn't accept it, the note explains that I can
> replace for example
> jmp [<InterruptVectorName>-$800,pcr]
> by
> jmp [<InterruptVectorName>-$800-(*+4),pc]
> Farther in the code, there are some
> jsr subroutine,pcr
> How could I replace it ? > Yahoo! Groups Links >



Reply by Doron Fael December 7, 20052005-12-07
At 08:50 07/12/2005 +0000, you wrote:
>I'm trying to adapt the code found in application note AN1718
>(Serial Bootloader for Reprogramming the MC68HC912B32 Flash EEPROM)
>for a 912DT128A.

The MC68HC912B32 and MC68HC912DT128A different flash technologies.
Using the low level Flash erase and programming routines is different on
these two parts - so you will likely need to completely change these
low-level routines

Doron
Nohau
HC12 In-Circuit Emulators
www.nohau.com/emul12pc.html


Reply by yann_37 December 7, 20052005-12-07
Hello,

I'm new with HC12.
I'm trying to adapt the code found in application note AN1718
(Serial Bootloader for Reprogramming the MC68HC912B32 Flash EEPROM)
for a 912DT128A. The beggining of the program copies a part of the
code from Flash to RAM and run it then.
This code contains a "pcr" mnemonic (Program Counter Relative) but I
don't really understand how it works. Has anybody used it ?
How is this "pcr" initialized or updated ?

If my assembler doesn't accept it, the note explains that I can
replace for example
jmp [<InterruptVectorName>-$800,pcr]
by
jmp [<InterruptVectorName>-$800-(*+4),pc]
Farther in the code, there are some
jsr subroutine,pcr
How could I replace it ?