BCSL 22 em

You might also like

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

n g

di
ea
R
e
lin ks
n o
O b o
o r -
f E
b n d
u a
H
h e
T

1
B.C.S.L.-22
Assembly Language Programming Lab
Disclaimer/Special Note: These are just the sample of the Answers/Solutions to some of the Questions given in the
Assignments. These Sample Answers/Solutions are prepared by Private Teacher/Tutors/Authors for the help and guidance
of the student to get an idea of how he/she can answer the Questions given the Assignments. We do not claim 100%
accuracy of these sample answers as these are based on the knowledge and capability of Private Teacher/Tutor. Sample
answers may be seen as the Guide/Help for the reference to prepare the answers of the Questions given in the assignment.
As these solutions and answers are prepared by the private Teacher/Tutor so the chances of error or mistake cannot be

g
denied. Any Omission or Error is highly regretted though every care has been taken while preparing these Sample Answers/

n
Solutions. Please consult your own Teacher/Tutor before you prepare a Particular Answer and for up-to-date and exact

i
information, data and solution. Student should must read and refer the official study material provided by the university.

a d
Q. 1. Design a two bit counter circuit that counts from 0 to 2. It should have states 00, 01 and 10. The
initial state of the counter may be assumed to be 00. The counter will be in following successive states: 00, 01,
10, 00, 01, 00, 01, 10, 00...Use J-K flip flop to design the circuit.

Re
You must design the circuit using state transition diagram and Karnaugh’s maps.

e
Ans. State Transition

in ks
Present State Nent State Flip- Flop input i
P1 P2 P1+
l
n o
P2+ J1 K1 J2 K2

O o
0 0 0 1 0 – 1 –
0 1 1
r - b 0 1 – – 1
1 0 0
fo E
0 – 1 0 –

b d
P P J K

u a n
0 0 0

H
0 1 1 –
1 0 – 1

h e 1 1 – 0

T
Karnaogh’s Map:
P2 P2 P2 P2
P1 P1 P1 P1
0 1 0 1 0 1 0 1
0 1 – – 1 – – 1

2 3 2 3 2 3 2 3
– – 1 – 0 1 – –

J1 = P2 K1 = P1 J2 = P1 K2 = P2

2
J.K. Flip-Flop Circuit

J1 Clock
K1 J2 K2
J K J K
Flip-Flop P1 Flip-Flop P2

P2 P2
P1 P1
J1 = P2 J2 = P1
K1 = P1 K2 = P2

Output: R1 = P1 R2 = P2
P+ = JP– + K–P

n g
i
P+ = J1 P1– + K1– P1, P2 = J 2 P2– + K 2– P2
P1 = P2 P1– + P1– P1
P1+ = P2 P1
a d P+2 = P1 P2– +P–2 P2
P+2 = P1P–2
State Transition Table
Present State
Re
Next State Output State

e
in ks
P1 P2 00.01 Input 10 R1 R2

l
0 0 0010 01 0 0
0 1
n o
0010 01 0 1

O b o
r -
1 0 0010 01 1 0

Present State
fo E Next State Output State
P1 P2
b n d
00. 01 10 R1 R2
00 A
u a A C B 0 0
01 B
H A C B 0 1
10

h
C
e A C B 1 0

T
Q. 2. Write and run following programs using 8086 assembly language:
(a) Write and run an Assembly language program that converts a packed 4 digit BCD number that has
been stored in two consecutive byte locations in the memory, into an equivalent binary number. The output
should be stored in DX register. For example, if two consecutive byte locations have BCD values (12)h and
(34)h then output will be binary equivalent of (1234)10 which is (0000 0100 1101 0010)2. This binary value
will be stored in DX register.
Ans. .BSD TO BINARY CODE CONVERSION PROGRAME
.DATA
BCD DW 1234H

3
COUNT DW DUP(0)
.CODE

START:
MOV AX,@DATA
MOV DS, AX
MOV AX, BCD
MOV COUNT O
MOV BX, 10H

BACK:
MOV DX, O
DIV BX
PUSH DX

g
INC COUNT

n
CMP AX, O
JNZ BACK
MOV DI, O
di
a
MOV BX, OAH

PEPACK:
MOV CX, COUNT
Re
e
DEC CX

in ks
POP AX

l
JCXZ SKIP

n o
REPMAL:
MUL BX
LOOP REPMAL
O b o
SKIP:
o r -
ADD DI, AX
f E
b d
DEC COUNT

n
JNZ REPACK
MOV DX, DI
u a
H
MOV AH, HCH
INT 21H
END START

h e
(b) Write and run (using appropriate calling program) a near procedure in 8086 assembly language that

T
checks if the input parameter has a value less than 5. If the value is less than 5 then subroutines displays the
line "Parameter value is less than 5" else it displays "Parameter value is >=5".
Ans. CHECKS IF THE INPUT PARAMETER HAS A VALUE LESS THAN 5. IF THE VALUE IS LESS THAN
5 THEN SUBROUTINES DISPLAYS THE LINE "PARAMETER VALUE IS LESS THAN 5" ELSE IT DISPLAYS
"PARAMETER VALUE IS >=5"
.STACK 100H
.DATA
MSG1 DB 'PARAMETER MSG2 DB 'PARAMETER > = 5$'
.CODE
MAIN PROC

4
MOV AX,@DATA MOV DS, AX
MOV DL, 5
MOV AH,1
INT 21H
MOV BL,AL
CMP AL,DL
JNG L2
CALL GREATERTHAN JMP
L2:CALL LESSTHAN MOV AH,4CH
INT 21H
MAIN ENDP
LESSTHAN PROC
MOV DX, OFFSET MSG1 MOV AH,9
INT 21H

g
MOV AH,4CH

n
INT21H

i
INT 21H GREATERTHAN ENDP END MAIN

d
(c) Write and run an 8086 assembly language program that finds the factorial of the value stored in BH

a
register. You may assume that BH register will store a maximum value 8. Thus, you need not handle the

e
overflow.
Ans. FINDS THE FACTORIAL OF THE VALUE STORED IN BH REGISTER. YOU MAY ASSUME THAT

R
BH REGISTER WILL STORE A MAXIMUM VALUE 8. THUS, YOU NEED NOT HANDLE THE OVERFLOW

e
DATA SEGMENT
N DB 06H

in ks
FACT DW?

l
DATA ENDS

n o
CODE SEGMENT

O o
ASSUME CS:CODE, DS:DATA START:

MOV AX, DATA


r - b
o E
MOV DS, AX
MOV AX,1
f
b d
MOV BL, N

u a n
MOV BH, 0
CALL FACTORIAL

H
MOV FACT, AX
MOV AH, 4CH
INT 21H
FACTORIAL PROC
h e
T
CMP BX, 1
JE L1
PUSH BX
DEC BX
CALL FACTORIAL
POP BX
MUL BX L1: RET
FACTORIAL ENDP CODE ENDS
END

You might also like