You are on page 1of 11

www.ignousolvedassignments.

com

Course Code

: MCSL-017

Course Title

: C and Assembly Language Programming

Assignment Number

: MCA(1)/L017/Assign/2014-15

Maximum Marks

: 100

Weightage

: 25%

Last Dates for Submission : 15th October, 2014 (For July 2014 Session)
15th April, 2015 (For January 2015 Session)
This assignment has two sections. Answer all questions in each section. Each Section is of 20
marks. Your Lab Records will carry 40 Marks. Rest 20 marks are for viva voce. You may use
illustrations and diagrams to enhance the explanations. Please go through the guidelines
regarding assignments given in the programme guide for the format of presentation.
Section 1: C Programming Lab
Question 1:
Write an interactive program in C language to create an application similar to NOTEPAD. Write a
program, mynotepad.c, which reads words from any file having extension .txt and displays each
word on a line by itself. A word is defined as any sequence of characters separated by a blank, a tab,
or a newline. Note that this definition for a word considers punctuation as part of the word. This
program should have features like cut, copy, paste, write and search. The application should be
designed user-friendly.
Note: You must execute the program and submit the program logic, sample input and output along
with the necessary documentation for this question.Assumptions can be made wherever necessary.
Solution : Coming Soon
Section 2: Assembly Language Programming Lab

Question 1:
a) Write a program in assembly language for converting lower case to upper case in a given
string of characters.
Solution :

DATA SEGMENT
MSG1 DB 10,13,ENTER ANY STRING :- $
MSG2 DB 10,13,CONVERTED STRING IS : $
P1 LABEL BYTE
M1 DB 0FFH

www.ignousolvedassignments.com

L1 DB ?
P11 DB 0FFH DUP ($)
DATA ENDS

DISPLAY MACRO MSG


MOV AH,9
LEA DX,MSG
INT 21H
ENDM

CODE SEGMENT
ASSUME CS:CODE,DS:DATA

START:
MOV AX,DATA
MOV DS,AX

DISPLAY MSG1
LEA DX,P1
MOV AH,0AH
INT 21H

DISPLAY MSG2
LEA SI,P11
MOV CL,L1
MOV CH,0

CHECK:
CMP [SI],61H
JB DONE
CMP [SI],5BH
UPR: SUB [SI],20H
DONE: INC SI
LOOP CHECK

www.ignousolvedassignments.com

DISPLAY P11
MOV AH,4CH
INT 21H
CODE ENDS
END START

b) Develop and execute an assembly language program to read an array of numbers and
find the minimal and maximal elements.
Solution:

DATA SEGMENT
ARR DB 5,3,7,1,9,2,6,8,4
LEN DW $-ARR
MIN DB ?
MAX DB ?
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA CS:CODE

START:
MOV AX,DATA
MOV DS,AX

www.ignousolvedassignments.com

LEA SI,ARR
MOV AL,ARR[SI]
MOV MIN,AL
MOV MAX,AL
MOV CX,LEN

REPEAT:
MOV AL,ARR[SI]
CMP MIN,AL
JL CHECKMAX
MOV MIN,AL

CHECKMAX:
CMP MAX,AL
JG DONE
MOV MAX,AL
DONE:
INC SI
LOOP REPEAT

MOV AH,4CH
INT 21H
CODE ENDS
END START

Before Execution :-

www.ignousolvedassignments.com

ignou.nisecomputers.com

After Execution :-

www.ignousolvedassignments.com

c)

Write a program in assembly language to print out the length of string.

Solution:

DATA SEGMENT
STR DB GANGADHAR$
MSG1 DB 10,13,THE STRING IN THE MEMORY IS : $
MSG2 DB 10,13,LENGTH OF THE STRING IS :- $
LEN DB 0H
DATA ENDS

www.ignousolvedassignments.com

DISPLAY MACRO MSG


MOV AH,9
LEA DX,MSG
INT 21H
ENDM

CODE SEGMENT
ASSUME CS:CODE,DS:DATA

START:
MOV AX,DATA
MOV DS,AX

DISPLAY MSG1
DISPLAY STR
LEA SI,STR

NEXT:
CMP [SI],$
JE DONE
INC LEN
INC SI
JMP NEXT
DONE:

DISPLAY MSG2
MOV AL,LEN
ADD AL,30H

MOV DL,AL
MOV AH,2
INT 21H

www.ignousolvedassignments.com

MOV AH,4CH
INT 21H
CODE ENDS
END START

After Execution :-

d) Write a program in assembly language to print an infinite sequence of pseudo-random


numbers.
Solution:

DATA SEGMENT
MSG1 DB 10,13,RANDOM NUMBERS ARE : $
MSG2 DB 10,13, $

www.ignousolvedassignments.com

RES DB 10 DUP ($)


DATA ENDS

CODE SEGMENT
ASSUME DS:DATA CS:CODE

START:
MOV AX,DATA

MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H

LEA DX,MSG2
MOV AH,9
INT 21H

NXT:
MOV AH,2CH ; Set time function
INT 21H

MOV AX,DX ; DH=seconds,DL=hundredths of second


XOR AH,AH
LEA SI,RES

CALL HEX2DEC
LEA DX,RES
MOV AH,9
INT 21H

www.ignousolvedassignments.com

LEA DX,MSG2
MOV AH,9
INT 21H

JMP NXT
MOV AH,4CH
INT 21H
CODE ENDS

HEX2DEC PROC NEAR


MOV CX,0
MOV BX,10

LOOP1: MOV DX,0


DIV BX
ADD DL,30H
PUSH DX
INC CX
CMP AX,9
JG LOOP1

ADD AL,30H
MOV [SI],AL

LOOP2: POP AX
INC SI
MOV [SI],AL
LOOP LOOP2

RET
HEX2DEC ENDP
END START

www.ignousolvedassignments.com

After Execution :-

For More Ignou Solved Assignments Please Visit - www.ignousolvedassignments.com


Connect on Facebook :
http://www.facebook.com/pages/IgnouSolvedAssignmentscom/346544145433550
Subscribe and Get Solved Assignments Direct to your Inbox :
http://feedburner.google.com/fb/a/mailverify?uri=ignousolvedassignments_com

You might also like