Microprocessor Systems: Dr. Mona Sayed
Microprocessor Systems: Dr. Mona Sayed
Microprocessor Systems: Dr. Mona Sayed
Lecture Notes # 7
There are three data items in this sample program: DATA1, DATA2
and SUM. Each is defined as DB (define byte).
The DB directive is used to allocate memory in byte-sized chunks.
DW (define word) allocates 2 bytes of memory. DATA1 and DATA2
have initial values but SUM is reserved for later use.
Code segment definition
The first line after the SEGMENT directive is the PROC directive. A procedure is a
group of instructions designed to accomplish a specific function.
The PROC and ENDP directives must have the same label. The PROC directive may
have the option FAR or NEAR. DOS requires FAR option to be used at the program
entry.
ASSUME directive associates segment registers with specific segments by assuming
that the segment register is equal to the segment labels used in the program.
Note that there can be many segments of the same type. So Assume helps to
differentiate which is to be used at a time.
DOS determines the CS and SS segment registers automatically. DS has to be
manually specified.
MOV AX,DTSEG ;load the data segment address
MOV DS,AX ;assign value to DS
Load AL and BL with DATA1 and DATA2 and ADD them together, and store the result in
SUM.
MOV AL,DATA1 ;get the first operand
MOV BL,DATA2 ;get the second operand
ADD AL,BL ;add the operands
MOV SUM,AL ;store result in location SUM
The last two instructions returns the control to the operating system.
MOV AH,4CH ;set up to
INT 21H ;return to DOS
SIMPLIFIED SEGMENT DEFINITION