- 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: dc.l 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: dc.l 10
will next reserve 4 consecutive
bytes
of memory
to store an int (= whole number)
value 10
(because we use .l for
long word (= 4 bytes))
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 4 bytes are reserved
001006 00 by the directive: dc.l 10
001007 0A (00 00 00 0A Hex = 10 decimal !!)
|
Important notes:
- Following the
A: ds.l 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
1008
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 4 bytes are reserved
001006 00 by the directive dc.l 10
001007 0A and init with value 10 (0A Hex = 10 Dec)
001008 1200 move.b d0, d1 (1200 (hex) is the code
00100A 1200 move.b d0, d1 for "move.b d0, d1" !)
|
The instruction code for first
move.b d0, d1 is
stored at
address 1008 Hex
(Remember the next available memory cell
for storing
instructions
and variables is located at the
address 1008 Hex)
The instruction code for second
move.b d0, d1 is
stored at
address 100A Hex
because the
instruction code (1210 Hex) is
2 bytes long ----
(1008 (Hex) + 2 (Hex) = 100A (Hex))
|