You are on page 1of 3

HOMEWORK-II

CAP212

COMPUTER PERIPHERALS AND INTERFACES

PART A

Q1: A program using if-then-else statements

If Temperature <30 : Light yellow lamp

If temperature >=30 and <40 : Light green lamp

If Temperature >=40 : Light red lamp

Q2: Compute the average of 4 bytes stored in an array in memory.

Q3: How the near call procedures and far call procedures are different from
each other.

PART B

Q4: Write a program to push and pop some data using assembly language.

Q5: Write the syntax and example of the following instructions

a) CALL b) CMP c)INC d)INT e)JNP/JPO

Ans: call instruction invokes an internal or external procedure named procedureName, or


a built-in function, as a subroutine. A series of arguments can optionally be prepared by
the argumentExpression values. These arguments can be acquired in the subroutine by
using either the parse arg or arg instructions, or the arg built-in function

example of a subroutine invocation using the call instruction

/* main program */
do n=1 to 5
call factorial n
say 'The factorial of' n 'is:' RESULT
end
return

factorial : procedure
n = arg(1)
if n = 1 then
return 1
return n * factorial( n - 1 )
The above program would normally use a function call instead. The following shows how
the main program would be coded in this case

/* main program */
do n=1 to 5
say 'The factorial of' n 'is:' factorial( n )
end
return

JNP (JPO) INSTRUCTION

Purpose: Conditional jump, and the state of the flags is taken into
account.

Syntax:

JNP label

It jumps if there is no parity or if the parity is uneven.

The jump is done if PF = 0.

Q6: What are the benefits of using macros in microprocessor and give an
example to show the working of the macro.

Ans: Macro benefits from microprocessors With their onboard computers, new
generation locomotives have great diagnostic and archival capabilities. Builders are
working with railroads to make better use of available data.

In all the hype for the new generation of diesel-electric locomotives--the General Motors
60 Series and the General Electric DASH 8 series--the key phrase was "microprocessor
control."

Microprocessor control, the locomotive builders said, could work wonders in improving
efficiency and making a locomotive more economical to operate. Fuel savings was one of
the big things with the new-generation units, and railroads using the new locomotives
found that the manufacturers were right: They were more efficient, more economical.

In their efforts to prove why the 60 Series and the DASH 8 series were better, GM and
GE also talked about the diagnostic capabilities of the locomotives' microprocessor
systems, the ability of the computer to spot a failure and its cause and sound an alert and
to record it all.
Almost in passing, it was noted that those locomotives could record and maintain their
own individual history, and make it available quickly through downloading to an
inexpensive computer and transfer to a data base.

You might also like