Assignment Bca
Assignment Bca
KHOJI.NET
Page 1
Question 1. Design a two bit counter circuit that counts from 0 to 3. It should have states
00, 01, 10 and 11. The initial state of the counter may be assumed to be 00. The counter will
be in following successive states: 00, 01, 10, 11, 00, 01, 10, 11, 00, 01, 10, 11, 00 ...
Use any flip flop to design the circuit. You must design counter using state transition
diagram and Karnaugh's map.
Answer:
KHOJI.NET
Page 2
Question 2. Write and run following programs using 8086 assembly language.
a). Write and run an Assembly language program that converts an ASCII four digit
number that is stored in four consecutive byte locations into a packed BCD number that is
to be stored in DX register. For example, if ASCII digits 4321 are stored in four consecutive
locations then your program will convert them into packed BCD and store it in DX as
(0100 0011 0010 0001)2
Answer:
DATA SEGMENT
MESSAGE DB "ENTER CHARACTER :$"
KHOJI.NET
NUM1 DB ?
NUM2 DB ?
NUM3 DB ?
NUM4 DB ?
BCD DW ?
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MESSAGE
MOV AH,9
INT 21H
MOV AH,1
INT 21H
MOV NUM1,AL
SUB NUM1,30H
LEA DX,MESSAGE
INT 21H
MOV NUM2,AL
SUB NUM2,30H
MOV AH,1
LEA DX,MESSAGE
INT 21H
MOV NUM3,AL
SUB NUM3,30H
MOV AH,1
LEA DX,MESSAGE
INT 21H
MOV NUM4,AL
Page 3
SUB NUM4,30h
SUB AL,30H
MOV DH,00h
MOV DL,01h
MOV DH,NUM1
rol DH,4
MOV BCD,DX
MOV AH,4CH
INT 21H
ENDS
END START
KHOJI.NET
Page 4
b). Write and run (using appropriate calling program) a near procedure in 8086 assembly
language that checks if the input parameter has a value zero or not. If the value is zero
subroutines terminates the program else returns a value 1 in AL register.
Answer:
DATA SEGMENT
MSG1 DB 10,13,"ENTER ANY ASCII VALUE : $"
MSG2 DB 10,13,"PRINTING AL VALUE : $ "
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
KHOJI.NET
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
CALL PRINT_AL
MOV AH,4CH
INT 21H
CODE ENDS
PRINT_AL PROC NEAR
MOV AH,1
INT 21H
MOV BL,AL
CMP BL,30h
JE V5
LEA DX,MSG2
MOV AH,9
INT 21H
MOV DL,01h
MOV AH,2
INT 21H
RET
PRINT_AL ENDP
V5: INT 21H
RET
END START
ret
Page 5
KHOJI.NET
Output for Non-Zero:
Page 6
c). Write and run an 8086 assembly language program that finds the sum of odd placed
values out of 10 consecutive byte values stored in an array in the memory. For example, if
10 consecutive byte values (in hexadecimal) are - 12, AA, 13, AB, 14, AC, 15, AD, 16, AF,
then this program should add only value 12, 13, 14, 15 and 16.
Answer:
DATA SEGMENT
ARR DB 0012h, 00AAh, 0013h, 00ABh, 0014h, 00ACh, 0015h, 00ADh, 0016h, 00AFh
LEN DW $-ARR
SUM DW ?
DATA ENDS
CODE SEGMENT
KHOJI.NET
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,ARR
MOV AX,0
MOV CX,5
REPEAT:
MOV BL,ARR[SI]
MOV BH,0
ADD AX,BX
ADD SI,2
LOOP REPEAT
MOV SUM,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
ret
Page 7
KHOJI.NET
Page 8