Since people are getting interested in assembly, I thought I'd post up some topics on assembly basics. I'm not an assembly expert but I've done some assembly on different processors so hopefully I can get the discussion going.

Eventually I hope to get a bunch of these topics posted, with hyperlinks going between all of them, ie when I talk about the memory map below, it would link to the 68HC11's 68HC11MemoryMap.

My first topic is addressing modes. My next topic is going to be about 68HC11Registers, so when I talk about registers, don't worry, I'm going to explain them soon.

Hopefully we all know what the LDAA instruction does, it loads a number into the accumulator 'A'.

Now, it takes an argument of what number goes into the accumulator register.

How does it decide what number goes in there? The addressing mode.

= Summary of Addressing Modes =

The 68HC11 has the following modes:

  • Immediate
  • Extended
  • Direct
  • Indexed
  • Inherent
  • Relative

= Immediate =

For a LDAA instruction I believe it can only use the first 4 (can someone confirm/deny?).

Immediate means that the value is contained in the opcode, and is indicated with the # (pound, hash, number) sign.

So, to load the hex value 12 into the A accumulator, you would write

LDAA #$12

The $ sign means it's a hex number.

= Extended =

Extended accesses memory in the 68HC11's memory map. Remember that this could be something stored in the PROM, or it could be another chip in the ECU like a A/D convertor.

Let's say that there is something located at memory address $DEAD (remember we're working in hex, so ABCDEF are numbers).

We would say

LDAA $DEAD

and that would grab whatever value is in memory location $DEAD and store it in the accumulator.

= Extended =

Direct addressing is similar to extended. It can only access memory locations $00 to $FF, but it is faster.

LDAA $00

I think this is how it is done but I don't remember exactly. Can anyone confirm?

= Indexed =

Indexed addressing uses the X and Y registers as an index, and you can specify a range from this index.

For example, you would set up the X register to have the value $1000 in it. Then you can access memory by doing this:

LDAA 0,X

This would load A with the value in the memory location $1000.

LDAA $10,X

This would load A with the value in memory location $1010. This has a range of one byte, 0 to 255 or $0 to $FF.

= Inherent =

Inherent means that it already knows about the addresses that it will be using. This is not a valid mode for the LDAA instruction. It would be used for something like

DECA

which means decrement the accumulator A. Decrement means subtract 1 from it.

Note how there's no address or anything here.

= Relative =

Relative means that the address is an offset from somewhere. This is only used in 68HC11Branching|branching? instructions. Ie BRA $10 would skip 16 instructions ahead in the program.

= Questions Go Here =

= Helpful Links Go Here =

-- AlexHarford - 30 Jun 2006

Topic revision: r1 - 30 Jun 2006 - 22:45:41 - AlexHarford
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback