Mod 22
Mod 22
EA = X + [Ri]
ADD 20(R1), R2
R1=1000
EA= 20+1000=1020
Indexing and Arrays
In general, the Index mode facilitates access to an operand
whose location is defined relative to a reference point within
the data structure in which the operand appears.
Several variations of index mode:
Relative Address
0
EA = PC + Relative Addr 1
PC = 2 2
100
AR = 100
101
102 1 1 0 A
Could be Positive or 103
Negative 104
(2’s Complement)
Additional Modes
Autoincrement mode – the effective address of the operand is the contents of a
register specified in the instruction. After accessing the operand, the contents of
this register are automatically incremented to point to the next item in a list.
(Ri)+. The increment is 1 for byte-sized operands, 2 for 16-bit operands, and 4
for 32-bit operands.
Autodecrement mode: -(Ri) – Contents of the register specified in the instruction
is decrement first and then used as the effective address of the operand
Move N,R1
Move #NUM1,R2 Initialization
Clear R0
LOOP Add (R2)+,R0
Decrement R1
Branch>0 LOOP
Move R0,SUM
Figure 2.16. The Autoincrement addressing mode used in the program of Figure 2.12.
Addressing Modes
Name Assembler syntax Addressing
function
The different
ways in which Immediate #Value Operand= Value
the location of
an operand is Register Ri EA = Ri
specified in Absolute(Direct) LOC EA = LOC
an instruction
are referred to Indirect (R i ) EA = [Ri ]
as addressing (LOC) EA = [LOC]
modes.
Index X(R i) EA = [Ri ]+ X
Autodecrement (R i ) Decrement R i ;
EA = [Ri]
Assembly Language
Assembly Language
A Complete set of mnemonics (symbolic names) and rules for
their use constitute a programming language, referred to as an
Assembly Language.
The set of rules for using mnemonics in the specification of
object program.
Assembler Directives:
• These are the instructions given to the assembler while it
translates a source program to object program.
• These are not converted into object program.
• Some of the assembler directives are : EQU, ORIGIN,
DATAWORD
Assembler Directives:
EQU(equate):
This is used to define a constant value or a fixed address.
The EQU directive does not set aside storage for a data item,
ORIGIN:
The origin directive tells the assembler where to load
DATAWORD:
This directive is used to load a value into the memory location.
RESERVE :
This directive is used to reserve a memory block for data and
program is to begin
END
Tells the assembler that this is the end of the source program.
Assembly and Execution of programs
Instruction
Format:
Label Operation Operand(s) Comment
Loader:
The loader is a system software program that loads the object
program from magnetic disc to the memory of a computer.
Debugger:
This is another system software program that detects and
reports the syntax errors to the user.
Number Notation
A decimal number is directly represented as
ADD #93,R1
A binary number is identified by a prefix symbol %(percent
sign)
ADD #%01011101,R1
A hexadecimal number is identified by a prefix symbol $(dollar
sign)
ADD #$5D,R1