- Suppose we are write
an assembler program.
- We must store the
instructions and
variables in
memory (RAM)....
|
Suppose we start
storing the instructions and
variables at
memory address
1000 Hex
- Consider the
following assembler program:
move.b d0, d1 <----- X
move.b d0, d1
A: ds.b 10
move.b d0, d1 <----- Y
move.b d0, d1
|
I will now explain what
each line of the
assembler program does....
- The assembler line
move.b d0, d1
(at arrow X) will store the
instruction code for
move.b d0, d1 into
memory
- When you store
some instruction code in
memory, the
used memory cells are
also (automatically)
reserved !!!
|
Given that
the instruction code for
move.b d0, d1 is
1200 Hex
(= 00010010 00000000 binary),
the first 2 lines
of the assembler program will
store the following
in memory (RAM):
Address Content What is stored Explanation
========================================================================
001000 1200 move.b d0, d1 (1200 (hex) is the code
001002 1200 move.b d0, d1 for "move.b d0, d1" !)
|
The instruction code for first
move.b d0, d1 is
stored at
address 1000 Hex
(Remember that we assumed that
we start storing
instructions and variables at the
address 1000 Hex)
The instruction code for second
move.b d0, d1 is
stored at
address 1002 Hex
because the
instruction code (1200 Hex) is
2 bytes long
- The directive
A: ds.b 10
will next reserve 10 consecutive
bytes
of memory
After processing the
assembler directive,
content of the
memory (RAM) is:
(in Hex)
Address Content What is stored Explanation
========================================================================
001000 1200 move.b d0, d1 (1200 (hex) is the code
001002 1200 move.b d0, d1 for "move.b d0, d1" !)
001004 00
001005 00
001006 00
001007 00 10 bytes are reserved
001008 00 by the directive:
001009 00
00100A 00 A: ds.b 10
00100B 00
00100C 00
00100D 00
|
Important node:
- The
label
A is
equated (= equal to)
the value 001004 Hex
which
is the
address of the
first reserve byte
|
- Following the
A: ds.b 10 line,
we have 2 more assembler lines
move.b d0, d1
(at arrow Y)
Just like at arrow X,
each line will store the
instruction code for
move.b d0, d1 into
memory
The move.b d0, d1
at array Y will be
stored in the
next available memory cell,
which is at address
100E
So after processing the
the next 2 lines,
the following things are
stored
in memory (RAM):
Address Content What is stored Explanation
========================================================================
001000 1200 move.b d0, d1 (1200 (hex) is the code
001002 1200 move.b d0, d1 for "move.b d0, d1" !)
001004 00
001005 00
001006 00
001007 00 10 bytes are reserved
001008 00 by the directive:
001009 00
00100A 00 A: ds.b 10
00100B 00
00100C 00
00100D 00
00100E 1200 move.b d0, d1 (1200 (hex) is the code
001010 1200 move.b d0, d1 for "move.b d0, d1" !)
|
The instruction code for first
move.b d0, d1 is
stored at
address 100E Hex
(Remember the next available memory cell
for storing
instructions
and variables is located at the
address 100E Hex)
The instruction code for second
move.b d0, d1 is
stored at
address 1010 Hex
because the
instruction code (1210 Hex) is
2 bytes long ----
(100E (Hex) + 2 (Hex) = 1010 (Hex))
|