Information Technology Reference
In-Depth Information
TABLE 3.3 Simple Machine Language Program in
Hexadecimal (Example 1)
Memory location
(bytes)
Hex instruction
000
100C
002
3000
004
100E
006
5000
008
2010
00A
0000
00C
015E
00E
0060
010
0000
lists the contents of the memory locations. For example, the contents of location 0 is
an instruction with opcode: 0001, and operand address: 0000 0000 1100. Please note
that in the case of operations that do not require operand, the operand portion of the
instruction is shown as zeros. The program is expected to be stored in the indicated
memory locations starting at location 0 during execution. If the program will be
stored at different memory locations, the addresses in some of the instructions
need to be updated to reflect the new locations.
It is clear that programs written in binary code are very difficult to understand
and, of course, to debug. Representing the instructions in hexadecimal will reduce
the number of digits to only four per instruction. Table 3.3 shows the same program
in hexadecimal.
3.2. INSTRUCTION MNEMONICS AND SYNTAX
Assembly language is the symbolic form of machine language. Assembly programs
are written with short abbreviations called mnemonics. A mnemonic is an abbrevi-
ation that represents the actual machine instruction. Assembly language program-
ming is the writing of machine instructions in mnemonic form, where each
machine instruction (binary or hex value) is replaced by a mnemonic. Clearly the
use of mnemonics is more meaningful than that of hex or binary values, which
would make programming at this low level easier and more manageable.
An assembly program consists of a sequence of assembly statements, where
statements are written one per line. Each line of an assembly program is split into
the following four fields: label, operation code (opcode), operand, and comments.
Figure 3.2 shows the four-column format of an assembly instruction.
Labels are used to provide symbolic names for memory addresses. A label is an
identifier that can be used on a program line in order to branch to the labeled line. It
can also be used to access data using symbolic names. The maximum length of a
Search WWH ::




Custom Search