Page 15 - DCAP102_DCAP_401_Foundations of Computer Programming
P. 15
Basic Programming Skills/Foundations of Computer Programming
Notes relocatable. They can be loaded practically anywhere in memory and run just as well. Program1
has to store the message “Have a nice day$” somewhere in memory. It is located in the DATA
SEGMENT. Since the characters are stored in ASCII, therefore it will occupy 15 bytes (please note
each blank is also a character) in the DATA SEGMENT.
Missing offset: The xxxx in the machine language for the instruction at line 0010 is there because
the assembler does not know the DATA segment location that will be determined at loading
time. The loader must supply that value.
Program Source Code: Each assembly language statement appears as:
{identifier} Keyword {{parameter},} {;comment}.
The element of a statement must appear in the appropriate order, but significance is attached to
the column in which an element begins. Each statement must end with a carriage return, a line
feed.
Keyword: A keyword is a statement that defines the nature of that statement. If the statement is
a directive then the keyword will be the title of that directive; if the statement is a data-allocation
statement the keyword will be a data definition type. Some examples of the keywords are:
SEGMENT (directive), MOV (statement) etc.
Identif ers: An identifier is a name that you apply to an item in your program that you expect to
reference. The two types of identifiers are name and label.
1. Name refers to the address of a data item such as counter, arr etc.
2. Label refers to the address of our instruction, process or segment.
Example: MAIN is the label for a process as:
MAIN PROC FAR
A20: BL,45 ; defines a label A20.
Identifier can use alphabet, digit or special character but it always starts with an alphabet.
Parameters: A parameter extends and refines the meaning that the assembler attributes to the
keyword in a statement. The number of parameters is dependent on the Statement.
Comments: A comment is a string of a text that serves only as internal document action for a
program. A semicolon identifies all subsequent text in a statement as a comment.
Directives
Assembly languages support a number of statements. This enables you to control the way in
which a source program assembles and list. These statements, called directives, act only when the
assembly is in progress and generate no machine-executable code. Let us discuss some common
directives.
1. List: A list directive causes the assembler to produce an annotated listing on the printer,
the video screen, a disk drive or some combination of the three. An annotated listing shows
the text of the assembly language programs, numbers of each statement in the program and
the offset associated with each instruction and each datum. The advantage of list directive
is that it produces much more informative output.
2. HEX: The HEX directive facilitates the coding of hexadecimal values in the body of the
program. That statement directs the assembler to treat tokens in the source file that begins
with a dollar sign as numeric constants in hexadecimal notation.
8 LOVELY PROFESSIONAL UNIVERSITY