Some statement and segment to write Assembly program

Bismillahir Rahmanir Rahim
 Offset address (16bits): 
Displacement of a memory location from the segment base
address is called offset address
• Offset address is contained in pointer and index registers.
• The first byte in a segment has offset 0 and the last offset in a segment is FFFFh ,
determined by the size of pointer and index registers, which are 16bits long.
• The maximum length of a segment is 216 = 65536 bytes » 64Kb
• The maximum length of a program is 4* 216 = 262144 bytes » 256Kb
• Offset registers for
data segment are SI, DI, BX
stack segment are SP, BP
code segment is IP
• The offset address of memory location is defined by the programmer
Effective address: Association shown as REGsegment : REG pointer / index . or
XXXXh:YYYYh – where XXXX is the segment base number , YYYY is the offset
address.
• Segment base numbers are contained in segment registers
• DS for data segment
• SS for stack segment
• CS for code segment
• ES for extra data segment
Segment base number is same for all locations of a segment
• Association of segment and pointer / index registers
• Data segment : DS:SI or DS:DI or DS: BX
• Extra data segment : ES:DI or ES: BX
• Stack segment : SS:SP, SS:BP
• Code segment : CS:IP
Physical (Absolute) address: It is the 20bits address of a memory location.
• Absolute address is equal to segment base number contained in segment register
multiplied by 10h and adding to the offset contained in corresponding pointer or
index registers
Data segment DS*16d + SI
DS*16d + DI
DS*16d + BX
Extra data segment ES*16d + DI
ES*16d + BX
Stack segment SS*16d + SP
SS*16d + BP
Code segment CS*16d + IP
• Physical address is computed in the bus unit of CPU where the segment registers
and Instruction pointer registers are located.
Logical segments of an assembly program :
a) data segment – contains directives to reserve and initialize data variables
b) stack segment – contains directives to reserve and initialize memory locations to
keep return addresses and temporary variables
c) code segment – contains codes to carry out data processing
d) extra data segment - contains directives to reserve and initialize data variables, if
the data segment is full. This segment is optional
Type of assembly statements:
a) Directive: commands to assembler such as SEGMENT, ENDS, DB, DW, DD,
DUP(), ASSUME, SEG, OFFSET
b) Instruction: commands to CPU provided by instruction set such as MOV, ADD,
SUB, MUL, DIV, SHL, SHR, CMP, JMP, Jcondition
Format of assembly statements:
Label: statements ; comments
a) Format of assembly directives
Label: Directive ; comments
b) Format of assembly instruction
Label: Mnemonic Destination, Source ; comments
• Label – named memory location
• Mnemonic – name of operation codes (included in instruction set)
• Destination and source are the addresses of CPU and system memory registers
• CPU register addresses have names given in programming model
• Memory register addresses may be named by programmer or can be used by
its value

Definition of logical segment:

segName SEGMENT
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
segName ENDS

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →