CS401 CURRENT MIDTERM PAPER WITH SOLUTION

[5:03 AM, 6/17/2023] 🌹: Cs401

Date :13 jan,2022.

Time : 12.00pm

Mcqz past file se thy.

Question 3 marks:

1)WriteThree name of assembly logical part.

·         Arithmetic Logic Unit (ALU):

·         Control Unit (CU):

·         Memory Management Unit (MMU):

2) in video memory, what information is expressed by each byte?


In video memory, each byte typically represents a specific piece of information related to the display of graphics or text on the screen. The specific interpretation of each byte can vary depending on the video hardware and the display mode being used.

Questions 5 marks

1)working of linear memory model?

The linear memory model treats memory as a contiguous sequence of bytes. Each byte is assigned a unique address. Data can be directly accessed by referencing its address.

3)stack data structure using direct call segment?

The stack data structure using direct call segment involves using the stack segment and the stack pointer to manage the stack operations. The stack segment holds the memory region reserved for the stack. The stack pointer (SP) keeps track of the current top of the stack, allowing for efficient push and pop operations.

[5:06 AM, 6/17/2023] 🌹: Mostly from Haadi File

Question

3 marks. What is purpose of Instructions Pointer Register?

the Instruction Pointer Register maintains the program's execution flow by holding the address of the next instruction, enabling sequential execution, and facilitating branching and jumping instructions for program control.

 

3 marks. Swap the value in ax and bx

To swap the values in the AX and BX registers, you can use a temporary register to hold one of the values. Here's the solution in three lines:

  • Move the value of AX into a temporary register, such as CX: MOV CX, AX.
  • Move the value of BX into AX: MOV AX, BX.
  • Move the value from the temporary register (CX) into BX: MOV BX, CX.

 

5 marks. Hello Function my s thora part tha us ki functionality batanii thi

Why we use the REP prefix with the block processing instruction tha

By using the REP prefix with block processing instructions, we can streamline code, enhance performance, and take advantage of the CPU's built-in repetitive execution capabilities.

·         Efficiency

·         Simplified Code

·         Improved Performance

 

What is   ptefix and what changes its brings to the opcode

the segment override prefix enables explicit specification of a segment register for memory access, modifies the opcode of the instruction to accommodate the override, and allows for accessing data in different memory segments, providing flexibility in memory operations.

What will be the effect of REPE &repne instruction on zero flag

the effect of the REPE instruction is to set the zero flag (ZF) to 0 when an unequal value is encountered, while the effect of the REPNE instruction is to set ZF to 1 when an equal value is encountered. The ZF flag reflects the outcome of the repeated comparison and helps in determining loop termination conditions or other control flow decisions.

Similarity or difference btna tha CMP and SUB ma

CMP is used for comparing operands and updating the flags register, while SUB performs a subtraction operation and stores the result in the destination operand. CMP is primarily used for decision-making, such as in conditional branching, while SUB is used when subtraction is required.

 

Working of addressing mode ko explain krna tha

The addressing modes help us specify the way in which an operand's effective address is represented in any given instruction. Some addressing modes allow referring to a large range of areas efficiently, like some linear array of addresses along with a list of addresses.

 ASCCI syntax was given prove this 5 marks

explain Base+index 3marks

The Base+Index addressing mode is commonly used in array access, data structures, and certain types of data manipulations. It provides flexibility in accessing elements based on a combination of a base address and an offset or displacement value stored in an index register.

Ascii stand for

ASCII stands for "American Standard Code for Information Interchange."

 

Subjective:

Q1. Identify the operation and operands from the given codes.

Mov ax, 5

Mov bx, 10 (3)

1.      "Mov ax, 5":

·         Operation: MOV (Move)

·         Operands:

·         Destination: AX (register)

·         Source: 5 (immediate value)

2.      "Mov bx, 10 (3)":

·         Operation: MOV (Move)

·         Operands:

·         Destination: BX (register)

·         Source: 10 (memory address/offset specified in parentheses as 3)

 

Write a program for multiplication of 2 4 bits number

ORG 1000h  ; Set the starting address of the program

 

MOV A, 0010b  ; Load the first 4-bit number into accumulator A

MOV B, 0011b  ; Load the second 4-bit number into register B

 

MUL B  ; Multiply the numbers in A and B

 

; The result is now stored in registers A (higher 4 bits) and B (lower 4 bits)

 

HLT  ; Halt the program

 

END  ; End of the program

A local variable is a variable that is declared within the scope of a function or a block of code

Local variables are typically stored on the stack memory. The storage location for local variables on the stack is determined by the compiler or the assembly programmer

- selective bit inversion on lowest nibble 100110b. 5-marks

To perform selective bit inversion on the lowest nibble (4 bits) of the binary number 100110b, you would flip the bits of the lowest nibble while leaving the higher nibble unchanged. Here's the process:

Original binary number: 100110b

Selective bit inversion on the lowest nibble:

·         Keep the higher nibble (leftmost 4 bits) unchanged: 1001

·         Invert the bits of the lowest nibble (rightmost 4 bits): 0010

Result: 10010010b

So, after performing the selective bit inversion on the lowest nibble of 100110b, the resulting binary number is 10010010b.

 

3. variable ki do function lekhy thy aur match krana tha set of each other with example

·         A variable is a named storage location that holds a value in a program.

·         Functions are blocks of code that perform a specific task or operation and can be called and executed multiple times.

·         Variables allow the storage and manipulation of data within a program, while functions provide a modular and reusable way to organize and execute code for specific tasks or operations.

 

Difference between shift logical right and shift arithmetic right? Marks 3

The key difference between shift logical right and shift arithmetic right lies in how they handle the sign bit. SHR always fills the leftmost bit with zero, while SAR preserves the sign bit, ensuring that the sign of the operand remains intact after the shift.

 

How MOVS instructions works? Marks 3

The MOVS instruction copies a block of data from a source location to a destination location. It utilizes source and destination pointers, increments or decrements the pointers, and can be repeated using the REP prefix.

 

MOV [AX+BX+30] iska btana tha k is m konsa physical design ya strategy use hogi? Marks 5

the instruction "MOV [AX+BX+30]" represents an addressing mode that calculates the effective address based on the values in the AX and BX registers, along with an offset, but it does not directly indicate a specific physical design or strategy.

 

Background and foreground colors k attributes

And physical address find krna

 

define byte with example

In many computer architectures, a byte is the smallest addressable unit of memory. For example, an 820 megabyte (MB

dusra tha display colours

Q2. How are local variables created and accessed in assembly language? (5)

 

Q3. Process of calling a subroutine keeping in mind stack data structure and using inter segment direct call? (5)

 

Q4. Name the registers which have higher and lower halves. Only names. (5)

Higher Half Registers:

·         EAX (Extended Accumulator)

·         EBX (Extended Base)

·         ECX (Extended Counter)

·         EDX (Extended Data)

Lower Half Registers:

·         AX (Accumulator)

·         BX (Base)

·         CX (Counter)

·         DX (Data)

 

-   prefix and affect on opcode 5-marks

 

Background and foreground colors k attributes

 

And physical address find krna

Working of addressing mode ko explain krna tha

Values of ip register is same and update wheb call instruction is extrect  5 marks

 

 

1)working of linear memory model?

 

2)CF=1 and AX=0x64, new value of AX register and carry flag after execute of RCL AX, 1?

 

3)stack data structure using direct call segment?

 

 

Values of ip register is same and update wheb call instruction is extrect  5 marks

 

Q3. Process of calling a subroutine keeping in mind stack data structure and using inter segment direct call? (5)

 

Q4. Name the registers which have higher and lower halves. Only names. (5)

 

Mcqs: registers k related the, call operation se 2-3 mcqs the, SHL se related tha

 

- basic commands likhin thin or un main error find krna tha like move ax, bx wrong ha or mov ax, bx right ha 3-marks

 

- Local variable and where to store it 5-marks

2)CF=1 and AX=0x64,new value of AX register and carry flag after execute of RCL AX, 1?

 

 

2. offset & ....