Pir Mehr Ali Shah Arid Agriculture University, Rawalpindi Office of the controller of Examinations Mid Exam / Spring 2020 (Paper Duration 48 hours) To be filled by Teacher Course No.: …..CS-530……Course Title: …Computer Organization & Assembly Language… Total Marks:…………48……… Date of Exam:………………23-June-2020…………………….. Degree: …………… BS(CS)……………...Semester:…6th … Section:………C (Morning)……... 7 8 9 10 __ __ __ Marks Obtained Total Marks in Words: Name of the teacher: Mr. Muhammad Usman Who taught the course: __ __ ___ Q. No. 1 2 3 4 5 6 Marks Obtained/ Total Marks _ _ /48 = _ _ /12 Signature of teacher / Examiner: To be filled by Student Registration No.: …………………………… Name:………………………………………………. Note: 1. Approximately paper solving time is 2.5 hrs, however submission time is till 48 hours. 2. Try to upload paper as soon as possible to avoid DOS error at server due to bulk submissions in late hours. 3. There are total four (4) questions in the paper. 4. Write programs in DOSBOX / emu8086 and add code with screenshots of program with its output in your answer sheet (word file) wherever required. 5. Make sure you have filled your Name and Reg. No. in the above provided space. 6. Upload the paper only through PC or laptop, Mobile submission is not allowed. Answer the following questions. Question # 1: (Points: 3+3+6=12) a) Describe the following resister with their purposes. 1) Code Segment 2) Flag Registers 3) Extra Segment 4) Base Register 5) Accumulator b) Describe the difference between 1) Instruction Pointer 2) Stack Pointer 3) Base pointer c) Write a code to display the largest number in array. Array size is up to 5 elements. OR Sample execution: Write a code to convert Capital letter to small letter and then display A=a all Capital letter (A to Z) along with Small letter (a to z) on the next B=b line. …… Z=z Solution of Question # 1: __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ Question # 2: (Points: 2+4+6=12) a) Find the following differences using twos complement arithmetic: 1) Binary of your last 3 digits of ARID number (i.e. 449 111000001) – 11011010 2) Binary of your last 4 digits of ARID number (i.e. 2449 1001…) – 1111100111 b) The hypothetical machine has two I/O instructions: 0011 Load AC from I/O 0111 Store AC to I/O In these cases, the 12-bit address identifies a particular I/O device. Show the program execution (using the format of Figure 1 and filled Figure 2) for the following program: Take a mod of your last 4 digit of your arid number with 10 (e.g. if arid no. is 18-arid1234 then take mod of 1234 % 10 = 4) 1. Load AC from device 4 (mod result). 2. Add contents of memory location 940/941. (940 if mod result is even, 941 if mod result is odd) 3. Store AC to memory location 940/941. (940 if mod result is odd, 941 if mod result is even) Assume that the next value retrieved from device 4 (mod result) is last two digits of arid number and that location 940/941 contains a value of 3. Figure 1 Figure 2 c) Convert the following high level (C++) program into assembly language. #include<iostream> using namespace std; int main() { char name; int age; cout<<"Enter Full name: "; cin>>name; cout<<"Enter age: "; cin>>age; cout<<"\nDisplaying Info."<<endl; cout<<"Name: "<<name<<endl; cout<<"Age: "<<age<<endl; } Solution of Question # 2: __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ Question # 3: (Points: 2+4+6=12) a) When Two 16-bits numbers are multiplied, what two registers holds the product? Show the registers that contains the most and least significant portions of the products. b) Write an if-else statement in assembly language that displays Yes if a variable age is greater than 21 or otherwise displays No. c) Predict the output of the following code and comments every-line purpose. .model small .stack 100h .code start: mov cx, 5 L1: push cx L2: mov ah,2h mov dl,2Ah int 21h loop L2 mov dl,0Ah int 21h mov dl,0Dh int 21h pop cx loop L1 mov cx,5 L3: push cx L4: mov ah,2h mov dl,20h int 21h loop L4 mov dl,2Ah int 21h mov dl,0Ah int 21h mov dl,0Dh int 21h pop cx loop L3 exit: int 21h end start Solution of Question # 3: __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ Question # 4: (Points: 2+4+6=12) a) Explain what the JMP AX Instruction accomplishes. Also identify it as a near or far jump instruction. b) If AX=8FFF and BX=0FFF and “cmp ax, bx” is executed, which of the following jumps will be taken? Each part is independent of others. Also give the value of Z, S, and C flags. 1) jg greater 2) jl smaller 3) ja above c) Write a program that prompts the user to type a decimal number of 16 digits or less, display its output in Hex on the next line. If the user enters an any wrong character, he or she should be prompted to begin again. Solution of Question # 4: __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________ __________________________________________________________________________________________