Home

Addressing Modes

Addressing Modes

 

 

Addressing Modes

As well as hardware for executing instructions, a processor needs hardware to access data. Principally, hardware is needed to read and write data to and from registers and memory. The capabilities of the accessing hardware are reflected in the processor’s instruction set in the so-called addressing modes. Hence, the term ‘addressing modes’ refers to the allowable ways in which the processor instructions can refer to data. CISC processors tend to have many different addressing modes whilst RISC processors tend to have a very small number of addressing modes. In this lecture, we will introduce the three fundamental addressing modes on the 68000: immediate, absolute and indirect. We will also look at some variations of the immediate and direct modes.

Learning Outcomes:
On completion of this lecture, you will be able to:

  • Distinguish between immediate, direct and indirect addressing modes;
  • Select an appropriate  addressing mode for a given instruction;
  • Implement the following addressing modes: immediate, quick immediate, data register direct, address register direct, absolute memory long, absolute memory short and address register indirect.

 

7.1     Categories of addressing modes

You select an appropriate addressing mode for a piece of data depending on how much you know about the data item itself when you’re writing the program:

  • If you know the value of the data, use an ‘Immediate Addressing Mode,’ signified by a # sign.
  • If you know the location of the data, use a ‘Direct Addressing Mode.’
  • If you know how to calculate the location of the data or how to calculate the data itself, use an ‘Indirect Addressing Mode.’

 

 

Level of Knowledge of Data

 

Kind of Addressing Mode

 

Value can be known at assembly time

Immediate Mode
(Immediate Values are sometimes called ‘Literals’)

 

Location can be known at assembly time

 

Direct Mode

 

Location or value can be calculated at run time

 

Indirect Mode

 

The 68000 has fourteen addressing modes and we will look at eleven of them through the course:

  • Two immediate modes;
  • Four direct modes;
  • Five indirect modes;
  • The remaining three are a special case of the indirect modes.

 

7.2      Immediate Addressing Modes

We have already encountered immediate addressing in which the actual operand is supplied with the instruction. We will describe two types of immediate addressing modes: immediate and quick immediate.

7.2.1   Immediate

  • Specify the operand as a byte, word or longword item. All sensible values permitted of 8, 16 or 32 bits as appropriate.
  • Only values known at assembly time allowed e.g.

#21,
#$60FA,
#$12234-$24
#(567*$ab)-’x’

  • These are not permissible as immediate operands:

#61+D0
#$74+(A4)
Why?

 

      • Quick Immediate Instructions

Some instructions and operands occur very frequently in the instruction execution stream, and some of these are speeded up by making the instruction shorter:

  • MOVE has a MOVEQ;
  • ADD and SUB have ADDQ and SUBQ.

Each of these instructions expects a ‘quick immediate’ operand with a restricted range of values.

MOVEQ (Move Quick):

  • Allows eight bits to represent the immediate data.
  • The destination must be a data register.
  • The eight bit data is sign-extended to fill all 32 bits of the data register.

ADDQ and SUBQ (Add and Subtract Quick)

  • Allows three bits to represent the immediate data, which is mapped to the values 1 to 8 (not 0 to 7!)
  • Size of the operation can be specified to byte, word, long
  • The destination is not restricted to be a data register.
  • The three bit data is sign-extended to fill the size of the operation specified.
    • Direct Addressing modes

 

If the Operand is in a Register (‘Register Direct’) you can use:

  • Data Register Direct
  • Address Register Direct

If the Operand is in Memory (‘Memory Direct’) you may use:

  • Absolute Memory Short
  • Absolute Memory Long
      • Register Direct
  • Just specify the register on its own, no brackets or anything. E.g. A4, D3
  • Address Register Direct An
  • Data Register Direct Dn
      • Memory Direct

Memory Direct modes are used to specify where an operand is in memory.

  • Just specify the memory location ‘directly,’ e.g.

21,
$12FA,
$6534-21+’a’

  • Notice the syntactic (i.e. grammatical) difference between immediate and direct: what is it?

Address Space
The 68000 processor family, being a fully 32-bit family, has a 32-bit address space (i.e. 232 distinct byte locations in memory.)
The 68000 itself only uses 24 bits of the available address space. This is a hardware restriction of the 68000 itself. To write portable code, write for a 32-bit address space.

Two Memory Direct Modes
For reasons that are perhaps partly historical and partly speed motivated, the 68000 has:

  • a 16-bit direct addressing mode called Absolute Memory Short along with
  • a 32-bit direct addressing mode called Absolute Memory Long

A 16-bit address is an address represented by only 16 bits, thus only 216 (i.e. 65536) distinct locations can be specified.

Absolute Memory Long

  • This is just the memory referencing addressing mode you would expect in a 32-bit machine. You can specify any address in the 32-bit address space, e.g.

$f0463047,
$1048-21+’a’
etc.

  • As with immediate modes, you can use any expression that may be evaluated at assembly time as an absolute memory reference.
  • The address is represented in the instruction as a 32-bit item.

Absolute Memory Short
To save space in an instruction, an abbreviated address can be stored in 16 bits. It is sign-extended to the full 32 bits when needed. This means the range of addresses is limited to:
$00000000 – $00007FFF, $FFFF8000 – $FFFFFFFF, i.e. the bottom 32768 and the top 32768 of addresses in the full 32-bit address space
Because it is only 16 bits, the instruction of which it is part is fetched faster.

    • Address Register Indirect

 

We will look at five indirect addressing modes in the course, but now we’ll just look at one -- ‘Address Register Indirect.’ You can make up the functionality of most the other indirect addressing modes from this; they are provided for convenience and speed.

Motivation for Indirection

  • To use a number as an address;
  • In other words, to be able to calculate the location of something, and then, crucially, to be able to use it as an address and reference something with it.

The 68000 has eight address registers, A0 to A7, which are exploited in the address register indirect addressing. In this indirect addressing mode, the address of an operand is found in an address register, rather than in the instruction. Address register indirect is indicated to the assembler by enclosing an address register in round parentheses.
e.g: CLR (A0) means: clear the contents of the memory location whose address is the contents of address register (A0).
To access an operand two accesses must be made: the first is to the address register to find the actual address of the operand and the second is to the operand itself.
Since the registers are on the chip along with the CPU, little time is lost reading their contents to locate the operand in memory.

 

    • Conclusion

Addressing modes are concerned with how an operand is located by the CPU.
Immediate addressing, also known as literal addressing, allows you to specify a constant as an operand: the value following the instruction op-code is the actual operand itself. In 68000 assembly language, the symbol # precedes the operand to indicate immediate addressing. Immediate addressing is used whenever the value of the operand is known at the time the program is written.
In direct, also called absolute, addressing the operand field of the instruction provides the address of the operand in memory. Direct addressing is used whenever the address of a variable is constant.
Address register indirect addressing uses an address register to point at the location of an operand in memory. This addressing mode is indicated to the 68000 assembler by enclosing the address register in round parentheses.

 

REFERENCES

  • A. Clements; Addressing Modes, In: 68000 Family Assembly Language; pp. 99-105; PWS Publishing Company; 1994.
  • Dr. Mike Brady, Microprocessor Systems 1, dept. of Computer Science, Trinity College Dublin: http://www.tcd.ie/Engineering/Courses/BAI/JS_Subjects/3D1/.
  • Stephen J Kuyath, UNCC, 2007: http://www.coe.uncc.edu/~sjkuyath/MC68000/am1.htm.
  • Look on the Web at http://www.mee.tcd.ie/~assambc/3D1.

 

Source: http://www.mee.tcd.ie/~assambc/3d1_l07n.doc

Web site to visit: http://www.mee.tcd.ie

Author of the text: indicated on the source document of the above text

If you are the author of the text above and you not agree to share your knowledge for teaching, research, scholarship (for fair use as indicated in the United States copyrigh low) please send us an e-mail and we will remove your text quickly. Fair use is a limitation and exception to the exclusive right granted by copyright law to the author of a creative work. In United States copyright law, fair use is a doctrine that permits limited use of copyrighted material without acquiring permission from the rights holders. Examples of fair use include commentary, search engines, criticism, news reporting, research, teaching, library archiving and scholarship. It provides for the legal, unlicensed citation or incorporation of copyrighted material in another author's work under a four-factor balancing test. (source: http://en.wikipedia.org/wiki/Fair_use)

The information of medicine and health contained in the site are of a general nature and purpose which is purely informative and for this reason may not replace in any case, the council of a doctor or a qualified entity legally to the profession.

 

Addressing Modes

 

The texts are the property of their respective authors and we thank them for giving us the opportunity to share for free to students, teachers and users of the Web their texts will used only for illustrative educational and scientific purposes only.

All the information in our site are given for nonprofit educational purposes

 

Addressing Modes

 

 

Topics and Home
Contacts
Term of use, cookies e privacy

 

Addressing Modes