Information Technology Reference
In-Depth Information
instructions are directions to the assembler , the program that translates an assembly-language
program into machine language. A typical pseudo-instruction is ORG 100, which instructs
the assembler to place the following lines at locations beginning with location 100. Another
example is the DAT pseudo-instruction that identifies a word containing only data. The END
pseudo-instruction identifies the end of the assembly-language program.
Each assembly-language instruction fits on one line. A typical instruction has the following
fields, some or all of which may be used.
Symbolic Address Mnemonic
Address
Indirect Bit Comment
If an instruction has a Symbolic Address (a string of symbols), the address is converted
to the physical address of the instruction by the assembler and substituted for all uses of the
symbolic address. The Address field can contain one or more symbolic or real addresses, al-
though the assembly language used here allows only one address. The Indirect Bit specifies
whether or not indirection is to be used on the address in question. In our CPU we do not
allow indirection, although we do allow it in our assembly language because it simplifies our
sample program.
Let's now construct an assembly-language program whose purpose is to boot up a computer
that has been reset. The boot program reads another program provided through its input port
and stores this new program (a sequence of 16-bit words) in the memory locations just above
itself. When it has finished reading this new program (determined by reading a zero word),
it transfers control to the new program by jumping to the first location above itself. When
computers are turned off at night they need to be rebooted, typically by executing a program
of this kind.
Figure 3.34 shows a program to boot up our computer. It uses three symbolic addresses,
ADDR 1, ADDR 2, ADDR 3, and one real address, 10. We assume this program resides
ORG
0
Program is stored at location 0.
ADDR 1
IN
Start of program.
JZ
10
Transfer control if AC zero.
STA
ADDR 2
I
Indirect store of input.
LDA
ADDR 2
Start incrementing ADDR 2.
ADD ADDR 3
Finish incrementing of ADDR 2.
STA
ADDR 2
Store new value of ADDR 2.
CLA
Clear AC.
JZ
ADDR 1
Jump to start of program.
ADDR 2 DAT
10
Address for indirection.
ADDR 3 DAT
1
Value for incrementing.
END
Figure 3.34 A program to reboot a computer.
 
Search WWH ::




Custom Search