banner



What Are The Different Registers In Assembly Language

Assembly - Registers


Processor operations mostly involve processing data. This data tin be stored in retentiveness and accessed from thereon. However, reading data from and storing information into retentiveness slows down the processor, as it involves complicated processes of sending the data request across the control bus and into the memory storage unit and getting the data through the same channel.

To speed up the processor operations, the processor includes some internal retention storage locations, called registers.

The registers shop data elements for processing without having to access the retentivity. A express number of registers are built into the processor fleck.

Processor Registers

There are ten 32-bit and six 16-bit processor registers in IA-32 architecture. The registers are grouped into three categories −

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

The general registers are further divided into the following groups −

  • Information registers,
  • Pointer registers, and
  • Index registers.

Data Registers

Four 32-bit data registers are used for arithmetic, logical, and other operations. These 32-bit registers can be used in three means −

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

  • Lower halves of the 32-bit registers can be used as iv xvi-bit data registers: AX, BX, CX and DX.

  • Lower and college halves of the above-mentioned 4 16-scrap registers tin be used as viii viii-fleck information registers: AH, AL, BH, BL, CH, CL, DH, and DL.

Data Registers

Some of these information registers have specific apply in arithmetical operations.

AX is the chief accumulator; information technology is used in input/output and about arithmetic instructions. For example, in multiplication operation, one 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 register, every bit it could be used in indexed addressing.

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

DX is known as the data register. Information technology is also used in input/output operations. It is as well used with AX register forth with DX for multiply and split up operations involving large values.

Arrow Registers

The pointer registers are 32-bit EIP, ESP, and EBP registers and respective sixteen-bit right portions IP, SP, and BP. There are three categories of pointer registers −

  • Pedagogy Pointer (IP) − The 16-bit IP register stores the offset address of the next teaching to be executed. IP in association with the CS annals (every bit CS:IP) gives the consummate address of the current teaching in the lawmaking segment.

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

  • Base Pointer (BP) − The xvi-chip BP register mainly helps in referencing the parameter variables passed to a subroutine. The address in SS register is combined with the outset in BP to go the location of the parameter. BP can also be combined with DI and SI equally base register for special addressing.

Pointer Registers

Alphabetize Registers

The 32-fleck index registers, ESI and EDI, and their 16-fleck rightmost portions. SI and DI, are used for indexed addressing and sometimes used in addition and subtraction. There are ii sets of index pointers −

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

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

Index Registers

Command Registers

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

Many instructions involve comparisons and mathematical calculations and change the condition of the flags and some other provisional instructions test the value of these status flags to take the command flow to other location.

The common flag bits are:

  • Overflow Flag (OF) − It indicates the overflow of a loftier-guild bit (leftmost flake) of data after a signed arithmetic operation.

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

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

  • Trap Flag (TF) − It allows setting the operation of the processor in single-step mode. The DEBUG plan we used sets the trap flag, so we could step through the execution one instruction at a fourth dimension.

  • 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 following the arithmetics operation. The sign is indicated by the high-order of leftmost bit. A positive result clears the value of SF to 0 and negative result sets it to 1.

  • Zero Flag (ZF) − It indicates the issue of an arithmetic or comparison operation. A nonzero result clears the aught flag to 0, and a cypher event sets information technology to 1.

  • Auxiliary Bear Flag (AF) − It contains the acquit from scrap 3 to bit 4 following an arithmetics operation; used for specialized arithmetic. The AF is set when a ane-byte arithmetic operation causes a carry from bit iii into chip four.

  • Parity Flag (PF) − Information technology indicates the total number of i-$.25 in the consequence obtained from an arithmetic operation. An even number of 1-$.25 clears the parity flag to 0 and an odd number of 1-$.25 sets the parity flag to 1.

  • Carry Flag (CF) − Information technology contains the bear of 0 or 1 from a high-order fleck (leftmost) afterward an arithmetic operation. It also stores the contents of last bit of a shift or rotate operation.

The post-obit table indicates the position of flag bits in the 16-bit Flags register:

Flag: O D I T Due south Z A P C
Chip no: 15 xiv thirteen 12 11 10 9 viii 7 half dozen 5 4 iii two i 0

Segment Registers

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

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

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

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

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

In assembly programming, a program needs to access the memory 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 10. And then, the rightmost hex digit in all such memory addresses is 0, which is non generally stored in the segment registers.

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

Example

Await at the following uncomplicated program to understand the use of registers in assembly programming. This program displays 9 stars on the screen along with a simple message −

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

When the above code is compiled and executed, it produces the post-obit outcome −

Displaying 9 stars *********        

Useful Video Courses


Assembly Programming For All Platforms, Learn To Code

Video

VLSI, PLC, Microcontrollers, and Assembly Language

Video

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

Posted by: eadieeavelifire.blogspot.com

0 Response to "What Are The Different Registers In Assembly Language"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel