BCSL-022 Solved Assignment 2023-24 - Protected-1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

2023-24

Learning Science

BCSL-022
Solved Assignment
https://learningscience.co.in
BCSL-022 Solved Assignment 2023-2024 (July-January)

.in
Course Code BCSL-022

Course Title Assembly Language Programming Lab

co
Assignment Number BCA (II)/L-022/Assignment/2023-24

e.
Maximum Marks 50

nc
Weightage 25%

31st October, 2023 (For July Session)

ie
Last Date of Submission
30 th April, 2024 (For January Session)

sc
Note: This assignment has two questions of total of 40 marks. Rest 10 marks are for viva voce. Please go through the guidelines regarding

ng
assignments given in the programme guide for the format of presentation.

Q1. Design a two bit counter circuit that count from the state 00 to 10 only. The state 11 is ignored. The states of the counter, thus, may be
ni
00, 01, 10, 00, 01, 10… Use J-K flip flop to design the circuit. You must design them using state transition diagram and Karnaugh's map.(10)

Q2. Perform the following using 8086 assembly language. (3×10 = 30)
ar
(a) Write and run a program using 8086 assembly language that increments a byte value stored in a memory location by a value 2. The
result should be stored in the same memory location. For example, if a memory location contains 0101 0001, then the program will add 2 to
e

this value and store the result 0101 0011 (after adding 2) in the same location 20.
//l

(b) Write and run a program using 8086 assembly language which finds the highest of four byte values stored in memory. The highest value
s:

should be left in AL register.

(c) Write and run a program using 8086 assembly language that compares the values. of AL and BL registers. In case AL is more than BL,
tp

then program clears BL register otherwise it clears AL register. You can move value '1100 1010' in AL, register and '1100 1000' in BL register,
initially. 1
ht

Learning Science | https://learningscience.co.in


.in
-: Solution :-
Q1. Design a two bit counter circuit that count from the state 00 to 10 only. The state 11 is ignored. The states of the counter, thus, may be 00, 01, 10,

co
00, 01, 10… Use J-K flip flop to design the circuit. You must design them using state transition diagram and Karnaugh's map. (10)

Solution:

e.
Step 1: State Transition Diagram:

nc
ie
sc
ng
Step 2: Transition Equations
ni
ar
For J-K FF0:

J0 = Q1' (Transition from 01 to 10)


e
//l

K0 = 0 (K0 is always set to 0 for the desired transitions)


s:

For J-K FF1:


tp

J1 = Q0' (Transition from 10 to 00)


2
ht

K1 = Q0 (Transition from 00 to 01)

Learning Science | https://learningscience.co.in


Step 3: Karnaugh Maps

.in
Karnaugh map for J-K FF0:

co
Q1 Q0 00 01 11 10

e.
0 1 0 x 0
1 x x x x

nc
Simplified equation for J0:

ie
J0 = Q1' (from the K-map)

sc
ng
Karnaugh map for J-K FF1:

Q1 Q0 00 01 11 ni10

0 0 1 x 0
ar
1 x x x x
e
//l

Simplified equation for J1:

J1 = Q0' (from the K-map)


s:
tp

Step 4: Final Equations


3
ht

With the simplified equations, we have:

J0 = Q1' (Complement of Q1)


Learning Science | https://learningscience.co.in
K0 = 0

J1 = Q0' (Complement of Q0)

.in
K1 = Q0

co
Step 5: Implementation

e.
Circuit Diagram (J-K Flip-Flop):

nc
ie
sc
ng
ni
e ar
//l
s:

Q2. Perform the following using 8086 assembly language. (3×10 = 30)
tp

(a) Write and run a program using 8086 assembly language that increments a byte value stored in a memory location by a value 2. The result should be
stored in the same memory location. For example, if a memory location contains 0101 0001, then the program will add 2 to this value and store the 4
ht

result 0101 0011 (after adding 2) in the same location 20.

Learning Science | https://learningscience.co.in


Solution:

.in
ORG 100h ; Origin of the program, typically 100h for .COM programs

co
MOV SI, 20 ; SI register holds the memory location address

MOV AL, [SI] ; Load the byte value from memory into AL register

e.
nc
ADD AL, 2 ; Increment AL by 2

ie
MOV [SI], AL ; Store the result back to the same memory location

sc
ng
MOV AH, 09h ; DOS function to display a string

MOV DX, SI ; Load the memory location address to DX

INT 21h ; Call DOS interrupt


ni
ar
MOV AH, 4Ch ; DOS function to terminate the program
e

INT 21h ; Call DOS interrupt


//l
s:

RET ; Return from the program


tp

5
ht

END

Screenshots of Output:
Learning Science | https://learningscience.co.in
.in
co
e.
nc
ie
sc
ng
ni
ar
(b) Write and run a program using 8086 assembly language which finds the highest of four byte values stored in memory. The highest value should be
e

left in AL register.
//l

Solution:
s:

ORG 100h ; Origin of the program, typically 100h for .COM programs
tp

MOV SI, 1000h ; Starting memory location for the values 6


ht

Learning Science | https://learningscience.co.in


MOV AL, [SI] ; Load the first value into AL register

.in
MOV BL, [SI+1] ; Load the second value into BL register

co
CMP BL, AL ; Compare BL with AL

JAE compare_next ; Jump to compare_next if BL is less or equal

e.
nc
MOV AL, BL ; Move BL to AL if BL is greater

ie
compare_next:

sc
MOV BL, [SI+2] ; Load the third value into BL register

ng
CMP BL, AL ; Compare BL with AL

JAE compare_last ; Jump to compare_last if BL is less or equal


ni
ar
MOV AL, BL ; Move BL to AL if BL is greater
e

compare_last:
//l

MOV BL, [SI+3] ; Load the fourth value into BL register


s:

CMP BL, AL ; Compare BL with AL


tp

JAE done ; Jump to done if BL is less or equal


7
ht

MOV AL, BL ; Move BL to AL if BL is greater

Learning Science | https://learningscience.co.in


.in
done:

MOV AH, 02h ; DOS function to display character

co
ADD AL, '0' ; Convert AL to ASCII

MOV DL, AL ; Load the character to display

e.
INT 21h ; Call DOS interrupt

nc
MOV AH, 4Ch ; DOS function to terminate the program

ie
INT 21h ; Call DOS interrupt

sc
ng
RET ; Return from the program

END
ni
ar
Screenshots of Output:
e
//l
s:
tp

8
ht

Learning Science | https://learningscience.co.in


.in
co
e.
nc
ie
sc
ng
ni
ar
(c) Write and run a program using 8086 assembly language that compares the values. of AL and BL registers. In case AL is more than BL, then program
e

clears BL register otherwise it clears AL register. You can move value '1100 1010' in AL, register and '1100 1000' in BL register, initially.
//l

Solution:
s:

.model small
tp

.stack 100h

9
ht

.data

Learning Science | https://learningscience.co.in


value_al db 0CAh ; Value '1100 1010' in AL register

.in
value_bl db 0C8h ; Value '1100 1000' in BL register

co
.code

main proc

e.
mov ax, @data

nc
mov ds, ax ; Set the data segment

ie
mov al, value_al ; Load value '1100 1010' into AL register

sc
mov bl, value_bl ; Load value '1100 1000' into BL register

ng
cmp al, bl ; Compare the values of AL and BL
ni
ar
jg clear_bl ; Jump to clear_bl if AL is greater than BL
e

; Clear AL register
//l

xor al, al
s:

jmp done
tp

10
ht

clear_bl:

; Clear BL register

Learning Science | https://learningscience.co.in


xor bl, bl

.in
done:

co
mov ah, 4Ch ; Exit program

int 21h

e.
main endp

nc
end main

ie
Screenshots of Output:

sc
ng
ni
e ar
//l
s:
tp

11
ht

Learning Science | https://learningscience.co.in


.in
co
e.
nc
ie
sc
ng
ni
ar
e
//l
s:
tp

12
ht

Learning Science | https://learningscience.co.in


.in
co
e.
nc
ie
For more solved assignments, WhatsApp me @ 7980608289

sc
ng
Learning Science
https://learningscience.co.in
ni
ar
Thank You
e
//l
s:
tp

13
ht

Learning Science | https://learningscience.co.in

You might also like