Intel MCS48 User Manual page 29

Family of single chip microcomputers
Hide thumbs Also See for MCS48:
Table of Contents

Advertisement

INTRODUCTION
Decimal
Hex
Binary
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Our
machine
language
program
then
becomes:
Step
Hex Code
B8
1
20
2
BA
3
05
4
09
5
F0
6
18
7
EA
8
04
This
coding
is
now
quite
efficient to
write
and
read
and
coding
errors are
much
easier
to
detect.
Hex
coding
is
usually very
efficient for
small
programs
(a
few hundred
lines of
code).
However,
it
does have two
major
limitations
in
larger
programs:
1.
Hex
coding
is
not self-documenting,
that
is,
the
code
itself
does
not give
any
indication
in
human
terms
of
the operation
to
be
performed.
The
user
must
learn
each code
or
constantly
use
a
Program
Reference Card
to
convert.
2.
Hex
coding
is
absolute,
that
is,
the
program
will
work
only
when
stored
in
a
specific location
in
program memory.
This
is
because
the
branch
or
jump
instructions
in
the
program
reference
specific
addresses
elsewhere
in
the
program.
In
the
example
above
steps
7
and
8 reference step
(or
address)
4.
If
the
program were
to
be moved,
step 8
would
have
to
be
changed
to refer to
the
new
address
of
step
4.
1.2.2
Assembly Language Programming
Assembly
language
overcomes
the
dis-
advantages
of
machine
language by
allowing
the
use
of
alphanumeric symbols
to repre-
sent
machine
operation
codes,
branch
addresses,
and
other operands. For
example,
the
instruction to
increment
the contents of
register
becomes INC R0
instead
of
the
hex
18,
giving the
user
at
a glance the
meaning
of
the
instruction.
Our example program
can be
written
in
assembly language
as
follows:
Step No.
Hex Code
Assembly
Code
B8
1
20
2
BA
3
05
4
09
5
AO
6
18
7
EA
8
04
MOV
R0,
#32
MOV
R2,
#05
INP:
IN
A,
P1
MOV
@R0,
A
INC R0
DJNZ
R2,
INP
The
first
statement
can be
verbalized
as
follows:
Move
to
Register
the
decimal
number
32.
Move
instructions are
always
structured
such
that
the destination
is
first
and
the
source
is
second.
The pound
sign
"#"
indicates that the
source
is
"immediate" data
(data
contained
in
the following byte
of
program memory).
In
this
case
data
was
specified
as
a decimal
32,
however,
this
could
have been
written
as a
hex
20H
or a binary
0010
0000B
since the
assembler
will
accept
either
form. Notice also
that
in
this
instance
two
lines
of
hex
code
are
represented
by
one
line
of
assembly
code.
The
input instruction IN A,
P1
has
the
same
form
as a
MOV
instruction indicating that
the
contents
of Port
1
are
to
be
transferred to
the
accumulator.
In
front of
the input
instruction
is
an address
label
which
is
delineated
by
a
colon.
This
labe|
allows the
program
to
be
written
in
a
form independent
of
its
final
location
in
program
memory
since
the
branch
instruction
at
the
end
of
the
program
can
refer
to
this
label
rather
than a
specific
address. This
is
a very important
advantage
of
assembly language programs
since
it
1-11

Advertisement

Table of Contents
loading

Table of Contents