This action might not be possible to undo. Are you sure you want to continue?
Writing a program in assembly language requires knowledge of the computer’s instruction set, the rules of its use, and the hardware on which it runs. An assembly language program consists of one or more segments for defining data and for machine instructions and a segment named the stack that contains stored addresses.
will utilize ROM (Read-only Memory), the important feature of ROM in programming is its Basic Input/Output System (BIOS), RAM (Random Access Memory) , its importance is its availability as a “worksheet” for temporary storage and execution of programs, and Addressing Memory Locations, an assembly language programmer has to distinguish between the address of memory location and its contents.
segment is an area in memory that begins on a paragraph boundary.
TYPES OF SEGMENTS
Segment Data Segment Stack Segment Segment Boundaries
Segment – the code segment contains the machine instructions that are to execute. Typically, the first executable instruction is at the start of this segment, and the operating system links to this location for program execution. The CS (code segment) register addresses this segment.
Segment – The data segment contains a program’s defined data, constants, and work areas. The DS (data segment) register addresses this segment.
Segment – the stack contains any data addresses that you need to save temporarily for your own “called” subroutines to return to your main program. The SS (stack segment) register addresses this segment.
segment registers contain the starting address of each segment. Extra segment registers are the ES.
memory locations are relative to the start of a segment. The distance in bytes is expressed as an offset (or displacement) from the start of a segment. For example: a two-byte (16-bit) offset can range from hex 0000 through hex FFFF or 0 through 65,535. Thus the first byte of the code segment is at offset 00, the second byte is at offset 01, and so forth, through to offset 65,535.
processor’s registers are used to control instructions being executed, to handle addressing of memory, and to provide arithmetic capability. The registers are addressable by name. Bits are conventionally numbered from right to left.
segment register is 16 bits long and provides for addressing an area of memory, known as the current segment.
code segment register contains the initial address of a program’s code segment. This address plus an offset value in the instruction pointer (IP) register indicates the address of an instruction to be fetched for execution.
data segment register contains the initial address of a program’s data segment. In simple terms, this address plus an offset value in an instruction causes a reference to a specific byte location in the data segment.
stack segment register permits implementation of a stack in memory, used for temporary storage of addresses and data. The SS register contains the starting address of the program’s stack segment. This address plus an offset value in the stack pointer (SP) register indicates the current word in the stack being addressed.
string (character data) operations use the extra segment register to handle memory addressing. In his context, the ES register is associated with the DI register.
Instruction Pointer Register (IP)
16-bit IP register contains the offset address of the instruction that is to execute next. The IP is associated with the CS register such that the IP indicates the current instruction within the currently executing code segment.
pointer registers, SP and BP, are associated with the SS register and permit the system to access data in the stack segment.
16-bith stack pointer is associated with the SS register and provides an offset value that refers to the current word being processed in the stack.
16-bit base pointer facilitates referencing parameters, which are data and addresses passed via the stack.
General Purpose Registers
AX, BX, CX and DX generalpurpose registers are the workhorses. They are unique in that you can address them as one word or as a one-byte portion. The leftmost byte is the “high” portion and the rightmost byte is the “low” portion.
For example, the CX register consists of a CH and a CL portion, and you can reference any of the three names.
following instructions move zeros to the CX, CH, and CL respectively: MOV MOV MOV CX, 00 CH, 00 CL, 00
AX register, the primary accumulator, is used for operations involving input/output and most arithmetic.
BX is known as the base register since it is the only general-purpose register that can be used as an “index” to extend addressing.
CX is known as the count register. It may contain a value to control the number of times a loop is repeated or a value to shift bits left or right.
DX is known as the date register. Some input/output operations require its use, and multiply and divided operations that involve large values assume the DX and AX pair.
index registers are available for extended addressing and for use in addition and subtraction.
16-bit source index register is required for some string (character) operation. In this context, the SI is associated with the DS register.
16-bit destination index register is also required for some string operations. In this context, the DI is associated with the ES register.
of the 16 bit of the flags register are common to all 8086-family processors to indicate the current status of the machine and the results of execution. The FLAGS Register consists of 9 status bits. These bits are also called flags, because they can either be SET (1) or NOT SET (0). All these flags have a name and purpose.