Porting HC11 code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Porting HC11 code

2,128 Views
JohnnyP
Contributor III
For HC11, LDX = #RegBase = $1000
Then use indirect X to address registers

So, this goes away, and I just delete the ",x" from my HC11 code, when accessing the registers?

For registers on page 0, ok, direct addressing, but what about the registers beyond page 0? Do you have to switch to extended?

HC11 variables were on page 0 and used direct addressing, but now the labels will start at $0800. Will I need to change anything, or will the assembler take care of it?
Labels (1)
0 Kudos
4 Replies

618 Views
blood
Contributor III
What I did when porting HC11 code was to move the registers. In the 9s12e256 you can set the registers to any 2K address space in the bottom half of the address map by writing to the INITRG register in your startup routine.
That way you dont have to worry about code that was useing variables with direct addressing.
0 Kudos

618 Views
Steve
NXP Employee
NXP Employee
What is the target MCU - S12?
HC11 does not have indirect addressing so I assume you mean indexed addressing in which case you are doing something like LDAA PORTA_OFFSET,X. Typically, you do this to save some code space because the instruction is smaller than an extended load: LDAA PORTA
 
Depending on how the registers are defined you can access them using indexed or extended mode. There are extra indexed modes on the S12 so you can keep indexed mode if you wish. It may be easier just to convert all the register accesses to extended mode
The assembly code will normally use the appropriate addressing mode unless direct addressing mode is forced in which case you will get an error. In other words LDAA PORT will use direct addressing mode if PORT is in direct space and extended if not.
I recommend that you read the S12 CPU manual appendix on the changes from HC11 because there are other differences that for example affect instruction timing and stack operation that may impact your code. This may also be a good time to look at converting the code to C.
If you are using the S12X CPU then there are other considerations.
0 Kudos

617 Views
JohnnyP
Contributor III
Steve:

Yes, the target is the 9S12C32.

To minimize code changes, would it be best/ok for me to set x = $0000 and continue using indexed x addressing?

My HC11 assembly code is 1150 lines, 1600 bytes, running on the secured version of the 811E2.

These are now nearly imposible to get. I have 30 on order at $36 ea.

The CW IDE is so different from my Mac based HC11 tools. arrrrrgggg. I just want to type assembly code and get it to the target.

I can't see learning C in time to keep alive. In your opinion, what is the most Mac-like tool for me to get? Right now, I'm spinning my wheels just getting started, and I'm running out of HC11 based product.

Pics of new product, in various stages of design.
http://www.jandssafeguard.com/8channel_pics/
0 Kudos

618 Views
Steve
NXP Employee
NXP Employee
Since the C32 registers take up more than 256 bytes it's most efficient to use extended addressing to access them; so removing the ,X would be the best solution. You can probably do this quickly in an editor and you'll have to review the register names & functionality anyway. That way you should also get direct addressing for many of the registers.
I don't know what tool would be most mac-like. People used to develop for the mac in CodeWarrior so it may be the best option. The debug environment for the S12 is much better than the HC11 so it is worthwhile investing some time to get to know the tools.
0 Kudos