Page 17 - DCAP102_DCAP_401_Foundations of Computer Programming
P. 17

Basic Programming Skills/Foundations of Computer Programming




                    Notes          Stack Segment

                                   8086 Microprocessor supports the Word stack. The stack segment parameters tell the assembler
                                   to alert the linker that this segment statement defines the program stack area.

                                   A program must have a stack area in that the computer is continuously carrying on several
                                   background operations that are completely transparent, even to an assembly language
                                   programmer, for example, a real time clock. Every 55 milliseconds the real time clock interrupts.
                                   Every 55 ms the CPU is interrupted. The CPU records the state of its registers and then goes

                                   about updating the system clock. When it finishes servicing the system clock, it has to restore the
                                   registers and go back to doing whatever it was doing when the interruption occurred. All such
                                   information gets recorded in the stack. If your program has no stack and if the real time clock
                                   were to pulse while the CPU is running your program, there would be no way for the CPU to
                                   fi nd the way back to your program when it was through updating the clock. 0400H byte is the

                                   default size of allocation of stack. Please note if you have not specified the stack segment it is
                                   automatically created.

                                   Data Segment
                                   It contains the data allocation statements for a program. This segment is very useful as it shows
                                   the data organization.

                                   Def ning Types of Data


                                   The following format is used for defining data defi nition:
                                   Format for data defi nition:
                                   {Name} <Directive> <expression>

                                   Name: A program references the data item through the name although it is optional.
                                   Directive: Specifying the data type of assembly.
                                   Expression: Represent a value or evaluated to value.
                                   The list of directives are given below:

                                    Directive                Description               Number of Bytes
                                    DB                       Defi ne byte               1
                                    DW                       Defi ne word               2
                                    DD                       Define double word         4


                                    DQ                       Define Quad word           8
                                    DT                       Define 10 bytes            10


                                   DUP Directive is used to duplicate the basic data definition to ‘n’ number of times
                                   ARRAY         DB                           10 DUP (0)
                                   In the above statement ARRAY is the name of the data item, which is of byte type (DB). This array
                                   contains 10 duplicate zero values; that is 10 zero values.

                                   EQU directive is used to define a name to a constant
                                   CONST         EQU                          20
                                   Type of number used in data statements can be octal, binary, haxadecimal, decimal and ASCII.
                                   The above statement defines a name CONST to a value 20.





          10                               LOVELY PROFESSIONAL UNIVERSITY
   12   13   14   15   16   17   18   19   20   21   22