BCSL 022 1
BCSL 022 1
BCSL 022 1
1. , Design a two bit counter circuit that counts from 1, that is, it will have state 01, 10, 11
only. The initial state of the counter may be assumed to be 01. The counter will be in
following successive states: 01, 10, 11, 01, 10, 11, 01, 10, 11 ... Use any flip flop to design the
circuit. You must design them using state transition diagram and Karnaugh's map. , (10
Marks)
Ans:
A sequential circuit is specified by a time sequence of external inputs, external outputs and internal flip-
flop binary states. Thus firstly, a state table and state diagram is used to describe behaviour of the circuit.
There are 2 flip-flop inputs for counter i.e. A, B. The next state of flip-flop is given in the table. DA
indicates the flip flop input corresponding to flip-flop-A. This counter requires 2-flip-flops.
From this the flip flop input equations are simplified using K-Maps as shown below.
The logic circuit can be made with 2 D flip flops, 2 OR gates & 4 AND gates.
2. , Write and run the following programs using 8086 assembly language.
(a) Write and run an Assembly language program that converts lowercase alphabets in a
given input string to uppercase. The input may consist of uppercase alphabets, special
characters and lowercase alphabets. For example, for the input string A@abAYaf, the
output will be A@ABAYAF. You may assume that the string is available in the memory
Ans:
DATA SEGMENT
DISPLAY MSG1
LEA DX, P1
MOV AH, 0AH
INT 21H
DISPLAY MSG2
DISPLAY P11
DISPLAY MSG3
MOV CL, L1
MOV CH, 0
CHECK:
CMP [SI], 41H
JB DONE
DONE: INC SI
LOOP CHECK
DISPLAY P11
(b) Write and run (using appropriate calling program) a near procedure in 8086
assembly language that converts 2 ASCII digits stored in two registers (say BH and
BL) into an equivalent binary number. For example, if the BH and BL registers
contain digits 4 and 5 respectively, then the binary number obtained will be 0010
1101 which is 45 in decimal. The parameters should be passed using registers and
the result should be returned in AL register. , (12 Marks)
Ans:
DATA_SEG SEGMENT
BCD DB 25h ; storage for BCD value
BIN DB ? ; storage for binary value
DATA_SEG ENDS
STACK_SEG SEGMENT STACK
DW 200 DUP(0) ; stack of 200 words
TOP_STACK LABEL WORD
STACK_SEG ENDS
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG, SS:STACK_SEG
START: MOV AX, DATA_SEG ; Initialise data segment
MOV DS, AX ; Using AX register
MOV AX, STACK_SEG ; Initialise stack
MOV SS, AX ; Segment register. Why; stack?
MOV SP, OFFSET TOP_STACK ; Initialise stack pointer
MOV AH, BCD
CALL BCD_BINARY ; Do the conversion
MOV BIN, AH ; Store the result
BCD_BINARY PROC NEAR
PUSHF
PUSH BX ; and registers used in procedure
PUSH CX ; before starting the conversion; Do the conversion
MOV BH, AH ; Save copy of BCD in BH
AND BH, 0Fh ; and mask the higher bits. The lower digit is in BH
AND AH, 0F0h ; mask the lower bits. The higher digit is in AH ; but in upper 4
bits.
MOV CH, 04 ; so move upper BCD digit to lower
ROR AH, CH ; four bits in AH
MOV AL, AH ; move the digit in AL for multiplication
MOV BH, 0Ah ; put 10 in BH
MUL BH ; Multiply upper BCD digit in AL; by 0Ah in BH, the result is in AL
MOV AH, AL ; the maximum/ minimum number would not ; exceed 8 bits so move
AL to
ADD AH, BH ; Add lower BCD digit to MUL result ; End of conversion,
binary result in
POP CX ; Restore registers
POP BX
POPF
RET ; and return to calling program
BCD_BINARY ENDP
CODE_SEG ENDS
END START
(c) Write and run an 8086 assembly language program displays a string stored in
memory. You must use appropriate interrupt for the same.
Ans:
DATA SEGMENT
PASSWORD DB 'FAILSAFE' ; source string
DESTSTR DB 'FEELSAFE' ; destination string
MESSAGE DB 'String are equal $'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS: DATA, ES: DATA
MOV AX, DATA
MOV DS, AX ; Initialise data segment register
MOV ES, AX ; Initialise extra segment register
LEA SI, PASSWORD ; Load source pointer
LEA DI, DESTSTR ; Load destination pointer
MOV CX, 08 ; Load counter with string length
CLD ; Clear direction flag so that comparison is
REPE CMPSB ; Compare the two string byte by byte
JNE NOTEQUAL ; If not equal, jump to NOTEQUAL
MOV AH, 09 ; else display message
MOV DX, OFFSET MESSAGE ;
INT 21h ; display the message
NOTEQUAL: MOV AX, 4C00h ; interrupt function to halt
INT 21h
CODE ENDS
END