ARCHITECTURE AND INSTRUCTIONS
6)
Indirect
through
base register plus index
register:
MOV
MOV
MOV
MOV
AX,(BX)
AX,(BX)
AX,(BP)
AX,(BP)
(SI)
(01)
(SI)
(01)
7) Indirect
through
base
or
index register
plus offset:
1000UP(?)
Mav
AX,MAN'LBYTES(BX)
MaV
AX,MANY_BYTES(BP)
MaV
AX,MANY_BYTES(SI)
MaV
AX,MANY_BYTES(OI)
8) Indirect
through
base register plus
index
register plus offset:
1000UP(?)
Mav
AX,MANY_BYTES(BX) (SI)
MaV
AX,MANY_BYTES(BX) (01)
MaV
AX,MANY_BYTES(BP) (SI)
MaV
AX,MANY_BYTES(BP) (01)
The
assembler uses its knowledge
about
a
memory
location's type when generating
instructions
that
reference
that
memory
location.
For
example, the assembler gen-
erates a byte-increment when encountering
the
following:
SUM
OB
? ;type is BYTE
INC SUM
;a
byte increment
However, with indirect operand-addressing
modes, it
is
not always possible for the
2-39
assembler
to
know the type
of
the memory
location, as illustrated
by:
MOV
AL,(BX)
Even though the assembler does not know
the type
of
the source operand
in
the above
instruction, it does know that the type
of
the
destination operand, AL,
is
BYTE.
So
the
assembler
assumes
that
(BX) is
also
of
type
BYTE
and
generates
a
byte-move
instruction.
But now consider the statement:
INC
(BX)
There
is
no
second memory location here
to
help the assembler determine the type
of
(BX). So the assembler cannot decide whether
to
generate
a
byte-increment
instruc-
tion
or
a word-increment instruction. The
above statement must therefore be written as
shown so the assembler can determine
the
type:
INC BYTE PTR (BX)
;a
byte-increment
or
INC WORD PTR (BX)
;a
word-increment
STRING INSTRUCTIONS
The assembler can usually discern the type
of
an
operand from its declaration,
and
hence
know what kind
of
code
to
generate for
accessing
that
operand.
However, we have just seen that, when using
an
indirect-addressing mode, we might have
to
supply the assembler with additional
information so it can determine the type.
String Primitives
String instructions also need such additional
information. Consider the string instruction
MOVS.
This instruction moves the con4:nts
of
the
memory address whose offset
is
in
SI
into the
memory address whose offset is in DI. We
should
not
need
to
specify
any
operands,
since
the
instruction has no choice as
to
which items to move
and
where.