Code Segment and Data Segment.ĬODE SEGMENT is the starting point of the Code Segment in a Program and CODE is the name given to this segment and SEGMENT is the keyword for defining Segments, Where we can write the coding of the program. Code Segment if at all you don’t need variable(s) for your program.if you need variable(s) for your program you will need two Segments i.e. In this Assembly Language Programming, A single program is divided into four Segments which are 1. START : MOV AX, DATA MOV DS, AX MOV AL ,NUM1 Now, Selection of data type is DB data type the numbers which we are adding will be integers so DB is sufficient.ĮNDS CODE SEGMENT ASSUME DS : DATA CS : CODE
We can write just ENDS But to differentiate the end of which segment it is of which we have to write the same name given to the Data Segment. Detailed explanation is given below.ĭATA ENDS is the End point of the Data Segment in a Program. We are initializing NUM1 to 9H ( H or h stands for Hexadecimal), NUM2 to 7H ( H or h stands for Hexadecimal).
The identified variables are NUM1, and NUM2.ĭATA SEGMENT is the starting point of the Data Segment in a Program and DATA is the name given to this segment and SEGMENT is the keyword for defining Segments, Where we can declare our variables. Let’s identify variables needed for this program.įirst variables will be the one which will hold the values present in the variables to be Added and it will be NUM1 and NUM2.So in all Two variables. Note :- In the permutations above it will work only in the order mentioned above and not by interchanging the first to second and second to first. Hence to do so we have to use combination of MOV and XCHG instructions. it means we can not Exchange any memory variable with another memory variable. Here, we don’t have memory, memory permutation i.e. Third permutation :- REG, REG means Register value can be Exchanged with Register value. Second permutation :- memory, REG means memory value can be Exchanged with Register value. Let us understand the meanings of the above permutations.įirst permutation :- REG, memory means Register value can be Exchanged with memory value. Instruction XCHG is used to EXCHANGE memory variables in the following permutations above. Now we will write another Assembly program which does some Exchange Operation.īefore actually starting to write the program, Let’s understand XCHG instruction.Īs we know the programs work only with the instructions in the instruction set.