Information Technology Reference
In-Depth Information
CLEAR R 0
MOVE N , R 1
MOVE # NUM , R 2
CALL SUBROUTINE ADDITION
MOVE R 0 , SUM
SUBROUTINE ADDITION
Loop:
ADD ( R 2 )+ ,R 0
DEC R 1
BRANCH-IF-GREATER Loop
RETURN ADDITION
Figure 2.12 A program segment using a subroutine
2.3.4. Input / Output Instructions
Input and output instructions (I
O instructions) are used to transfer data between the
computer and peripheral devices. The two basic I
/
O instructions used are the INPUT
and OUTPUT instructions. The INPUT instruction is used to transfer data from an
input device to the processor. Examples of input devices include a keyboard or a
mouse. Input devices are interfaced with a computer through dedicated input
ports. Computers can use dedicated addresses to address these ports. Suppose that
the input port through which a keyboard is connected to a computer carries the
unique address 1000. Therefore, execution of the instruction INPUT 1000 will
cause the data stored in a specific register in the interface between the keyboard
and the computer, call it the input data register, to be moved into a specific register
(called the accumulator) in the computer. Similarly, the execution of the instruction
OUTPUT 2000 causes the data stored in the accumulator to be moved to the data
output register in the output device whose address is 2000. Alternatively, the com-
puter can address these ports in the usual way of addressing memory locations. In
this case, the computer can input data from an input device by executing an instruc-
tion such as MOVE R in , R 0 . This instruction moves the content of the register R in
into the register R 0 . Similarly, the instruction MOVE R 0 , R in moves the contents
of register R 0 into the register R in , that is, performs an output operation. This
/
TABLE 2.7 Some Transfer of Control Operations
Transfer of control operation
Meaning
BRANCH-IF-CONDITION
Transfer of control to a new address if condition is true
JUMP
Unconditional transfer of control
CALL
Transfer of control to a subroutine
RETURN
Transfer of control to the caller routine
Search WWH ::




Custom Search