Showing posts with label CS401. Show all posts

CS401 Assembly Language Assignment Solution Fall 2012

Part (A):
Calculate physical address of the following segment offset pairs. Explain each and every step for calculating the physical address.                                  (Calculation:3 marks, Explanation:2 marks)
  1. 2C3E:0199
  2. 8000:0250

Part (B):
Assemble the given program using NASM.
(5 marks)
ORG 0100H
MOV AX,5H
ADD AX,44ABH
MOV BX,10
ADD AX,BX
SUB AX,0F12H
MOV BX,15
ADD AX,BX
MOV AX,0X4C00
INT 0X21
solution of part B:
1 ORG 0100H AX 0005 0103 0 0 0 0 1
BX 0000
2 MOV AX,5H AX 44B0 0106 0 0 0 0 1
BX 0000
3 ADD AX,44ABH AX 44B0 0109 0 0 0 0 1
BX 000A
4 MOV BX,10 AX 44BA 010B 0 0 0 0 0
BX 000A
6 ADD AX,BX AX 35A8 010E 0 0 0 0 0
BX 000A
7 SUB AX,0F12H AX 35A8 0111 0 0 0 0 0
BX 000F
8 MOV BX,15 AX 35B7 0113 0 0 1 0 0
BX 000F
9 ADD AX,BX AX 4C00 0116 0 0 1 0

  1. Now we execute the program with F2 key (instruction will move one by one) and write down the contents of the specified registers in the given table.


Instruction
Register current value after the instruction execution
IP
(Instruction Pointer)
Flags
CF
ZF
PF
SF
AF
1 ORG 0100H AX






BX
2 MOV AX,5H AX






BX
3 ADD AX,44ABH AX






BX
4 MOV BX,10 AX






BX
6 ADD AX,BX AX






BX
7 SUB AX,0F12H AX






BX
8 MOV BX,15 AX






BX
9 ADD AX,BX AX






BX

Question No. 2:
Now after attempting previous question, You are able to write, assemble and debug a program. So write a program using Conditional Jump instructions that will add all odd numbers between 1 to 20 (not including 1 & 20). Explain each instruction of program in your own words and also attach the snapshot of your AFD showing the executed code results.
(Program:5 marks, Explanation: 3 marks & Snapshot: 2 marks)
Note: Provide snapshot of your program which will be run in AFD window. It is strictly prohibited the copied assignment.

CS401 Final term Subjective 2012

CS401 - Computer Architecture and Assembly Language Fina lterm Subjective Paper July 2012



40 Mcqs
5 Marks Questions
1 - Define Coordination between data bus, control bus and address bus?
2 - Values required for the following registers to write a character on serial port using INT 21?
- AH =
- AL =
- DX =
3 - Data movement and arithmetic operation in Motorola 68k processor?
4 - Set the time interrupt frequency at 1ms ?
3 Marks Questions1 - Information through descriptor's first 16 Bits used to represent what?
2 - can we increase the speed of multitasking. if yes then how?
3 - Purpose of Global Descriptor Table (GDT) ?
4 - How many bytes will be moved?
- Mov cx, 384
REP movsb
- Mov cs, 384
REP movsw
2 Marks Questions1 - what is the function naming convention in language C ?
2 - write instruction to allocate space for 32Bit PCB?
3 - what are the roles of segment-selector and segment-descriptor?
4 - Segment and Offset address in case of FAR Jump?

CS401 Final term Subjective Solved by MOAAZ

CS401- Computer Architecture and Assembly Language  Solved Subjective from Final term Papers

 Solved by Moaaz Siddiq
Attachments:
Download this file (CS401-FINALTERM-SOLVED-SUBJECTIVE-BY-MOAAZ.pdf)CS401-FINALTERM-SOLVED-SUBJECTIVE-BY-MOAAZ[ ]272 Kb

CS401 Final term MCQs Solved by MOAAZ

CS401 - Computer Architecture and Assembly Language  

Solved Objective from Final term Papers

 Solved by Moaaz Siddiq

Attachments:
Download this file (CS401-FINALTERM-SOLVED-MCQS-BY-MOAAZ.pdf)CS401-FINALTERM-SOLVED-MCQS-BY-MOAAZ[ ]255 Kb

CS401 Final term Paper 2010

FINAL TERM EXAMINATION SPRING 2010
CS401 COMPUTER ARCHITECTURE AND ASSEMBLY LANGUAGE PROGRAMMING
9 AUG 2010
 
Question No: 1 ( M a r k s: 1 ) - Please choose one
When a 32 bit number is divided by a 16 bit number, the quotient is of
·    32 bits
·    16 bits
·    8 bits
·    4 bits
 
Question No: 2 ( M a r k s: 1 ) - Please choose one
In the instruction MOV AX, 5 the number of operands are
·
1
·
2
·
3
·
4
 
Question No: 3 ( M a r k s: 1 ) - Please choose one
3. In DOS input buffer , number of characters actually read on return is stored in
·      First byte
·      Second byte
·      Third byte
·      Fourth byte
 
Question No: 4 ( M a r k s: 1 ) - Please choose one
7. VESA VEB 2.0 is standard for
·    High Resolution Mode
·    Low Resolution Mode
·    Very High Resolution Mode
·    Medium Resolution Mode
 
Question No: 5 ( M a r k s: 1 ) - Please choose one
22. IN DB-9 connector the Data Set ready pin is at
·
5
·
6
·
7
·
8
 
Question No: 6 ( M a r k s: 1 ) - Please choose one
Threads can have function calls, parameters and                      variables.
·      global
·      local
·      legal
·      illegal
 
Question No: 7 ( M a r k s: 1 ) - Please choose one
How many prevalent calling conventions do exist
·
1
·
2
·
3
·
4
 
Question No: 8 ( M a r k s: 1 ) - Please choose one
In 9pin DB 9 DSR is assigned on pin number
·
4
·
5
·
6
·
7
 
Question No: 9 ( M a r k s: 1 ) - Please choose one
In 9pin DB 9 CTS is assigned on pin number
·
6
·
7
·
8
·
9
 
Question No: 10 ( M a r k s: 1 ) - Please choose one
In 9pin DB 9 CD is assigned on pin number
·
1
·
2
·
3
·
4
 
Question No: 11 ( M a r k s: 1 ) - Please choose one
A 32bit address register can access upto ............................of memory so memory
access has increased a lot.
·    2GB
·    4GB
·    6GB
·    8GB
 
Question No: 12 ( M a r k s: 1 ) - Please choose one
in device attribute word which of the following bit decides whether it is a charater device or a block device
·      Bit 12
·      Bit 13
·      Bit 14
·      Bit 15
 
Question No: 13 ( M a r k s: 1 ) - Please choose one
9. Which of the following IRQ is cascading interrupt
·    IRQ 0
·    IRQ 1
·    IRQ 2
·    IRQ 3
 
Question No: 14 ( M a r k s: 1 ) - Please choose one
Which of the following interrupts is used for Arithmetic overflow
·      INT 1
·      INT 2
·      INT 3
·      INT 4
 
Question No: 15 ( M a r k s: 1 ) - Please choose one
An End of Interrupt (EOI) signal is sent by
·      Handler
·      Processor
·      IRQ
·      PIC
 
Question No: 16 ( M a r k s: 1 ) - Please choose one
The number of pins in a parallel port connector are?
·
20
·
25
·
30
·
35
 
Question No: 17 ( M a r k s: 1 ) - Please choose one
Which of the following pins of a parallel port connector are grounded?
·      10-18
·      18-25
·      25-32
·      32-39
 
Question No: 18 ( M a r k s: 1 ) - Please choose one
A 32bit address register can access upto .......................... of memory so memory access has increased a lot.
·      2GB
·      4GB
·      6GB
·      8GB
 
Question No: 19 ( M a r k s: 1 ) - Please choose one
9 Pin Serial connector is called
·      DB-7
·      DB-9
·      DB-25
·      9DB-5
 
Question No: 20 ( M a r k s: 1 ) - Please choose one
In NASM an imported symbol is declared with the ............................ while and
exported symbol is declared with the ............................
·      Global directive, External directive
·      External directive, Global directive
·      Home Directive, Foreign Directive
·      Foreign Directive, Home Directive
 
Question No: 21 ( M a r k s: 2 )
Write brief about INT 13 – Extended READ SERVICES
 
Question No: 22 ( M a r k s: 2 ) What is Interrupt flag?
 
Question No: 23 ( M a r k s: 3 )
Give the name of any two descriptors
 
Question No: 24 ( M a r k s: 3 )
It is the part of Multitasking TSR caller, what will do these instructions comment against them (3)
Mov al, [chars+bx] Mov [es:40],al
Inc bx
Question No: 25 ( M a r k s: 5 )
Write Data Movement and Arithmetic Instructions of Motorola 68 K Processor.
 
Question No: 26 ( M a r k s: 5 )
Write assembly program for “Break Interrupt Service Routine”

CS401 Final term MCQs Solved Mega Post

CS401- Computer Architecture and Assembly Language Programming
McQs collection 

Question No: 1                                 ( M a r k s: 1 ) http://vuzs.net
 
To transfer control back the RET instruction take
 
 
·                          1 argument
 
·                          1 argument
 
·                          3 arguments
 
·                          No arguments
 
 
Question No: 2                                 ( M a r k s: 1 ) http://vuzs.net
 
In STOSB instruction SI is decremented or incremented by
 
 
4
1
2
3
 
Question No: 3                                 ( M a r k s: 1 ) http://vuzs.net
 
CMPS instruction subtracts the source location to the destination location.
                                   
Destination location always lies in
 
 
DS:SI
DS:DI
 
ES:SI
 
ES:DI
 
 
Question No: 4 ( M a r k s: 1 ) http://vuzs.net
 
Regarding assembler, which statement is true:
 
Assembler converts mnemonics to the corresponding OPCODE
Assembler converts OPCODE to the corresponding mnemonics.
 Assembler executes the assembly code all at once
Assembler executes the assembly code step by step
 
Question No: 5                                 ( M a r k s: 1 ) http://vuzs.net
 
Iof “BB” is the OPCODE of the instruction which states to “move a constant value to AX register”, the hexadecimal representation (Using little Endian notation) of the instruction “Mov AX,336” (“150” in hexadecimal number system) will be:
 
0xBB0150
0x5001BB
0x01BB50
0xBB5001
 
Question No: 6                                 ( M a r k s: 1 ) http://vuzs.net
 
In the instruction  MOV AX, 5 the number of operands are
 
1
2
3
4
 
Question No: 7                                 ( M a r k s: 1 ) http://vuzs.net
 
The maximum parameters a subroutine can receive (with the help of registers) are
 
 
6
7
8
9
 
Question No: 8                                 ( M a r k s: 1 ) http://vuzs.net
In assembly the CX register is used normally as a ______________register.
 
source
counter
index
pointer
 
Question No: 9                                 ( M a r k s: 1 ) http://vuzs.net
 
All the addressing mechanisms in iAPX 8 8 return a number called _ _ _ _ _ _ _ _ _ _ _ _ _ address .
 
 
effective
faulty
indirect
direct
Question No: 10                                 ( M a r k s: 1 ) http://vuzs.net
 
When a 16 bit number is divided by an 8 bit number, the dividend will be in
 
 
AX
BX
CX
DX
 
Question No: 11                                 ( M a r k s: 1 ) http://vuzs.net
in Left-Shift-Operation the left most bit _______
 
will drop
will go into CF
Will come to the right most
will be always 1
 
Question No: 12                                 ( M a r k s: 1 ) http://vuzs.net
 
Suppose the decimal number "35" after shifting its binary two bits to left, the new value becomes _________
 
35
70
140
17
 
Question No: 13                                 ( M a r k s: 1 ) http://vuzs.net
 
When divide overflow occurs processor will be interrupted this type of interrupt is called
Hardware interrupt
 
Software interrupt
 
Processor exception
 
Logical interrupts
 
 
Question No: 14                                 ( M a r k s: 1 ) http://vuzs.net
 
Which mathematical operation is dominant during the execution of SCAS instruction
 
Division
 
Multiplication
 
Addition
 
Subtraction
 
 

CS401 Final Term Paper Solved 2010 - 3

 FINALTERM  EXAMINATION
Spring 2010
CS401- Computer Architecture and Assembly Language Programming
(Session - 2)


Time: 90 min
M a r k s: 58
    
Question No: 1    ( M a r k s: 1 )    http://vuzs.net
 Suppose AL contains 5 decimal then after two left shifts produces the value as

       ► 5         
       ► 10
       ► 15
       ► 20
   
Question No: 2    ( M a r k s: 1 )    http://vuzs.net
 In graphics mode a location in video memory corresponds to a _____________ on the screen.
       ► line
       ► dot
       ► circle
       ► rectangle
   
Question No: 3    ( M a r k s: 1 )    http://vuzs.net
 Creation of threads can be
       ► static
       ► dynamic
       ► easy
       ► difficult
   
Question No: 4    ( M a r k s: 1 )    http://vuzs.net
 The thread registration code initializes the PCB and adds it to the linked list so that the __________ will give it a turn.
       ► assembler
       ► scheduler
       ► linker
       ► debugger
   
Question No: 5    ( M a r k s: 1 )    http://vuzs.net
 VESA VBE 2.0 is a standard for
       ► High resolution Mode
       ► Low resolution Mode
       ► Medium resolution Mode
       ► Very High resolution Mode
   
Question No: 6    ( M a r k s: 1 )    http://vuzs.net
 Which of the following gives the more logical view of the storage medium
       ► BIOS
       ► DOS
       ► Both
       ► None
   
Question No: 7    ( M a r k s: 1 )    http://vuzs.net
 Which of the following IRQs is derived by a key board?
       ► IRQ 0
       ► IRQ 1
       ► IRQ 2
       ► IRQ 3
   
Question No: 8    ( M a r k s: 1 )    http://vuzs.net
 Which of the following IRQs is used for Floppy disk derive?

       ► IRQ 4
       ► IRQ 5
       ► IRQ 6
       ► IRQ 7
   
Question No: 9    ( M a r k s: 1 )    http://vuzs.net
 Which of the following pins of a parallel port connector are grounded?
       ► 10-18      
       ► 18-25     
       ► 25-32   
       ► 32-39
   
Question No: 10    ( M a r k s: 1 )    http://vuzs.net
 The physical address of IDT( Interrupt Descriptor Table) is stored in _______
       ► GDTR
       ► IDTR
       ► IVT
       ► IDTT
   
Question No: 11    ( M a r k s: 1 )    http://vuzs.net
 In NASM an imported symbol  is declared with the ............................ while and exported symbol is declared with the ............................
       ► Global directive, External directive 
       ► External directive, Global directive
       ► Home Directive, Foreign Directive
       ► Foreign Directive, Home Directive
   
Question No: 12    ( M a r k s: 1 )    http://vuzs.net
 In 68K processors there is a ........................ program counter (PC) that holds the address of currently executing instruction
       ► 8bit
       ► 16bit
       ► 32bit
       ► 64bit
   
Question No: 13    ( M a r k s: 1 )    http://vuzs.net
 To reserve 8-bits in memory ___ directive is used.
       ► db
       ► dw
       ► dn
       ► dd
   
Question No: 14    ( M a r k s: 1 )    http://vuzs.net
 In the “mov ax, 5”     5 is the __________ operand.
       ► source
       ► destination
       ► memory
       ► register
   
Question No: 15    ( M a r k s: 1 )    http://vuzs.net
 RETF will pop the segment address in the
       ► CS register
       ► DS register
       ► SS register
       ► ES register
   
Question No: 16    ( M a r k s: 1 )    http://vuzs.net
 For the execution of the instruction “DIV  BL”, the implied dividend will be stored in

       ► AX 
       ► BX
       ► CX 
       ► DX
   
Question No: 17    ( M a r k s: 1 )    http://vuzs.net
 When a number is divided by zero ”A Division by 0” interrupt is generated. Which instruction is used for this purpose
       ► INT 0
       ► INT 1
       ► INT 2
       ► This interrupt is generated automatically
   
Question No: 18    ( M a r k s: 1 )    http://vuzs.net
 INT 21 service 01H is used to read character from standard input with echo. It returns the result in  ______ register.
       ► AL
       ► BL
       ► CL
       ► BH
   
Question No: 19    ( M a r k s: 1 )    http://vuzs.net
 BIOS sees the disks as
       ► logical storage
       ► raw storage
       ► in the form of sectors only
       ► in the form of tracks only
   
Question No: 20    ( M a r k s: 1 )    http://vuzs.net
 In 9pin DB 9, which pin number is assigned to CD (Carrier Detect) ?
       ► 1
       ► 2
       ► 3
       ► 4
   
Question No: 21    ( M a r k s: 1 )    http://vuzs.net
 In 9pin DB 9, Signal ground is assigned on pin number
       ► 4
       ► 5
       ► 6
       ► 3
   
Question No: 22    ( M a r k s: 1 )    http://vuzs.net
 In 9pin DB 9, RI (Ring Indicator) is assigned on pin number
       ► 6
       ► 7
       ► 8
       ► 9
   
Question No: 23    ( M a r k s: 1 )    http://vuzs.net
 Motorola 68K processors have ....................... 23bit general purpose registers.
       ► 4
       ► 8
       ► 16
       ► 32
   
Question No: 24    ( M a r k s: 1 )    http://vuzs.net
 When two devices in the system want to use the same IRQ line then what will happen?

       ► An IRQ Collision

       ► An IRQ Conflict

       ► An IRQ Crash

       ► An IRQ Blockage

   
Question No: 25    ( M a r k s: 1 )    http://vuzs.net
 In the instruction  MOV AX, 5 the number of operands are
       ► 1
       ► 2
       ► 3
       ► 4
   
Question No: 26    ( M a r k s: 1 )    http://vuzs.net
 Which flags are NOT used for mathematical operations ?
       ► Carry, Interrupt and Trap flag.
       ► Direction, Interrupt and Trap flag.
       ► Direction, Overflow and Trap flag.
       ► Direction, Interrupt and Sign flag.
   
Question No: 27    ( M a r k s: 2 )
 How can we improve the speed of multitasking?

Ans:
We can improve the speed of multitasking by changing the frequency of timer interrupt.
   
Question No: 28    ( M a r k s: 2 )
 Write instructions to do the following. Copy contents of memory location with offset 0025 in the current data segment into AX.

Ans:

Mov ax , [0025]

mov[0fff], ax

mov  ax , [0010]
   mov [002f] , ax
     
Question No: 29    ( M a r k s: 2 )
 Write types of Devices?

Ans:
There are two types devices used  in pc.
  1. Input devices(keyboard, mouse,)
  2. Output devices.(monitor, printer)
    
Question No: 30    ( M a r k s: 2 )
 What dose descriptor 1st 16 bit tell?
Ans:
Each segment is describe by the descriptor like
  1. base,
  2. limit,
  3. and attributes,
it  basically define the actual base address.
    
Question No: 31    ( M a r k s: 3 )
 List down any three common video services for INT 10 used in text mode.

Ans:
INT 10 - VIDEO - SET TEXT-MODE CURSOR SHAPE
AH = 01h
CH = cursor start and options
CL = bottom scan line containing cursor (bits 0-4)
    
Question No: 32    ( M a r k s: 3 )
 How to create or Truncate File using INT 21 Service?
  
Ans:
 INT 21 - TRUNCATE FILE
AH = 3Ch
CX = file attributes
DS:DX -> cs401 filename
Return: 
CF = error flag
AX = file handle or error code
    
Question No: 33    ( M a r k s: 3 )
 How many Types of granularity also name them?
Ans:
There are three types of granuality :
  1. Data Granularity
  2. Business Value Granularity
  3. Functionality Granularity
   
Question No: 34    ( M a r k s: 5 )
 How to read disk sector into memory using INT 13 service?

Ans:
INT 13 - DISK - READ SECTOR(S) INTO MEMORY :
AH = 02h
AL = number of sectors to read (must be nonzero)
CH = low eight bits of cylinder number
CL =                sector number 1-63 (bits 0-5)
                          high two bits of cylinder (bits 6-7, hard disk only)
DH = head number
DL = drive number (bit 7 set for hard disk)
ES:BX -> data buffer
  
Return: 
CF = error flag
AH = error code
AL = number of sectors transferred
   
Question No: 35    ( M a r k s: 5 )
The program given below is written in assembly language. Write a program in C to call this assembly routine.
[section .text]
global        swap
swap:        mov  ecx,[esp+4]      ; copy parameter p1 to ecx
                  mov  edx,[esp+8]      ; copy parameter p2 to edx
                  mov  eax,[ecx]           ; copy *p1 into eax
                  xchg eax,[edx]           ; exchange eax with *p2
                  mov  [ecx],eax           ; copy eax into *p1
                  ret                               ; return from this function

 Ans:
The above code will assemble in c through this command. Other aurwise error will occur.
Nasm-f win32 swap .asm

This command will generate swap.obj file.
The code for given program will be as follow.

#include <stdio.h>
Void swap(int* pl, int* p2);
Int main()
{
      Int a=10,
      Int b= 20;
Print f (“a=%d b=%d\n” , a ,b);

Swap (&a ,&b);

Print f (“a=%d b=%d\n” , a ,b);

System ( “pause”);


Return 0;


}
    
Question No: 36    ( M a r k s: 5 )
 Write the code of “break point interrupt routine”.
 Ans:
Breakpoint interrupts service routine :
debugISR:          push bp
              mov  bp, sp             ; …………….to read cs, ip and flags
              push ax
              push bx
              push cx
              push dx
              push si
              push di
              push ds
              push es

              sti                     ;…………………….. waiting for keyboard interrupt
              push cs
              pop  ds                 ;…………………… initialize ds to data segment

              mov  ax, [bp+4]         
              mov  es, ax             ; ………………….load interrupted segment in es
              dec  word [bp+2]        ; ……………….decrement the return address
              mov  di, [bp+2]         ;………………… read the return address in di
              mov  word [opcodepos], di ;…………. remember the return position
              mov  al, [opcode]       ; …………..load the original opcode
              mov  [es:di], al        ;………….. restore original opcode there

              mov  byte [flag], 0     ; …………set flag to wait for key
              call clrscr             ;……………. clear the screen

              mov  si, 6              ; …………..first register is at bp+6
              mov  cx, 12             ;………… total 12 registers to print
              mov  ax, 0              ; …………..start from row 0
              mov  bx, 5              ; ………….print at column 5

          push ax                 ; ………………..row number
              push bx                 ;………………. column number 
              mov  dx, [bp+si]
              push dx                 ;………………. number to be printed
              call printnum           ;…………….. print the number
              sub  si, 2              ; ……………….point to next register 
              inc  ax                 ; ………………..next row number 
              loop l3                 ; ……………….repeat for the 12 registers

              mov  ax, 0              ; ………………..start from row 0
              mov  bx, 0              ; ………………..start from column 0
              mov  cx, 12             ; …………………..total 12 register names
              mov  si, 4              ;……………………. each name length is 4 chars
              mov  dx, names          ; …………………..offset of first name in dx

              push ax                 ;………………………. row number 
              push bx                 ; ………………………column number 
              push dx                 ; ……………………….offset of string
              push si                 ; ………………………….length of string
              call printstr           ; ………………………….print the string
              add  dx, 4              ;………………………….. point to start of next string 
              inc  ax                 ; ……………………………new row number
              loop l1                 ;…………………………….. repeat for 12 register names

              or word [bp+6], 0x0100  ; ……………………set TF in flags image on stack

keywait:      cmp  byte [flag], 0     ;……………………. has a key been pressed
              je   keywait            ;            ………………….. no, check again

              pop es

              pop ds
              pop di
              pop si
              pop dx
              pop cx
              pop bx
              pop ax
              pop bp
              iret

start:        xor  ax, ax
              mov  es, ax             ;            ……………………point es to IVT base
              mov  word [es:1*4], trapisr ;…………………. store offset at n*4
              mov  [es:1*4+2], cs     ;      …………………...store segment at n*4+2
              mov  word [es:3*4],            …………………..debugisr ; store offset at n*4
              mov  [es:3*4+2], cs     ;      …………………..store segment at n*4+2
              cli                     ;                  ………………….disable interrupts
              mov  word [es:9*4], kbisr ; ………………….store offset at n*4
              mov  [es:9*4+2], cs     ; ……………………...store segment at n*4+2
              sti                     ;             ………………………enable interrupts

Related Posts Plugin for WordPress, Blogger...