# Mohammad Ali Jinnah University - Mechanical Engineering - Computer Programming - Assignment 4, Exercises for Computer Numerical Control. Mohammad Ali Jinnah University

4 pages
1000+Number of visits
Description
Computer programming Assignment
20 points
this document
Preview3 pages / 4

ASSIGNMENT#4

Registration No. _____________ Name:______________

Solve All Questions.

Question 2 Translate each of the following binary representations into its equivalent base ten representation.

A. 1100 __________

B. 10.011 __________

C. 0.01 __________

D. 10001 __________

E. 100000 __________

Question 3 Write the answer to each of the following logic problems.

10101010 10101010 10101010

AND 11110000 OR 11110000 XOR 11110000

Question 4 You need to store the information of students and the courses they are talking. Design tables,

normalize them, identify primary keys, foreign keys, and composite keys in the tables. You need

to store the following fields in your database:

Student-registration-Number, Student-Name, Student-FatherName, Student-DOB, Course-Code,

Course-Name.

Question 5 The following table shows a portion of a machine's memory containing a program written in the language described

in the language description table. Answer the questions below assuming that the machine is started with its program

counter containing 00 (20 marks)

address content address content 00 25 07 00

01 03 08 C0

02 20 09 00

03 F9 0A C0

04 53 0B 00

05 05 0C C0

06 33 0D 00

A. What bit pattern will be in register 5 when the machine halts?

____________

B. What bit pattern will be in register 0 when the machine halts?

____________

C. What bit pattern will be in register 3 when the machine halts?

____________

D. What bit pattern will be at memory location 00 when the machine halts?

____________

Question 6 4. Fill in the blanks below with the part on the operating system (file manager, memory manager, device drivers,

window manager, scheduler, dispatcher) that performs the activity described.

A. _______________ Maintains a record of what is displayed on the computer’s screen

B. _______________ Performs the switching from one process to another

C. _______________ Maintains the directory system

D. _______________ Creates virtual memory

Question 7 What is the difference between a process that is waiting as opposed to a process that is ready?

Question 8 Describe the bootstrap process.

Question 9 Give output of the following program:

Program Output

#include<iostream.h> void main() { int result=0, a=2, b=3; result=(a++)+(--b); cout<<result<<endl; a++; b++; cout<< --result<<endl; a=b--; b=a++; cout<< a<< endl; cout<< b++ <<endl<< --a<<endl; }

Question 10

What is the output of the following program?

#include<iostream.h>

void main(void)

{

int a=10;

if(a>5);

if(a=10) cout<<"YES";

else;

cout<<"NO";

}

a) YES

b) NO

c) YESNO

d) There is an error in the program.

Question 11

Write an algorithm for finding all the factors of a positive integer. For example, in the case of integer 12, your algorithm should report the values 1, 2, 3, 4, 6, 12.

APPENDIX C

The following table is from Appendix C of the text. It is included here so that it can be incorporated in tests for

student reference. Questions in this test bank refer to this table as the “language description table.”

Op- code Operand Description

1 RXY LOAD the register R with the bit pattern found in the memory cell whose address is XY. Example: 14A3 would cause the contents of the memory cell located at address A3 to be placed in register 4.

2 RXY LOAD the register R with the bit pattern XY. Example: 20A3 would cause the value A3 to be placed in register 0.

3 RXY STORE the bit pattern found in register R in the memory cell whose address is XY. Example: 35B1 would cause the contents of register 5 to be placed in the memory cell whose address is B1.

4 0RS MOVE the bit pattern found in register R to register S. Example: 40A4 would cause the contents of register A to be copied into register 4.

5 RST ADD the bit patterns in registers S and T as though they were two’s complement representations and leave the result in register R. Example: 5726 would cause the binary values in registers 2 and 6 to be added and the sum placed in register 7.

6 RST ADD the bit patterns in registers S and T as though they represented values in floating-point notation and leave the floating-point result in register R. Example: 634E would cause the values in registers 4 and E to be added as floating-point values and the result to be placed in register 3.

7 RST OR the bit patterns in registers S and T and place the result in register R. Example: 7CB4 would cause the result of ORing the contents of registers B and 4 to be placed in register C.

8 RST AND the bit patterns in register S and T and place the result in register R. Example: 8045 would cause the result of ANDing the contents of registers 4 and 5 to be placed in register 0.

9 RST EXCLUSIVE OR the bit patterns in registers S and T and place the result in register R. Example: 95F3 would cause the result of EXCLUSIVE ORing the contents of registers F and 3 to be placed in register 5.

A R0X ROTATE the bit pattern in register R one bit to the right X times. Each time place the bit that started at the low-order end at the high-order end. Example: A403 would cause the contents of register 4 to be rotated 3 bits to the right in a circular fashion.

B RXY JUMP to the instruction located in the memory cell at address XY if the bit pattern in register R is equal to the bit pattern in register number 0. Otherwise, continue with the normal sequence of execution. (The jump is implemented by copying XY into the program counter during the execute phase.) Example: B43C would first compare the contents of register 4 with the contents of register 0. If the two were equal, the pattern 3C would be placed in the program counter so that the next instruction executed would be the one located at that memory address. Otherwise, nothing would be done and program execution would continue in its normal sequence.

C 000 HALT execution. Example: C000 would cause program execution to stop.

no comments were posted