Lecture 4 (B)
Lecture 4 (B)
• Stack
• Data
• Code
The size of code and data of a program can be specified by memory model
using .MODEL directive
.MODEL Memory_model
• The stack area should be big enough to contain the stack at its
maximum size.
• Declaration:
.STACK size
.STACK 100H
** Allocates 100 bytes for stack area reasonable size for most
applications
.DATA
WORD1 DW 2
BYTE1 DB 1
Declaration:
name PROC
name ENDP
Here name = name of the procedure. PROC and ENDP are pseudo-ops
Program Structure
.MODEL SMALL
.STACK 100H
.DATA
. CODE
MAIN PROC
;instructions go here
MAIN ENDP
END MAIN
*** The last line of the program should be the END directive, followed by the name of main
procedure
Instruction: INT (Appendix C)
INT: Interrupt option stops the continuous progress of an activity or process.
Syntax:
INT interrupt_number
***A particular function is requested by placing a function number in the AH register and invoking INT 21h .
*** INT 21h functions expect input values to be in certain registers and return output values to other
registers
MAIN ENDP
END MAIN
Programming Steps
Editor Create source program
.ASM file
.OBJ file
.EXE file
Instruction: LEA
• Usually, DS does not contain the segment number of the data segment.
• Thus, a program with data segment will start with these two instruction
MOV DS,AX
Solve the Following