COAL Lab 6
COAL Lab 6
Objectives
• To understand physical and logical memory segments used in 80x86
architecture
• To study the basic elements of assembly language
Basic Information
Understanding segments is an essential part of programming in assembly language. In the
family of 8086-based processors, the term segment has two meanings:
• A block of memory of discrete size, called a “physical segment.” The number
of bytes in a physical memory segment is 64K for 16-bit processors or 4
gigabytes for 32-bit processors.
• A variable-sized block of memory, called a “logical segment,” occupied by a
program’s code or data.
MASM programs consist of modules made up of segments. Every program written only
in MASM has one main module, where program execution begins. This main module can
contain code, data, or stack segments defined with all of the simplified segment
directives. Any additional modules should contain only code and data segments.
The .DATA and .CODE statements do not require any separate statements to define the
end of a segment. They close the preceding segment and then open a new segment. The
END statement closes the last segment and marks the end of the source code. It must be
at the end of every module
Directives are part of the assembler syntax, but are not related to the Intel instruction set
architecture. Various assemblers may generate identical machine code for the Intel
processor, but their sets of directives need not to be the same.
Link step:
The linker supplies with the macro assembler reads an object program (*.obj) and
generates an executable (*.exe) program. The executable program can be executed just by
typing its name.
1. TEMPLATE #1
Following is the program template for creating new programs.
TITLE (The TITLE directive marks the entire line as a comment. You can put
any ;information you want on this line e.g.
;this program is to make you understand the program template
;All the text to right of semicolon is ignored by the assembler, so we use it for
comments.)
INCLUDE irvine16.inc
TEMPLATE #2
. MODEL SMALL
. DATA
.CODE
.STARTUP
.EXIT
END
Directives:
A directive is a command that is recognized and acted upon by the assembler as the
program’s source code is being assembled. Directives are part of assembler’s syntax but
are not related to the intel instruction set Following directives have been used in the
above program template
TITLE
.CODE
INCLUDE
PROC
ENDP
END
Characters
We can call MS DOS INT 21h function 6 by loading 6 into the ah register and loading into dl, the
character to be displayed
e.g.
mov ah,6 ; call DOS function 06
mov dl,”*” ; character to be displayed
int 21h
Strings
A string is declared in this way in the .DATA portion of your assembly.
string byte 'NAME ','$'
Lab Tasks
Lab TaskNo:2
Write a program using call DOS function 06 to display your name on the screen (Each
character one by one). Note: Use template 2 for this problem.
Lab TaskNo:3
Write a program using call DOS function 09 to display your name on the screen. You can
use any template.
# Qualities & 0 < Poor <=1 1 < Satisfactory <= 2 2.5 < Excellent <= 4
Criteria
Task Minimal or Some tasks were All tasks were completed,
ER1 Completion no program completed, but the and the program runs
functionality program has errors or without errors.
was incomplete functionalities.
achieved.
# Qualities & 0 < Poor <=1 1 < Satisfactory <= 2 2.5 < Excellent <= 3
Criteria
ER6 Program Output is Output is mostly accurate Output is clear, accurate,
Output inaccurate or but may lack labels, and well presented with
poorly captions, or formatting. labels, captions, and proper
presented. formatting.
# Qualities & 0 < Poor <=1 1 < Satisfactory <= 2 2.5 < Excellent <= 3
Criteria
ER8 Question & Answers Answers most questions Answers all questions
Answer some confidently and based on confidently and
questions but lab task knowledge. demonstrates a deep
not understanding of the given
confidently lab task.
or based on
lab task
knowledge.