Intel MCS48 User Manual page 28

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

Advertisement

INTRODUCTION
1.2
Programming
a
Microcomputer
1.2.1
Machine Language Programming
A
microprocessor
is
instructed
what
to
do
by
programming
it
with a
series of instructions
stored
in
Program Memory.
The
processor
fetches these
instructions
one
at
a time
and
performs
the operation
indicated.
These
instructions
must
be
stored
in
a
form
that
the
processor can understand. This format
is
referred to
as
Machine
Language. For most
microprocessors
this
instruction
is
a
group
of
8 binary
bits (1's
and
O's)
called
a
word
(also called
a byte
if
the
word
is
8-bits).
Some
instructions require
more
than
one
location
in
Program Memory.
To
execute a
multi-byte
instruction,
the
processor
must
execute
multiple fetches of
program
memory
before
performing
the
instruction.
Because
multi-
byte
instructions
take
more Program
Mem-
ory
and
take longer
to
execute than
single
byte
instructions
their
use
is
usually kept to
a
minimum.
A
processor
may
be
programmed
by
writing
a
sequence
of instructions
in
the
binary
code
(ones
and
zeros)
which
the
machine
can
interpret
directly.
This
is
machine
language
programming and
it
is
very useful
where
the
program
to
be
written
is
small
and
the application requires
that
the
designer
have an
intimate
knowledge
of
the microprocessor.
Machine
language
pro-
gramming
allows the
user,
because
of his
detailed
knowledge,
to
use
many
program-
ming
"tricks" to
produce
the
most compact
and
efficient
code
possible.
The
following
is
an
example
of
a
machine
language program:
This
program
reads 5
sequential
8-bit
words
in
from an
I/O port
and
stores
them
sequentially
in
data
memory. The program
starts
by
initializing
two
registers,
one which
determines
where
the data
is
to
be
stored
and
another which
counts
the
number
of
words
to
be
stored.
When
finished the
processor continues
on
to
the next
instructions.
Step
Machine
Number
Code
Explanation
1011
1000
Load
decimal 32
in
1
0010 0000
register
R0
2
1011
1010
Load
decimal
5
in
3
0000
0101
register
R2
4
0000
1001
Load
Port
1
to
accu-
mulator
5
1010 0000
Transfer contents
of
accumulator
to reg-
ister
addressed
by
register
6
0001 1000
Increment
R0
by
1
7
1110 1010
Decrement
register
2
8
0000 0100
by
1,
if
result
is
zero
continue
to
step
9,
if
not
go
to
step
4
9
10
As you
can
see, writing
machine
instruc-
tions
in
ones and
zeros
can be
very
laborious
and
subject
to
error.
It
is
almost
always
more
efficient to
represent
each
8-bits of
machine
language
code
in
a
shorthand
format
called
Hexadecimal.
The
term
hexadecimal
results
from
the
character
set
used
in
hexadecimal
notation.
Hexadecimal
is
merely an extension
of
the
normal decimal
numbers
by
the addition
of
the
first
six letters of
the alphabet. This
gives a
total
of
1
6
different
characters.
Each
hexadecimal
"digit"
can
represent
16
values or the equivalent
of
four binary
bits;
therefore,
each
8-bit
machine
language
word
can be represented by
2
hexadecimal
(hex
for short)
digits.
The
correspondence
among
the
decimal,
binary,
and
hex
number
systems
is
given below:
1-10

Advertisement

Table of Contents
loading

Table of Contents