BCSL 022
BCSL 022
The
state 11 is ignored. The states of the counter, thus, may be 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.
Ans:
Ans. To design a two-bit counter circuit that counts from the state 00 to 10 only
(ignoring state 11), we will use J-K flip-flops. The counter should cycle through the
states 00, 01, and 10 repeatedly. We will first create a state transition diagram to
visualize the circuit's behaviour and then use Karnaugh’s map to derive the
excitation equations for the J and K inputs of the flip- flops.
State Transition Diagram:
State 00 01 10 00 01 10 … …
Input 00 01 10 11 00 01 10 …
Karnaugh's Map for J-K Flip-Flop Inputs: We will use two J-K flip-flops, one for each
bit of the counter. Here's the Karnaugh's map for each flip-flop:
Flip-Flop A (2nd bit) - Inputs J2 and K2:
J2/K2 00 01 11 10
00 0 0 - 1
01 0 0 - 1
11 - - - -
10 1 1 - 0
Page | 1
J2/K2 00 01 11 10
00 0 1 - 1
01 0 1 - 1
11 - - - -
10 1 1 - 0
Excitation Equations: Based on the Karnaugh's maps, we can derive the excitation
equations for the J and K inputs of the flip- flops as follows:
Flip-Flop A (2nd bit):
J2 = Q1 (Current state of the 1st bit)
K2 = Q2' (Complement of the current state of the 2nd bit)
Flip-Flop B (1st bit):
J1=0
K1 = Q2 (Current state of the 2nd bit)
Circuit Diagram: The final circuit diagram using J-K flip-flops based on the
excitation equations is as follows:
In this circuit, we have three J-K flip-flops (FF1, FF2, and FF3), each representing one
state bit. FF1 is the 1st bit (Q1), FF2 is the 2nd bit (Q2), and FF3 is not part of the
counter; it's there just to hold the output of the counter (Q1 and Q2) for the user to
observe.
The clock signal is connected to all three flip-flops to trigger the state transition on
each clock pulse. The reset signal is used to initialize the counter to the initial state
00.
Page | 2
When the circuit is powered on, and the reset signal is asserted, the counter will be
in state 00. On each clock pulse, it will count in the sequence 00 > 01 > 10 > 00, and so
on, while ignoring state 11. The counter will cycle through these states repeatedly as
per the state transition diagram.
Ans. To achieve this in 8086 assembly language, we need to write a program that
fetches the byte from the memory location, increments it by 2, and then stores the
result back into the same memory location. Below is the 8086-assembly language
code to perform the task:
In this program, the initial value 0101 0001 (51H) is stored in the memory location
0000. The program then loads the byte value into the AL register, increments it by 2
using the ADD instruction, and stores the result back into the same memory
location.
Now, let's assemble and run the program using an 8086 assembler and emulator
(such as emu8086):
1. Save the assembly code in a file named increment.asm.
Page | 3
2. Assemble the code using an 8086 assembler (e.g., TASM, MASM, NASM, etc.).
3. Run the executable or load the .com file in an 8086 emulator (e.g., emu8086).
The output should be as follows:
Before Increment: Value at memory location 0000: 0101 0001 (51H)
After Increment: Value at memory location 0000: 0101 0011 (53H)
(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
left in Al register.
Ans. To find the highest of four-byte values stored in memory using 8086 assembly
language, we can compare each value with the current highest value found so far
and update the AL register accordingly. The AL register will hold the highest value
among the four bytes after the comparison is complete.
Here's the 8086-assembly language code to achieve this:
In this program, the four-byte values to compare are stored in the values array. We
use the AL register to hold the current highest value among the four bytes. We
compare each byte value with the current highest value stored in AL and update AL
if a higher value is found.
Page | 4
Now, let’s assemble and run the program using an 8086 assembler and emulator
(such as emu8086):
1. Save the assembly code in a file named highest.asm.
2. Assemble the code using an 8086 assembler (e.g., TASM, MASM, NASM, etc.).
3. Run the executable or load the .com file in an 8086 emulator (e.g., emu8086).
The output will depend on the values in the values array, and the AL register will
hold the highest value among the four-bytes after the program execution.
(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
clears BL register otherwise it clears Al register. You can move value ‘1100
1010’ in AL, register and ‘1100 1000’ in BL register, initially.
Ans.
To compare the values of AL and BL registers in 8086 assembly language and clear
either AL or BL based on the comparison result, we can use the CMP instruction to
compare AL and BL, and then use conditional jumps (JG and JLE) to perform the
clearing operation.
Here's the 8086-assembly language code to achieve this:
Page | 5
In this program, the initial values '1100 1010' (202 in decimal) and '1100 1000' (200 in
decimal) are stored in AL and BL registers, respectively. The program then uses the
CMP instruction to compare the values in AL and BL.
If AL is greater than BL (AL > BL), the program clears the BL register (XOR BL, BL).
Otherwise, if BL is greater than or equal to AL (AL <= BL), the program clears the
AL register (XOR AL, AL).
Finally, the program displays the cleared register value (either AL or BL) on the
screen.
Page | 6
Now, let's assemble and run the program using an 8086 assembler and emulator
(such as emu8086):
1. Save the assembly code in a file named compare_and_clear.asm.
2. Assemble the code using an 8086 assembler (e.g., TASM, MASM, NASM, etc.).
3. Run the executable or load the .com file in an 8086 emulator (e.g., emu8086).
The output will display the cleared register value, which will be either 0 (if AL was
cleared) or 200 (if BL was cleared), depending on the comparison result.
Page | 7