MCSL-017 C AND ASSEMBLY LANGUAGE PROGRAMMING, MCSL 017, (MCA - IGNOU), C AND ASSEMBLY LANGUAGE PROGRAMMING, INDIRA GANDHI NATIONAL OPEN UNIVERSITY, SYMESTER I, LAB MANUAL; MCSL 017 C AND ASSEMBLY LANGUAGE PROGRAMMING LAB MANUAL (SCHOOL OF COMPUTER AND INFORMATION SCIENCE); C PROGRAMMING LAB, DIGITAL LOGIC CIRCUITS, ASSEMBLY LANGUAGE PROGRAMMING;

MCSL-017 (COURSE MATERIAL - IGNOU), [MCSL 017 - IGNOU - M.C.A.],

(Masters of Computer Application - IGNOU), C & ASSEMBLY LANGUAGE PROGRAMMING, INDIRA GANDHI NATIONAL OPEN UNIVERSITY, SYMESTER 1 (LAB MANUAL);

MCSL 017 C AND ASSEMBLY LANGUAGE PROGRAMMING LAB MANUAL (SCHOOL OF COMPUTER AND INFORMATION SCIENCE); C PROGRAMMING LAB, DIGITAL LOGIC CIRCUITS, ASSEMBLY LANGUAGE PROGRAMMING; IGNOU FREE BOOKS, IGNOU ONLINE BOOKS, IGNOU NOTES; IGNOU PERSONAL NOTES; IGNOU MCA BOOKS, IGNOU MCA FIRST YEAR (FIRST SYMESTER - BOOKS); INDIRA GANDHI NATIONAL OPEN UNIVERSITY - FREE - ONLINE - BOOKS; IGNOU MASTERS OF COMPUTER APPLICATIONS - FREE ONLINE BOOKS; IGNOU ONLINE - FREE BOOKS, IGNOU NOIDA CENTER, IGNOU MAIDAN GARHI, NEW DELHI;

NOTE: THESE ARE MY/OUR PERSONAL NOTES, AND WE SUGGEST YOU TO PLEASE FOLLOW YOUR OWN NOTES AND BOOKS PROVIDED BY THE UNIVERSITY (IGNOU); AS THESE ARE MY/OUR PERSONAL NOTES FOR MY PERSONAL USE, THANKS.

MCSL - 017 C AND ASSEMBLY LANGUAGE PROGRAMMING (LAB MANUAL);

===========================================
SECTION 1 - C PROGRAMMING LAB
SECTION 2 - DIGITAL LOGIC CIRCUITS
SECTION 3 - ASSEMBLY LANGUAGE PROGRAMMING
===========================================
COURSE INTRODUCTION  - In the MCS-011 Problem Solving and Programming course, you had studied the Problem solving Techniques, usage of computers to solve problems, algorithm design, flowcharting and basic C programming skills. The first section of this block provides you the list of C programs to help you to have on experience.

C has been used successfully for every type of programming problem imaginable from operating systems to spreadsheets to expert systems - and efficient systems (कुशल प्रणाली) - and efficient compilers (संकलित करना) are available for machines ranging in power from the Apple Macintosh to the Cray Super Computers. The largest measure of C's success seems to be based on purely practical consideration and salient (मुख्य) features being as follows :
  1. The portability (वहनीय) of the compiler
  2. The standard library concept
  3. a powerful and varied repertoire (विभिन्न प्रदर्शनों की सूची) of operators
  4. an elegant syntax (एक सुरुचिपूर्ण वाक्यविन्यास) 
  5. ready access to the hardware when needed
  6. and the ease (सुगमता) with which applications can be optimized by hand-coding isolated procedures.
C is often called a "Middle Level" Programming Language. (UNDERSTANDING C) (CLICK HERE TO KNOW MORE ABOUT C - Programming Language) This is not a reflection on its lack of programming power but more a reflection on its capability to access the system's low level functions. Most high-level language (examples FORTRAN, COBOL, PASCAL etc.) provide everything the programmer might want to do already built into the language. And a low level language (example an assembler) provides nothing other than access to the machines basic instruction set. A middle level language, such as C combines the elements of high-leve language with the functionalism (कार्यात्मकता) of assembly language.

C was initially used for system programming to develop the programs for the Operating System design. The basic advantage of using C is it produces code that runs nearly as fast as code written in assembly language. Some application areas where we can use C programming are :
  1. Operating Systems - (OS - Like Windows, DOS, LINUX, UNIX, etc.)
  2. Language Compilers - [compiler = लेखक, रचयिता]; [compiler सम्बन्धी अधिक जानकारी के लिए यहाँ क्लिक करें : http://en.wikipedia.org/wiki/Compiler ] - [compiler एक या एक से अधिक प्रोग्रामों का समूह है - जो की हाई लेवल प्रोग्रामिंग lenguage को लो लेवल प्रोग्रामिंग lenguage में परिवर्तित या ट्रांसलेट करता है]
  3. Assemblers - [An Assembly Language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices], [Typically a modern assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities.]
  4. Text Editors -
  5. Print Spoolers -
  6. Network Drivers -
  7. Modern Programs -
  8. Date Bases -
  9. Language Interpreters -
  10. Utilities -
This section is very much useful and first step for program development, which will be beneficial for the future course like Data Structure, Design and Analysis of Algorithms and other programming languages. To get the maximum benefit from this, it is necessary that we should execute all the example programs in the MCS-011 course and also problems given in the list at the end of the section, as well.

This Lab course consists of only one block and is organized in the following way :

Section 1 : covers C Programming using Turbo C compiler, UNIX and MS Visual C++. The program development life cycle along with an example is given. This will provide you the reference and guidance fro the rest of the programs you will handle in the practical sessions. This section also contains the general guidelines for your reference. The list of the programs - session wise is given at the end of the section.



Section - 2 : Digital Circuits are the basic building block of a computer system.  It opens up the fundamental logical concepts that are involved inside the computer.  Section 2 touches on the problems relating to logical circuits.  You must develop these logic circuits first on paper and then implement computational circuits.  This will help your skills in the subject area of computer organization.  You must read MCS -012 Block 1 prior to attempting this section.

Section - 3: This section deals with Assembly Language Programming, a low level machine dependent language. Skills in assembly language programming are essential to take full advantage of machine capabilities.  This section covers basic information on various assemblers and a 8086 assembly language simulator, followed by the list of problems.  You must read MCS -012 Block 4 prior to developing assembly programs as given in this section.
===========================================
SECTION 1, - C PROGRAMMING LAB (Structure)
----------------------------------------------------------------
1.0 - Introduction
1.1 - Objectives
1.2 - General Guidelines
1.3 - Salient Features of C
1.4 - C Programming Using Borland Compiler
1.5 - Using C with UNIX
1.6 - Running C Programs using MS Visual C ++
1.7 - Program Development Life Cycle
1.8 -List of Lab Assignments - Session wise
===========================================
1.0 INTRODUCTION :
----------------------------------------------------------------
This is the lab course, wherein we will have the hands on experience. We have studied the support course material (MCS-011) Problem solving and programming). In this part, C programming under DOS, UNIX, and WINDOWS environments are provided illustratively. A list of programming problems is also provided at the end of each session. Please go through the general guidelines and the program documentation guidelines carefully.
===========================================
1.1 OBJECTIVES - After completing this lab course we will /  are - be able to :
  1. Develop the logic for a given problem;
  2. Write the algorithm;
  3. Draw a Flow Chart :
  4. Recognize and understand the syntax and construction of C code;
  5. gain experience of procedural language programming;
  6. Know the steps involved in compiling, linking and debugging C code;
  7. Understanding using header files;
  8. Make use of different data-structures like arrays, pointers, structures and files;
  9. Understand how to access and use library functions;
  10. Understanding function declaration and definition;
  11. Feel more confident about writing your own functins;
  12. Be able to write some simple output ont he screen as well as in the files;
  13. Be able to write some complex programs;
  14. Be able to apply all the concepts that have been covered in the theory course; and 
  15. Know the alternative ways of providing solution to a given problem/ problems.
===========================================
1.2 GENERAL GUIDELINES :
----------------------------------------------------------------
  1. We should attempt all problems / assignments given in the list session wise.
    .
  2. We may seek assistance in doing the lab exercise from the concerned lab instructor. Since the assignments have credits, the lab instructor is obviously not expected to tell you how to solve these, but you (we students) may ask questions concerning the C Language or a technical problem.
    .
  3. For each program you should add comments (i.e. text between /* ... */ delimiters above each function in the code, including the main function. This should also include a description of the function written, the purpose of the function, meaning of the argument used in the function and the meaning of the return value (if any).
    These descriptions should be placed in the comment block immediately above the relevant function source code.
    .
  4. The comment block above the main funciton should describe the purpose of the program. Proper comments are to be provide where and when necessary in the programming.
    .
  5. The program written for the problem given should conform to the ANSI standard for the C language.
    .
  6. The program should be interactive, general and properly documented with real Input/ Output data.
    .
  7. If two or more submissions from different students appear to be of the same origin (i.e. are variants of essentially the same program), none of them will be counted.
    .
  8. It is your responsibility to create a separate directory to store all the programs, so that nobody else can read or copy.
    .
  9. Observation book and lab record are compulsory.
    .
  10. The list of the programs (list of program given at the end, session -wise) is available to you in this lab manual. For each session, you must come prepare with the algorithms and the programs written in the Observation Book. You should utilize the lab hours for executing the programs, testing for various desired outputs and enhancements of the programs.
    .
  11. As soon you have finished a lab exercise, contact one of the lab instructor / incharge in order to get the exercise evaluated and also get the signature from him/ her on the Observation book.
    .
  12. Completed lab assignments should be submitted in the form of a Lab Record in which you have to write the algorithm, program code along with comments and output for various inputs given.
  13. The total number of lab sessions (3 hours each) are 10 and the list of assignments is provided session-wise.  It is important to observe the deadline given for each assignment.
===========================================



1.3 SALIENT FEATURES OF C (सी' की मुख्य विशेषताऐं)
----------------------------------------------------------------
We briefly list some of C's Characteristics that define the language and also have lead to its popularity as a programming language.  Naturally, we studied many of these aspects throughout the MCS-011 Problem solving and Programming Course. [LEARN MORE FEATURES ABOUT C - CLICK HERE]
  1. Small size - (compact size)
  2. Extensive use of function cells - 
  3. Structured Language ; (or structured programming); [ It is most famous for removing or reducing reliance on the GOTO statement]
  4. Low level (BitWise) programming readily available;
  5. Pointer implementation - extensive use of pointers for memory, array, structures and functions.
  6. It has high - level constructs (रचना करना).
  7. It can handle low-level activities.
  8. It produces efficient (कुशल) programs.
  9. It can be compiled on a variety of computers (different os and hardware)
[LEARN MORE FEATURES ABOUT C - CLICK HERE] - PDF FILE
    ===========================================
     
    1.4 - C PROGRAMMING USING BORLAND COMPILER : (C using Borland C/C++ Compiler);
    some of you may be using the Boaland C / C++ compiler during the lab sesion under MS-DOS connecting through Windows.  Whilst C++ is a different programming language to C, it is in fact a superset of C i.e. almost everything that C provides, C++ provides too, and more besides. Therefore we can use Borland C++ to compile our C programs.

    To Start Borland C / C++ :  ---- Click the Start Button of the Screen (Windows - Desktop).  --> The Start menu pops up. --> Select Programs from the 'Start' menu. --> Select Borland C/ C++ from the Programs menu. --> Select Boarland C/C++ from the Borland C++ menu. SUMMARY as follows :
    Start --> Programs --> Borland C++  --> Borland C++

    You should now see the main windows for the C/C++ development environment.

    Editing a Program : - We can create a program by entering text that corresponds to C statements into a file.

    Setting Directories : - Before you proceed, make sure that the directory setting for Borland C/C++ are correct. This can be done as follows :

    Select 'Options' from the menu and then select 'Project' from the 'Options' Pull-Down Menu. This will display the Project Options dialog box.  In the 'Topics' area, click on 'Directories' listed. Ensure that the information in each of the fields is as given below - if it is incorrect, modify it accordingly.

    Source Directories ------- Include C:\bc5\include; ............... Library C:\bc5\lib
    Source Leave this field BLANK --------- Click OK to continue.

    Creating  hello.c  : [ FOR EXTRA HELP VISIT HERE - BORLAND TUTOR ]
    1. Select File from the menu and then select New from the file menu. The first thing that you should do is give the program a name, 'hello.c'  
    2. Select File from the menu. -->
    3. Select 'Save As' from the File drop-down menu  -->
    4. In the Drives drop-down list box, click on the down arrow to open up the list box. -->
    5. Scroll through the list to select the drive and click on it. -->
    6. click on the 'File Name' Field and type 'hello.c'  -->
    7. (Make sure the file name has the ' .C ' extension only.  It should not have a ' .CPP ' extension. If it does change it to ' .C  ', or it won't run properly - so be careful).
    8. Click on the OK button to continue. -->
    9. Now type the ' hello.c ' program exactly as you wrote in the lab observation book. -->
    10. remember that it is good practice to save your programs periodically. You can do this as follows :
      Select ' File ' from The ' Menu '. -----> then Select ' Save ' from the 'File' drop-down menu.
    Compiling a Program : - When you have finished typing the program, you should compile it as follows:
    ---> Select---> Project from the menu -------->
    ---> Select---> Compile from the Project drop-down menu.




    An attempt will be made to compile your program.  If there are errors, they will be reported in the message windows.  You should use the information provided to help yo fix the problems and then recompile the program.

    Running a Program : ----- If you have successfully compiled your program you can now link and run it as follows :
    • --------> Select --- Debug from the menu.
    • --------> Select --- Run from the Debug drop-down menu.
    First, an attempt will be made to link your program.  If there are errors, they will be reported in the message windows.  You should use the information provided to help you fix the problems and then recompile and link the program.

    Your program now runs.  The output from the program will be displayed in a separate window.  (NOTE : If the screen displays a black output windows for a split second and the window then disappears it means you did not set the Target Output type before you compiled your program).

    To switch between the edit window and the output windows, simply click on the window that you want to activate.

    To close the output window, point to the icon in the top left-hand corner and double click on it.

    ALT + F9  (Short cut for Compile and Link) : ---- As you become more famililar with the Borland C/C++ development environment, you will realize that it is possible to combine steps such as COMPILE and LINK into a single step such as build all.  there are also key combinations that can be used instead of selecting from menus (e.g. Alg + F9 compiles the program).  You should spend some time familiarizing yourself with the Borland C/C++ development environment.

    To close the hello.c file, --- double click on the icon in the top left-hand corner of the hello.c edit window.

    To Quit (EXIT) from Borland C/ C++ compiler : --> Select File from the menu ---> Select Exit from the File drop down menu.

    Minimum hardware requirements for Borland C/ C++ Compiler : --- This Borland C / C++ compiler has a command line interface.  You must run it from the (CUI- Character User Interface) DOS prompt.  It has no (GUI) Graphical User Interface like the version we use in the Labs. What you are getting for free is not a good Graphical Interface we use in the labs. You get just the compileer, which is full spec, but you must drive it from the command line. To run the free C/C++ Compiler, our computer must meet the following specification or (HCL = Hardware Compatibility List) :
    1. PC with a Pentium processor, 90 MHz or higheer - (but - P166 recommended - Pentium-1st);
    2. Microsoft Windows 95, 98, 2000, or NT 4.0 with Service Pack 3 (or later);
    3. Microsoft Internet Explorer 4.01 Service Pack 1 (included on CD ROM);
    4. VGA or higher - resolution monitor Super VGA (included on CD ROM);



    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================
    ===========================================