What Happen if I Store 16 Bit Register to 32 Bit Register
Assembly - Registers
Processor operations mostly involve processing data. This data can exist stored in memory and accessed from thereon. However, reading data from and storing information into retention slows down the processor, every bit it involves complicated processes of sending the data asking across the control passenger vehicle and into the retentivity storage unit and getting the data through the aforementioned channel.
To speed upward the processor operations, the processor includes some internal memory 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 ten 32-chip and six 16-chip processor registers in IA-32 compages. The registers are grouped into iii categories −
- Full general registers,
- Control registers, and
- Segment registers.
The general registers are further divided into the following groups −
- Data registers,
- Pointer registers, and
- Alphabetize registers.
Data Registers
Four 32-scrap data registers are used for arithmetics, logical, and other operations. These 32-bit registers can exist used in 3 means −
-
As complete 32-scrap data registers: EAX, EBX, ECX, EDX.
-
Lower halves of the 32-bit registers can be used equally four sixteen-fleck data registers: AX, BX, CX and DX.
-
Lower and higher halves of the higher up-mentioned four sixteen-flake registers tin can be used as eight 8-bit information registers: AH, AL, BH, BL, CH, CL, DH, and DL.
Some of these information registers take specific use in arithmetical operations.
AX is the principal accumulator; it is used in input/output and most arithmetics instructions. For case, in multiplication functioning, ane operand is stored in EAX or AX or AL register according to the size of the operand.
BX is known equally the base annals, equally it could be used in indexed addressing.
CX is known as the count register, as the ECX, CX registers shop the loop count in iterative operations.
DX is known equally the data register. It is likewise used in input/output operations. It is as well used with AX register along with DX for multiply and divide operations involving large values.
Pointer Registers
The pointer registers are 32-flake EIP, ESP, and EBP registers and respective xvi-bit right portions IP, SP, and BP. There are three categories of pointer registers −
-
Educational activity Pointer (IP) − The 16-scrap IP register stores the beginning address of the next instruction to be executed. IP in association with the CS annals (as CS:IP) gives the complete address of the electric current education in the lawmaking segment.
-
Stack Pointer (SP) − The 16-bit SP register provides the get-go value inside the plan stack. SP in association with the SS annals (SS:SP) refers to be current position of data or address within the program stack.
-
Base of operations Arrow (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 offset in BP to get the location of the parameter. BP tin also be combined with DI and SI every bit base register for special addressing.
Alphabetize Registers
The 32-flake index registers, ESI and EDI, and their 16-chip rightmost portions. SI and DI, are used for indexed addressing and sometimes used in improver and subtraction. There are 2 sets of index pointers −
-
Source Index (SI) − It is used as source index for string operations.
-
Destination Index (DI) − It is used as destination index for cord operations.
Command Registers
The 32-bit teaching pointer register and the 32-scrap flags register combined are considered as the control registers.
Many instructions involve comparisons and mathematical calculations and modify the status of the flags and some other conditional instructions test the value of these status flags to have the control period to other location.
The common flag $.25 are:
-
Overflow Flag (OF) − It indicates the overflow of a high-society bit (leftmost bit) of information subsequently a signed arithmetics operation.
-
Direction Flag (DF) − It determines left or right direction for moving or comparing cord data. When the DF value is 0, the string operation takes left-to-right direction and when the value is prepare to one, the cord operation takes correct-to-left direction.
-
Interrupt Flag (IF) − Information technology 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 set to 1.
-
Trap Flag (TF) − It allows setting the operation of the processor in single-step manner. The DEBUG program we used sets the trap flag, and then we could pace through the execution 1 instruction at a time.
-
Sign Flag (SF) − It shows the sign of the issue of an arithmetics performance. This flag is set according to the sign of a data particular following the arithmetic 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 one.
-
Zero Flag (ZF) − It indicates the result of an arithmetic or comparison operation. A nonzero consequence clears the naught flag to 0, and a naught effect sets it to 1.
-
Auxiliary Carry Flag (AF) − It contains the carry from bit 3 to bit iv following an arithmetic functioning; used for specialized arithmetic. The AF is prepare when a i-byte arithmetic operation causes a carry from flake 3 into bit 4.
-
Parity Flag (PF) − It indicates the total number of 1-$.25 in the effect obtained from an arithmetic performance. An fifty-fifty number of 1-$.25 clears the parity flag to 0 and an odd number of one-bits sets the parity flag to 1.
-
Carry Flag (CF) − It contains the conduct of 0 or 1 from a high-gild scrap (leftmost) after an arithmetics operation. It also stores the contents of last chip of a shift or rotate operation.
The post-obit table indicates the position of flag bits in the 16-scrap Flags register:
| Flag: | O | D | I | T | S | Z | A | P | C | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Bit no: | fifteen | xiv | thirteen | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | four | 3 | 2 | ane | 0 |
Segment Registers
Segments are specific areas defined in a programme for containing data, code and stack. There are 3 main segments −
-
Code Segment − It contains all the instructions to exist executed. A 16-bit Lawmaking Segment register or CS annals stores the starting address of the lawmaking segment.
-
Information Segment − It contains data, constants and work areas. A 16-bit Data Segment register or DS register stores the starting address of the data segment.
-
Stack Segment − It contains information and return addresses of procedures or subroutines. Information technology is implemented as a 'stack' data construction. The Stack Segment register or SS register stores the starting address of the stack.
Apart from the DS, CS and SS registers, there are other actress segment registers - ES (extra segment), FS and GS, which provide additional segments for storing data.
In associates programming, a program needs to access the retentiveness locations. All retentiveness locations inside 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 retentivity addresses is 0, which is not more often than not stored in the segment registers.
The segment registers stores the starting addresses of a segment. To get the exact location of information or education inside a segment, an offset value (or deportation) is required. To reference whatsoever retention location in a segment, the processor combines the segment address in the segment register with the showtime value of the location.
Instance
Look at the following uncomplicated program to empathize the use of registers in assembly programming. This program 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 point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,four ;organisation telephone call number (sys_write) int 0x80 ;call kernel mov edx,9 ;message length mov ecx,s2 ;message to write mov ebx,ane ;file descriptor (stdout) mov eax,4 ;system phone call number (sys_write) int 0x80 ;call kernel mov eax,ane ;system 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 lawmaking is compiled and executed, information technology produces the following outcome −
Displaying 9 stars *********
Useful Video Courses
Video
Video
townsontionampicest.blogspot.com
Source: https://www.tutorialspoint.com/assembly_programming/assembly_registers.htm
0 Response to "What Happen if I Store 16 Bit Register to 32 Bit Register"
Post a Comment