Dr. Lokesh Chandra Singh

Er. Ravindra Raj

po
t.i

n

Course Code : BCSL-022
Course Title : Assembly Language Programming Lab
Assignment Number : BCA(II)/BCSL022/Assign/2012
Maximum Marks : 50
Weightage : 25%
Last Dates for Submission : 15th October, 2012/15th April, 2013

w

w

w

.ig

no
um

ca

ra
nc
h

i.b

lo

gs

Note: This assignment has two questions, total of 40 marks. Rest 10 marks are for viva voce.
Please go through the guidelines regarding assignments given in the programme guide for the
format of presentation.
Question 1:
1) Design a two bit counter circuit that starts counting from 1 that is possible states of counter are 01, 10,
11, 01... Use J-K flip flop to design the circuit. You must design them using state transition diagram and
Karnaugh's map.
(10 Marks)
Answer:

9334255802

Page 1

9122163254
Dr. Lokesh Chandra Singh

Er. Ravindra Raj

2) Write and run the following programs using 8086 assembly language.

w

gs
lo
i.b

w

w

.ig

no
um

ca

ra
nc
h

.model small
.stack 100h
CR equ 13d
LF equ 10d
.data
msg1 db CR, LF,‘Enter an uppercase letter:$’
result db CR, LF,‘The lowercase equivalent is: $’
bad_msg db CR, LF,‘Not an uppercase letter: $’
.code ; main program
start:
mov ax, @data
mov ds, ax
mov ax, offset msg1
call puts
call getc ; read uppercase letter
mov bl, al ; save character in bl
cmp bl, ‘A‘
jl invalid ; if bl < ‘A‘ goto invalid
cmp bl, ‘Z‘ ; if bl > ‘Z‘ goto invalid
jg invalid
; otherwise its valid
add bl, 32d ; convert to lowercase
mov ax, offset result
call puts ; display result message
mov al, bl
call putc ; display lowercase letter
jmp finish
invalid:
mov ax, offset bad_msg ; not uppercase
call puts ; display bad_msg
mov al, bl
call putc ; display character
entered
finish:
mov ax, 4c00h
int 21h ; return to ms-dos
; subprograms getc, putc and puts should be defined
here
end start

po
t.i

n

(a) Write and run an Assembly language program that finds if the two given strings are palindrome or not.
For example, for the two strings "ABCDEF" as "FEDCBA" the program should output: “ The strings are
Palindrome”.
Answer:

9334255802

Page 2

9122163254
Dr. Lokesh Chandra Singh

Er. Ravindra Raj

gs
lo
i.b
ra
nc
h

w

w

w

.ig

no
um

ca

DATA SEGMENT
BCD DW 4596h
BIN DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AX, BCD
MOV BX, AX
MOV AL, AH
MOV BH, BL
MOV CL, 04H
ROR AH, CL
ROR BH, CL
AND AX, 0F0FH
AND BX, 0F0FH
MOV CX, AX
MOV AX, 0000H
MOV AL, CH
MOV DI, 03E8H
MUL DI
MOV DH, 00H
MOV DL, BL
ADD AX, DX
MOV AX, 0064H
MUL CL
ADD DX, AX
MOV AX, 000AH
MUL BH
ADD AX, DX
MOV BIN, DX
MOV AX, 4C00H
INT 21H
CODE ENDS
END START

po
t.i

n

(b) Write and run (using appropriate calling program) a subroutine in assembly language that converts a
binary number having value between 0000 and 1001 to an equivalent decimal digit. For example, 1001
will be digit 9. Also write the calling program to this subroutine. You must pass the binary value to the
subroutine as a parameter, and the subroutine should print the equivalent binary digit. You must use stack
for parameter passing.
Answer:

9334255802

Page 3

9122163254
Dr. Lokesh Chandra Singh

Er. Ravindra Raj

po
t.i
gs
lo
i.b
ra
nc
h

w

w

w

.ig

no
um

ca

DATA SEGMENT
BCD DB 17h
BIN DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA
MOV DS, AX
MOV AL, BCD
MOV AH, BCD
AND AH, 0FH
MOV BL, AH
AND AL, 0F0H
MOV CL, 04H
ROR AL, CL
MOV BH, 0AH
MUL BH
ADD AL,BL
MOV BIN, AL
MOV AX, 4C00H
INT 21H
CODE ENDS
END START

n

(c) Write and run an assembly language program that converts two digit input (ASCII) format to a packed
BCD number.
(30 Marks)
Answer:

9334255802

Page 4

9122163254

Bcsl 022 solved-assignment_2012-13

  • 1.
    Dr. Lokesh ChandraSingh Er. Ravindra Raj po t.i n Course Code : BCSL-022 Course Title : Assembly Language Programming Lab Assignment Number : BCA(II)/BCSL022/Assign/2012 Maximum Marks : 50 Weightage : 25% Last Dates for Submission : 15th October, 2012/15th April, 2013 w w w .ig no um ca ra nc h i.b lo gs Note: This assignment has two questions, total of 40 marks. Rest 10 marks are for viva voce. Please go through the guidelines regarding assignments given in the programme guide for the format of presentation. Question 1: 1) Design a two bit counter circuit that starts counting from 1 that is possible states of counter are 01, 10, 11, 01... Use J-K flip flop to design the circuit. You must design them using state transition diagram and Karnaugh's map. (10 Marks) Answer: 9334255802 Page 1 9122163254
  • 2.
    Dr. Lokesh ChandraSingh Er. Ravindra Raj 2) Write and run the following programs using 8086 assembly language. w gs lo i.b w w .ig no um ca ra nc h .model small .stack 100h CR equ 13d LF equ 10d .data msg1 db CR, LF,‘Enter an uppercase letter:$’ result db CR, LF,‘The lowercase equivalent is: $’ bad_msg db CR, LF,‘Not an uppercase letter: $’ .code ; main program start: mov ax, @data mov ds, ax mov ax, offset msg1 call puts call getc ; read uppercase letter mov bl, al ; save character in bl cmp bl, ‘A‘ jl invalid ; if bl < ‘A‘ goto invalid cmp bl, ‘Z‘ ; if bl > ‘Z‘ goto invalid jg invalid ; otherwise its valid add bl, 32d ; convert to lowercase mov ax, offset result call puts ; display result message mov al, bl call putc ; display lowercase letter jmp finish invalid: mov ax, offset bad_msg ; not uppercase call puts ; display bad_msg mov al, bl call putc ; display character entered finish: mov ax, 4c00h int 21h ; return to ms-dos ; subprograms getc, putc and puts should be defined here end start po t.i n (a) Write and run an Assembly language program that finds if the two given strings are palindrome or not. For example, for the two strings "ABCDEF" as "FEDCBA" the program should output: “ The strings are Palindrome”. Answer: 9334255802 Page 2 9122163254
  • 3.
    Dr. Lokesh ChandraSingh Er. Ravindra Raj gs lo i.b ra nc h w w w .ig no um ca DATA SEGMENT BCD DW 4596h BIN DW ? DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV AX, BCD MOV BX, AX MOV AL, AH MOV BH, BL MOV CL, 04H ROR AH, CL ROR BH, CL AND AX, 0F0FH AND BX, 0F0FH MOV CX, AX MOV AX, 0000H MOV AL, CH MOV DI, 03E8H MUL DI MOV DH, 00H MOV DL, BL ADD AX, DX MOV AX, 0064H MUL CL ADD DX, AX MOV AX, 000AH MUL BH ADD AX, DX MOV BIN, DX MOV AX, 4C00H INT 21H CODE ENDS END START po t.i n (b) Write and run (using appropriate calling program) a subroutine in assembly language that converts a binary number having value between 0000 and 1001 to an equivalent decimal digit. For example, 1001 will be digit 9. Also write the calling program to this subroutine. You must pass the binary value to the subroutine as a parameter, and the subroutine should print the equivalent binary digit. You must use stack for parameter passing. Answer: 9334255802 Page 3 9122163254
  • 4.
    Dr. Lokesh ChandraSingh Er. Ravindra Raj po t.i gs lo i.b ra nc h w w w .ig no um ca DATA SEGMENT BCD DB 17h BIN DB ? DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV AL, BCD MOV AH, BCD AND AH, 0FH MOV BL, AH AND AL, 0F0H MOV CL, 04H ROR AL, CL MOV BH, 0AH MUL BH ADD AL,BL MOV BIN, AL MOV AX, 4C00H INT 21H CODE ENDS END START n (c) Write and run an assembly language program that converts two digit input (ASCII) format to a packed BCD number. (30 Marks) Answer: 9334255802 Page 4 9122163254