Monday, April 25, 2016

What is Code Segment? With Example

Code Segment : The code segment contains a program's instructions. The declaration syntax is

.CODE           name

Where name is the optional name of the segment(there is no need for a name in a SMALL program, because the assembler will generate an error).

Inside a code segment, instructions are organized as procedures. The simplest procedure definition is

name    PROC
;body   of   the   procedure
name    ENDP


where name is the name of the procedure, PROC and ENDP are pseudo-ops that delineate the procedure.


Here is an example of a code segment definition :

.CODE
MAIN PROC
;main procedure instructions
MAIN ENDP
;other procedure go here