Top Banner
DEPARTMENT OF PURE & APPLIED PHYSICS GURU GHASIDAS VISHWAVIDYALAYA, BILASPUR (C.G.) (A Central University) MODEL ANSWERS AR-7121 (B) M. Sc. (Second Semester) Examination, 2013 ELECTRONICS Paper: Fourth (Computer Applications in Electronics)
12

AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

Mar 19, 2018

Download

Documents

dotu
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

DEPARTMENT OF PURE & APPLIED PHYSICS GURU GHASIDAS VISHWAVIDYALAYA, BILASPUR (C.G.)

(A Central University)

MODEL ANSWERS

AR-7121 (B)

M. Sc. (Second Semester) Examination, 2013

ELECTRONICS

Paper: Fourth

(Computer Applications in Electronics)

Page 2: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

Ans.1:

(i) (c) (vi) (d)

(ii) (c) (vii) (b)

(iii) (a) (viii) (c)

(iv) (b) (ix) (a)

(v) (c) (x) (a)

Ans.2:

The process of opcode fetch operation requires minimum 4-clock cycles T1, T2, T3, and T4 and

is the 1st machine cycle (M1) of every instruction. Example Fetch a byte 41H stored at memory

location 2105H. For fetching a byte, the microprocessor must find out the memory location

where it is stored. Then provide condition (control) for data flow from memory to the

microprocessor. The processof data flow and timing diagram of fetch operation are shown in

Figs. 5.3 (a), (b), and (c). The µP fetches opcode of the instruction from the memory as per the

sequence below

• A low IO/ M means microprocessor wants to communicate with memory.

• The µP sends a high on status signal S1 and S0 indicating fetch operation.

• The µP sends 16-bit address. AD bus has address in 1st clock of the 1st machine cycle, T1

• AD7 to AD0 address is latched in the external latch when ALE = 1.

• AD bus now can carry data.

• In T2, the RD control signal becomes low to enable the memory for read operation.

• The memory places opcode on the AD bus

• The data is placed in the data register (DR) and then it is transferred to IR.

Page 3: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

The MVI B,05H instruction requires 2-machine cycles (M1 and M2). M1 requires 4-states and

M2 requires 3-states, total of 7-states as shown in Fig. 5.3 (d). Status signals IO/ M, S1and S0

specifies the 1st machine cycle as the op-code fetch.n T1-state, the high order address {10H} is

placed on the bus A15 ⇔ A8 and low-order address {00H} on the bus AD7⇔ AD0 and ALE =

1. In T2-state, the RD line goes low, and the data 06H from memory location 1000H are placed

on the data bus. The fetch cycle becomes complete in T3-state. The instruction is decoded in the

T4-state. During T4-state, the contents of the bus are unknown. With the change in the status

signal, IO/ M = 0, S1 = 1 and S0 = 0, the 2nd machine cycle is identified as the memory read.

Ans.3:

In every programming language, thus also in the C programming language, there are

circumstances were you want to do the same thing many times. For instance you want to print

the same words ten times. You could type ten printf function, but it is easier to use a loop. The

only thing you have to do is to setup a loop that execute the same printf function ten times.

There are three basic types of loops which are:

“for loop”

Page 4: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

“while loop”

“do while loop”

The while loop can be used if you don’t know how many times a loop must run. Here is an

example:

#include<stdio.h>

int main()

{

int counter, howmuch;

scanf("%d", &howmuch);

counter = 0;

while ( counter < howmuch)

{

counter++;

printf("%d\n", counter);

}

return 0;

Let’s take a look at the example: First you must always initialize the counter before the

while loop starts ( counter = 1). Then the while loop will run if the variable counter is smaller

then the variable “howmuch”. If the input is ten, then 1 through 10 will be printed on the

screen. A last thing you have to remember is to increment the counter inside the loop

(counter++). If you forget this the loop becomes infinitive.

Ans: 4

There are three major types of data transfer between the microcomputer and art I/O device. They

are,

Programmed I/O : In programmed I/O the data transfer is accomplished through an I/O

port and controlled by software.

Interrupt driven I/O : In interrupt driven I/O, the I/O device will interrupt the processor,

and initiate data transfer.

Page 5: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

Direct memory access (DMA) : In DMA, the data transfer between memory and I/O can

be performed by bypassing the microprocessor.

INTERFACING I/O AND PERIPHERAL DEVICES:

1. For data transfer from input device to processor the following operations are performed.

The input device will load the data to the port.

When the port receives a data, it sends message to the processor to read the data.

The processor will read the data from the port.

After a data have been read by the processor the input device will load the next data into

the port.

2. For data transfer from processor to output device the following operations are performed.

The processor will load the data to the port.

The port will send a message to the output device to read the data.

The output device will read the data from the port.

After the data have been read by the output device the processor can load the next data to

the port.

The various INTEL 110 port devices are 8212, 8155/8156, 8255, 8355 and 8755.

The 8212 is a 24 pin IC.

It consists of eight number of D-type latches.

It has 8-input lines DI1 to DI8 and 8-output lines DO1 to DO8

The 8212 can be used as an input or output device

It has two selecting device DS1 (low) and DS2.

Page 6: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -
Page 7: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

Ans. 5: (i)

ii.

Page 8: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -
Page 9: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

Ans. 6:

Most languages allow you to create functions of some sort. Functions are used to break

up large programs into named sections. You have already been using a function which is the

main function. Functions are often used when the same piece of code has to run multiple times.

In this case you can put this piece of code in a function and give that function a name.

When the piece of code is required you just have to call the function by its name. (So you only

have to type the piece of code once).

In the example below we declare a function with the name MyPrint. The only thing that

this function does is to print the sentence: Printing from a function. If we want to use the

function we just have to call MyPrint() and the printf statement will be executed. (Don’t forget

to put the round brackets behind the function name when you call it or declare it).

Take a look at the example:

A local variable is a variable that is declared inside a function. A global variable is a

variable that is declared outside allfunctions. A local variable can only be used in the function

where it is declared. A global variable can be used in all functions.

See the following example:

#include<stdio.h>

// Global variables

int A;

int B;

int Add()

{

return A + B;

}

int main()

{

int answer; // Local variable

A = 5;

B = 7;

answer = Add();

printf("%d\n",answer);

return 0; }

Page 10: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

(ii)

The formatted Input / Output functions can read and write values of all data types, provided the

appropriate conversion symbol is used to identify the datatype.

scanf is used for receiving formatted Input andprintf is used for displaying formatted output.

Syntax for scanf :

scanf(“control_string 1, - - , control_string n”,&variable1, - - - - ,variable n);

Syntax for printf :

printf(“control_string 1, - - , control_string n”,variable1, - - - - , variable n); Sample Program :

printf_scanf.c

#include<stdio.h>

#include<conio.h>

void main()

{

int no;

char ch;

char s[20];

printf("Enter a character : ");

scanf("%c",&ch);

printf("Enter a No : ");

scanf("%d",&no);

printf("Enter a Word or String : ");

scanf("%s",&s);

printf("\n Character : %c",ch);

printf("\n No : %d",no);

printf("\n String : %s",s); getch();

}

Ans.7

Addressing modes are an aspect of the instruction set architecture in most central

processing unit (CPU) designs. The various addressing modes that are defined in a given

instruction set architecture define how machine language instructions in that architecture identify

the operand (or operands) of each instruction. An addressing mode specifies how to calculate the

Page 11: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

effective memory address of an operand by using information held in registers and/or constants

contained within a machine instruction or elsewhere.

In computer programming, addressing modes are primarily of interest to compiler writers

and to those who write code directly in assembly language.

There are five addressing modes in 8085.

1. Immediate Addressing Mode: - An immediate is transferred directly to the register.

Eg: - MVI A, 30H (30H is copied into the register A)

MVI B,40H(40H is copied into the register B).

2. Register Addressing Mode: - Data is copied from one register to another register.

Eg: - MOV B, A (the content of A is copied into the register B)

MOV A, C (the content of C is copied into the register A).

3. Direct Addressing Mode: - Data is directly copied from the given address to the register.

Eg: - LDA 3000H (The content at the location 3000H is copied to the register A).

4. Indirect Addressing Mode: - The data is transferred from the address pointed by the data in a

register to other register.

Eg: - MOV A, M (data is transferred from the memory location pointed by the regiser to the

accumulator)

5. Implied Addressing Mode: - This mode doesn't require any operand. The data is specified by

opcode itself.

Eg: - RAL CMP

Ans. 8

(i) C program for addition of two numbers

#include <stdio.h>

#include <conio.h>

void main ()

{

int a,b,c;

printf("Program to add two numbers\n");

printf("Enter two numbers of integer type:\n");

printf ("Enter the first number:");

Page 12: AR-7121 (B) - G.G.U Applications in Electronics.pdfAR-7121 (B) M. Sc. (Second Semester) Examination, ... The µP fetches opcode of the instruction from the memory as per the ... -

scanf ("%d",&a);

printf ("\nEnter second number:");

scanf ("%d",&b);

c=a+b;

printf ("\nSum of two numbers = %d",c);

}

(ii)

#include <stdio.h>

#include <conio.h>

void main()

{

int n ,i,j,temp,a[12]; //in a[] specify some number .

printf("Enter the no of inputs:");

scanf("%d", &n);

printf("Enter %d integer numbers :", n);

for(i=0;i<n;i++)

{

scanf("%d",&a[i]);

}

for (i=0;i<n;i++)

for(j=i+1;j<n;j++)

{

if(a[i]>a[j])

{

temp=a[j];

a[j]=a[i];

a[i]=temp;

}

}

printf("THE %d NUMBERS SORTED IN ASCENDING ORDER ARE :\n", n);

for(i=0;i<n;i++)

{

printf("%d ",a[i]);

}

getch();

}