0 ratings0% found this document useful (0 votes) 118 views3 pagesMASM Theory Lab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
12. Famillarization of MASM Programming
‘THe Intel 8086 isa 16 bit processor that is intended to be w
Computer. 16 bit indicates the word length of the micro
Produces the physical address by adding the effeeti
the four segment registers and this way of Addressing,
notation,
ised as the CPU in the micro
processor. The 8086 microprocessor
address to the contents of at
of
the memory is called segment: offset
‘The Microsoft Macro Assembler is an X86 assembler that
and Windows,
uses the Intel syntax for MS-DOS
|
Structure of an assembly language program
Assembly language programs are divided into four sections
© Header
© Data |
* Code
* Closing
‘The header
‘The header contains various directives which do not
Produce machine codes.
‘Sample header:
ASSUME —CS:CODE, _Ds:DaTA
‘The data segment
‘The data segment begins with the dire.
directive. Two kinds of variables are there,
“data segment” and ends with ‘data ends*
alized and uninitialized,
Program data and storage
Pseudo ops are used to define data or reserved ‘storage:
+ DB - byte
* DW - word
+ DD - double word
+ DQ - Quad word
ancl Microprocessors LabCSL.331- Lab Manual, Semester 5, CSE Dept, KMEA3
* DT = Tenbyte
Defining data
Examples for numeric data values
too = decimal
1006 - binary
00h = hexadecimal
“100” - ASCII
“100 - ASCII
A list of vatues can be defined using ARRAY
ARRAY = DW 4 Ch, 10b, 13, 0
A? represents an uninitiated storage location
RESULT DB?
‘The code segment |
Code segment begins with code segment directive and ends with code ends directive.
Afier code segment directive START is used to indicate start of program. Each line of the
Code is divided into four columns: label, mnemonics, operands and comments
Tabels refer to the position of variables and instructions represented by. the
mnemonies, Operands are requested by most assembly language instructions and the
instructions are operated an the operands. Comments aid in remembering the purpose of
Various instructions.
‘The closing of the program is indicated by the directives
CODE ENDS
END START
‘These directives indicate the assembler that it has reached the end of the
Program.
Assembling a program :
‘The source file of an assembly language program is usually named with an extension‘The source file ts
object file obj
‘The command masm my prog prodices myprog obj
‘The object file tust be linked by the linker (TLINK) to produce an executable file
(exe)
‘The command link myprog prosdices myprop.exe
‘TWopat and output using KOK Assembly language
Most ingwut and output is not done directly via the © ports because port address vary
Aanvong computer inodels, There are BOS routines and DOS routines fay handling VO Castine
(interrupt number 21h),
Tnterrnpes
Te interrupt instevction is vied to cause a software interrupt (System call) Ar
(ierrupt interrupts the currently running program and execute the subroutines ancl transfor
‘he control back to the original program after the completion of subroutine, The interrupts
‘may be caused by hardware Or software. int 21h is an example for saflware interrupt
‘Output to monitor
‘DOS internupte: imerruypt 21h is» DOS inerrupt that invokes one of the many
SuPpORtng routines provided by KOS. The Dow fimetion is selected via AH register, Other
Fepiatars may serve as arguments. For displaying h character ropister AN vortainy the value
AN and register Dt cointainn the ASCH value of the charter,
Forutpatting a sting the register At contains the vale ODI andl repister DX
‘omuli th offet to the string in tho data sean, The string is torminated with “character,
Input w character