BCSL 022
BCSL 022
BCA(II)/L-022/Assignment/2024-25
The goal is to design a two-bit counter with the following states: 00, 01, 10, and it should
count in the sequence: 00 → 01 → 10 → 00 → 01 → 10 → 00 → ...
The state transition diagram for the counter can be shown as:
rust
Copy code
State 00 -> State 01
State 01 -> State 10
State 10 -> State 00
J K Q(next) Descriptio
n
0 0 Q No change
0 1 0 Reset
1 0 1 Set
1 1 Toggle Toggle
State Table:
Let's create the state table for the counter based on the state transitions:
00 01 1 0 1 0
01 10 1 0 0 1
10 00 0 1 1 0
Here:
● J1 and K1 are the inputs to the first flip-flop (Q1),
● J2 and K2 are the inputs to the second flip-flop (Q2),
● Q1 represents the first bit of the counter, and Q2 represents the second bit.
Karnaugh Maps:
To simplify the inputs for J1, K1, J2, and K2, we use Karnaugh maps.
Q1Q2 00 01 11 10
00 1 1 0 1
01 1 1 0 1
Q1Q2 00 01 11 10
00 0 0 1 0
01 0 0 1 0
Q1Q2 00 01 11 10
00 1 0 1 1
01 0 0 1 1
Q1Q2 00 01 11 10
00 0 1 0 0
01 1 1 0 0
Objective: Convert two consecutive bytes representing a BCD number into its binary
equivalent and store it in the DX register.
● Byte 1: (12)h
● Byte 2: (34)h
Assembly Program:
asm
Copy code
.model small
.stack 100h
.data
bcd_num db 12h, 34h ; Packed BCD number
binary_num dw 0 ; Variable to store the result
.code
main:
; Initialize DS
mov ax, @data
mov ds, ax
; Program end
mov ah, 4Ch
int 21h
end main
Objective: A subroutine checks if the input value is less than 5 and displays a message
accordingly.
Assembly Program:
asm
Copy code
.model small
.stack 100h
.data
msg1 db "Parameter value is less than 5$", 0
msg2 db "Parameter value is >= 5$", 0
.code
main:
; Initialize DS
mov ax, @data
mov ds, ax
; Program end
mov ah, 4Ch
int 21h
check_value proc
cmp al, 5 ; Compare AL with 5
jl less_than_5 ; Jump if less than 5
greater_equal_5:
mov dx, offset msg2
call print_msg
ret
less_than_5:
mov dx, offset msg1
call print_msg
ret
print_msg proc
mov ah, 09h ; DOS print string function
int 21h
ret
print_msg endp
check_value endp
end main
Objective: Find the factorial of the value in the BH register (assumed maximum value is 8).
Assembly Program:
asm
Copy code
.model small
.stack 100h
.data
result db 1 ; Variable to store factorial result
.code
main:
; Initialize DS
mov ax, @data
mov ds, ax
; Calculate factorial
mov cl, al ; Copy AL (value to calculate factorial)
dec cl ; CL = AL-1 (starting from AL-1)
factorial_loop:
mul cl ; AL = AL * CL
dec cl ; Decrease CL by 1
jnz factorial_loop ; Repeat until CL = 0
; Program end
mov ah, 4Ch
int 21h
end main
These solutions cover both the digital design and assembly programming tasks. Each
assembly program is written to follow the requested logic and can be assembled and run on
an emulator such as DOSBox or an 8086 assembly IDE.