banner



What Is The Value Of The D Register After First Time Insturction Is Executed

Assembly - Registers


Processor operations mostly involve processing data. This data tin can exist stored in retention and accessed from thereon. Nonetheless, reading data from and storing information into memory slows downwardly the processor, as information technology involves complicated processes of sending the data asking across the control jitney and into the retention storage unit and getting the data through the aforementioned channel.

To speed upwards the processor operations, the processor includes some internal retentivity storage locations, called registers.

The registers store data elements for processing without having to access the memory. A limited number of registers are built into the processor chip.

Processor Registers

There are 10 32-chip and six 16-fleck processor registers in IA-32 compages. The registers are grouped into 3 categories −

  • General registers,
  • Command registers, and
  • Segment registers.

The general registers are further divided into the following groups −

  • Data registers,
  • Pointer registers, and
  • Index registers.

Data Registers

4 32-flake data registers are used for arithmetics, logical, and other operations. These 32-chip registers tin can be used in three ways −

  • As complete 32-bit data registers: EAX, EBX, ECX, EDX.

  • Lower halves of the 32-scrap registers can be used as 4 16-chip data registers: AX, BX, CX and DX.

  • Lower and higher halves of the above-mentioned iv xvi-flake registers can exist used as 8 8-scrap information registers: AH, AL, BH, BL, CH, CL, DH, and DL.

Data Registers

Some of these data registers have specific use in arithmetical operations.

AX is the primary accumulator; it is used in input/output and most arithmetic instructions. For example, in multiplication operation, 1 operand is stored in EAX or AX or AL annals according to the size of the operand.

BX is known as the base of operations annals, every bit it could exist used in indexed addressing.

CX is known as the count register, equally the ECX, CX registers shop the loop count in iterative operations.

DX is known as the information register. It is also used in input/output operations. It is also used with AX register along with DX for multiply and divide operations involving large values.

Pointer Registers

The pointer registers are 32-bit EIP, ESP, and EBP registers and corresponding xvi-flake right portions IP, SP, and BP. At that place are iii categories of arrow registers −

  • Didactics Pointer (IP) − The 16-bit IP register stores the starting time address of the next instruction to be executed. IP in clan with the CS register (as CS:IP) gives the complete address of the current instruction in the code segment.

  • Stack Pointer (SP) − The 16-bit SP register provides the offset value inside the program stack. SP in association with the SS register (SS:SP) refers to exist electric current position of information or address within the program stack.

  • Base Pointer (BP) − The xvi-bit BP register mainly helps in referencing the parameter variables passed to a subroutine. The address in SS register is combined with the offset in BP to get the location of the parameter. BP can besides be combined with DI and SI as base register for special addressing.

Pointer Registers

Index Registers

The 32-bit index registers, ESI and EDI, and their 16-bit rightmost portions. SI and DI, are used for indexed addressing and sometimes used in addition and subtraction. In that location are two sets of index pointers −

  • Source Index (SI) − It is used as source index for cord operations.

  • Destination Index (DI) − It is used as destination index for cord operations.

Index Registers

Control Registers

The 32-bit instruction pointer register and the 32-scrap flags register combined are considered every bit the control registers.

Many instructions involve comparisons and mathematical calculations and change the status of the flags and some other conditional instructions examination the value of these status flags to take the control flow to other location.

The common flag bits are:

  • Overflow Flag (OF) − It indicates the overflow of a high-order bit (leftmost fleck) of information after a signed arithmetics performance.

  • Direction Flag (DF) − It determines left or right direction for moving or comparing string data. When the DF value is 0, the string operation takes left-to-right direction and when the value is set to 1, the string operation takes right-to-left direction.

  • Interrupt Flag (IF) − It determines whether the external interrupts like keyboard entry, etc., are to be ignored or processed. It disables the external interrupt when the value is 0 and enables interrupts when prepare to i.

  • Trap Flag (TF) − It allows setting the operation of the processor in single-step mode. The DEBUG program nosotros used sets the trap flag, so we could stride through the execution 1 instruction at a time.

  • Sign Flag (SF) − It shows the sign of the result of an arithmetic operation. This flag is set according to the sign of a data item post-obit the arithmetics functioning. The sign is indicated past the high-order of leftmost chip. A positive result clears the value of SF to 0 and negative outcome sets it to 1.

  • Nada Flag (ZF) − It indicates the effect of an arithmetic or comparison operation. A nonzero result clears the zippo flag to 0, and a null result sets information technology to 1.

  • Auxiliary Acquit Flag (AF) − It contains the conduct from bit 3 to bit iv following an arithmetics operation; used for specialized arithmetic. The AF is set up when a 1-byte arithmetic operation causes a deport from fleck 3 into scrap 4.

  • Parity Flag (PF) − Information technology indicates the total number of ane-bits in the outcome obtained from an arithmetic performance. An fifty-fifty number of 1-bits clears the parity flag to 0 and an odd number of 1-bits sets the parity flag to 1.

  • Carry Flag (CF) − Information technology contains the carry of 0 or 1 from a high-order bit (leftmost) after an arithmetics operation. It as well stores the contents of final bit of a shift or rotate functioning.

The following table indicates the position of flag bits in the 16-scrap Flags annals:

Flag: O D I T S Z A P C
Bit no: 15 14 13 12 xi 10 nine 8 7 six 5 4 3 two ane 0

Segment Registers

Segments are specific areas defined in a program for containing data, code and stack. There are three chief segments −

  • Lawmaking Segment − It contains all the instructions to be executed. A xvi-fleck Lawmaking Segment register or CS register stores the starting address of the code segment.

  • Data Segment − It contains data, constants and work areas. A sixteen-chip Information Segment register or DS register stores the starting address of the information segment.

  • Stack Segment − Information technology contains data and return addresses of procedures or subroutines. Information technology is implemented as a 'stack' data structure. The Stack Segment register or SS register stores the starting address of the stack.

Autonomously from the DS, CS and SS registers, at that place are other extra segment registers - ES (extra segment), FS and GS, which provide additional segments for storing data.

In assembly programming, a plan needs to admission the retentiveness locations. All memory locations within a segment are relative to the starting address of the segment. A segment begins in an address evenly divisible by sixteen or hexadecimal x. And then, the rightmost hex digit in all such memory addresses is 0, which is not generally stored in the segment registers.

The segment registers stores the starting addresses of a segment. To go the exact location of data or educational activity within a segment, an offset value (or displacement) is required. To reference any memory location in a segment, the processor combines the segment accost in the segment register with the offset value of the location.

Example

Wait at the post-obit simple programme to understand the use of registers in assembly programming. This plan displays ix stars on the screen along with a simple message −

section	.text    global _start	 ;must be declared for linker (gcc) 	 _start:	         ;tell linker entry signal    mov	edx,len  ;bulletin length    mov	ecx,msg  ;message to write    mov	ebx,one    ;file descriptor (stdout)    mov	eax,4    ;system call number (sys_write)    int	0x80     ;call kernel 	    mov	edx,ix    ;bulletin length    mov	ecx,s2   ;message to write    mov	ebx,one    ;file descriptor (stdout)    mov	eax,4    ;arrangement call number (sys_write)    int	0x80     ;call kernel 	    mov	eax,i    ;organisation phone call number (sys_exit)    int	0x80     ;telephone call kernel 	 department	.data msg db 'Displaying 9 stars',0xa ;a bulletin len equ $ - msg  ;length of message s2 times 9 db '*'        

When the above code is compiled and executed, information technology produces the following result −

Displaying ix stars *********        

Useful Video Courses


Assembly Programming For All Platforms, Learn To Code

Video

VLSI, PLC, Microcontrollers, and Assembly Language

Video

What Is The Value Of The D Register After First Time Insturction Is Executed,

Source: https://www.tutorialspoint.com/assembly_programming/assembly_registers.htm

Posted by: lynchthouthe1935.blogspot.com

0 Response to "What Is The Value Of The D Register After First Time Insturction Is Executed"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel