banner



How Many Bytes Are In The Bx Register

Assembly - Registers


Processor operations by and large involve processing information. This data can be stored in memory and accessed from thereon. However, reading data from and storing information into memory slows downwards the processor, every bit information technology involves complicated processes of sending the data request across the control double-decker and into the memory storage unit of measurement and getting the data through the aforementioned channel.

To speed up 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 retentivity. A limited number of registers are built into the processor flake.

Processor Registers

There are x 32-fleck and half-dozen 16-chip processor registers in IA-32 architecture. The registers are grouped into three categories −

  • Full general registers,
  • Control 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-bit information registers are used for arithmetics, logical, and other operations. These 32-bit registers can exist used in three ways −

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

  • Lower halves of the 32-fleck registers tin be used as four 16-bit data registers: AX, BX, CX and DX.

  • Lower and higher halves of the above-mentioned iv 16-bit registers can be used as eight 8-bit data registers: AH, AL, BH, BL, CH, CL, DH, and DL.

Data Registers

Some of these data registers accept specific apply in arithmetical operations.

AX is the master accumulator; it is used in input/output and virtually arithmetic instructions. For example, in multiplication functioning, one operand is stored in EAX or AX or AL register according to the size of the operand.

BX is known equally the base register, as information technology could exist used in indexed addressing.

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

DX is known equally the data register. It is also used in input/output operations. It is also used with AX register forth with DX for multiply and divide operations involving big values.

Pointer Registers

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

  • Didactics Pointer (IP) − The 16-scrap IP register stores the outset address of the next instruction to be executed. IP in association with the CS annals (equally CS:IP) gives the complete address of the current instruction in the lawmaking segment.

  • Stack Arrow (SP) − The xvi-flake SP register provides the kickoff value within the program stack. SP in association with the SS annals (SS:SP) refers to be electric current position of data or address within the program stack.

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

Pointer Registers

Index Registers

The 32-chip alphabetize 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. There are two sets of alphabetize pointers −

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

  • Destination Alphabetize (DI) − It is used as destination index for string operations.

Index Registers

Command Registers

The 32-bit instruction pointer register and the 32-bit flags annals 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 control flow to other location.

The mutual flag $.25 are:

  • Overflow Flag (OF) − Information technology indicates the overflow of a loftier-order flake (leftmost bit) of data after a signed arithmetics operation.

  • Direction Flag (DF) − Information technology determines left or right direction for moving or comparing cord information. When the DF value is 0, the string operation takes left-to-correct management and when the value is set to one, 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 candy. Information technology disables the external interrupt when the value is 0 and enables interrupts when set to one.

  • Trap Flag (TF) − Information technology allows setting the operation of the processor in single-pace style. The DEBUG program nosotros used sets the trap flag, so we could stride through the execution one education at a fourth dimension.

  • Sign Flag (SF) − It shows the sign of the event of an arithmetic operation. This flag is set according to the sign of a information item following the arithmetic operation. The sign is indicated by the loftier-order of leftmost bit. A positive result clears the value of SF to 0 and negative consequence sets it to 1.

  • Naught Flag (ZF) − It indicates the result of an arithmetic or comparison operation. A nonzero effect clears the cipher flag to 0, and a nil effect sets it to 1.

  • Auxiliary Behave Flag (AF) − It contains the carry from bit 3 to bit iv following an arithmetic operation; used for specialized arithmetic. The AF is gear up when a 1-byte arithmetics operation causes a carry from bit iii into bit 4.

  • Parity Flag (PF) − It indicates the total number of 1-bits in the upshot obtained from an arithmetics functioning. 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 one.

  • Conduct Flag (CF) − It contains the carry of 0 or 1 from a high-order bit (leftmost) after an arithmetic functioning. It also stores the contents of last flake of a shift or rotate operation.

The following table indicates the position of flag bits in the sixteen-bit Flags register:

Flag: O D I T S Z A P C
Bit no: 15 14 13 12 xi 10 9 8 7 6 5 4 iii 2 1 0

Segment Registers

Segments are specific areas divers in a plan for containing data, code and stack. At that place are three chief segments −

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

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

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

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

In assembly programming, a programme needs to access the memory locations. All retentivity locations within a segment are relative to the starting address of the segment. A segment begins in an address evenly divisible past 16 or hexadecimal 10. So, the rightmost hex digit in all such memory addresses is 0, which is non mostly 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 offset value (or displacement) is required. To reference whatever retentiveness location in a segment, the processor combines the segment address in the segment register with the offset value of the location.

Example

Look at the following unproblematic program to sympathize the employ of registers in assembly programming. This program displays 9 stars on the screen forth with a elementary bulletin −

section	.text    global _start	 ;must be declared for linker (gcc) 	 _start:	         ;tell linker entry point    mov	edx,len  ;message length    mov	ecx,msg  ;message to write    mov	ebx,1    ;file descriptor (stdout)    mov	eax,four    ;organisation call number (sys_write)    int	0x80     ;call kernel 	    mov	edx,9    ;message length    mov	ecx,s2   ;bulletin to write    mov	ebx,i    ;file descriptor (stdout)    mov	eax,4    ;system telephone call number (sys_write)    int	0x80     ;call kernel 	    mov	eax,ane    ;organisation call number (sys_exit)    int	0x80     ;call kernel 	 section	.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, information technology produces the following result −

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

Useful Video Courses


Assembly Programming For All Platforms, Learn To Code

Video

VLSI, PLC, Microcontrollers, and Assembly Language

Video

How Many Bytes Are In The Bx Register,

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

Posted by: greenwoodflut1945.blogspot.com

0 Response to "How Many Bytes Are In The Bx Register"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel