Assembly Register, Code Structure

Narisca

İstihbarat Tim
11 Mar 2021
394
128
Londra
Assembly Register Code Structure

------------------------------------------------------------------------------------------------

Data Division
The Data section is used to declare initiated data or constants. This data does not change at run time. Various constants, file names, or buffer size, and so on. you can declare.

The syntax for declaring data is =
section.data

Bss Division =
BSS bölümü değişkenleri bildirmek için kullanılır.

BSS the syntax for declaring a partition is as follows =
section.bss

Text Division =
The text section is used to hold the actual code. This section should begin with the global _start notification, which tells the kernel where the program execution began.

Syntax for declaring a text section =
section.text
global _start
_start:


-------------------------------------------------------------------------------------------------------------------
Assembly Registers

Processor operations mostly involve data processing. This data can be stored in memory and accessed from there. However, reading data from memory and storing it in memory slows down the processor because it involves complex operations to send the data request over the control bus and into memory storage and receive the data through the same channel.

To speed up processor operations, the processor contains some internal memory storage called records.

Stores records to handle data items without having to access memory. A limited number of registers are embedded in the processor chip.

Processor Register=

The IA-32 architecture has ten 32-bit and six 16-bit processor registers.

Records fall into three categories =

1- General Registers
2- Control Registers
3- Segment registers.


General records are also divided into the following groups =

1- Data Registers
2- Pointer Registers
3- İndex Registers

------------------------------------------------------------------------------------------------
Data Registers =
Four 32-bit data registers are used for arithmetic, logical, and other operations.

These 32-bit records can be used in three ways =
1-Complete 32-bit Data Records as: EAX, EBX, ECX, EDX.
The bottom half of 2 - 32-bit records can be used as four 16-bit data records: AX, bx, CX, and DX.
3-the lower and higher half of the four 16-bit records mentioned above can be used as eight 8-bit data records: AH, AL, BH, BL, CH, CL, DH, and DL.

ch4kGs.jpg


Some of these data records have special use in arithmetic operations.

AX is the primary accumulator; used in input/output and most arithmetic instructions. For example, in multiplication, an operand is stored in the eax or AX or AL register according to the size of the operand.

BX is known as the base register, as it can be used in indexed addressing.

CX is known as Count record, as ECX, CX Records store the number of cycles in iterative operations.

DX is known as the data register. It is also used in input / output operations. It is also used with the AX register in conjunction with DX for multiplication and division operations involving large values.
------------------------------------------------------------------------------------------------
Pointer Registers =
The pointer records are 32-bit EIP, ESP, and EBP records, and the corresponding 16-bit right partitions are IP, SP, and BP.

There are three categories of pointer records =

1- Instruction Pointer (IP) = The 16-bit IP record stores the offset address of the next instruction to be executed. IP (as CS: IP), along with the CS record, returns the full address of the current instruction in the code segment.

2- Stack Pointer (SP) = The 16-bit SP record provides the offset value in the program stack. In connection with the SS record (SS:SP), SP refers to the current of the data or address in the program stack.

3- Base Pointer (BP) = The 16-bit BP record mainly helps to refer to parameter variables passed to a subroutine. The address in the SS register is combined with the offset in BP to get the position of the parameter. BP can also be combined with DI and Si as the basic register for private addressing.



-------------------------------------------------------------------------------------------------------------------

Index Registers =
The 32-bit instruction pointer record and the 32-bit flag record are considered unified control records.

Many instructions include comparisons and mathematical calculations and change the state of the flags, and some other conditional instructions test the value of these state flags to move the control flow elsewhere.

Common flag bits are:

Owerflow Flag (OF) = Indicates a data overflow of a higher-order bit (the leftmost bit) after a signed arithmetic operation.

Direction Flag (DF) = Specifies the left or right direction to move or compare string data. When the DF value is 0, the string operation takes a left-to-right direction, and when the value is set to 1, the string operation takes a right-to-left direction.

Interrupt Flag (IF) = Keyboard input of external interrupts, etc.determines whether it is like., will be ignored or processed. Disables external interruption when the value is 0, and enables interrupts when it is set to 1.

Trap Flag (TF) = Allows you to set the operation of the processor in one-step mode. The debug program we use sets the trap flag so we can step up to execute one command at a time.

Sign Flag (SF) = Indicates the sign of the result of an arithmetic operation. This flag is set according to the sign of a data item that follows the arithmetic operation. The sign is indicated by the high order of the leftmost bit. The positive result clears the SF value to 0 and the negative result sets it to 1.

Zero Flag (ZF) = Indicates the result of an arithmetic or comparison operation. A nonzero result clears the zero flag to 0 and sets the zero result to 1.

Auxiliary Carry Flag (AF) = It involves moving from bit 3 to bit 4 after arithmetic; it is used for special arithmetic. AF is set when a 1-byte arithmetic operation causes bit 3 to be moved from bit 4.

Parity Flag (PF) = Indicates the total number of 1 bits in the result from an arithmetic operation. An even 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) = It involves moving 0 or 1 from a higher-order bit (leftmost) after an arithmetic operation. It also stores the contents of the last bit of a scroll or rotation operation.
------------------------------------------------------------------------------------------------

Segment Registers =
Segments are specific fields defined in a program that contains data, code, and stacks.

There are three main sections =

1- Code Segment = Contains all instructions to execute. The 16-bit code segment register, or CS register, stores the starting address of the code segment.
2- Data Segment = Contains data, constants, and workspaces. The 16-bit data segment record or DS record stores the starting address of the data segment.
3- Stack Segment = Contains the data and return addresses of procedures or subroutines. It is implemented as a' stack ' data structure. The stack segment record or SS record stores the initial address of the stack.

In addition to DS, CS, and SS records, there are other extra segment records, such as ES (extra segment), FS, and GS, which provide additional segments for storing data.In assembly programming, a program must access memory . All memory within a segment are relative to the segment's start address. A segment begins at an address that can be divided equally by 16 or hexadecimal 10. Therefore, the rightmost hexadecimal digit in all these memory addresses is 0, which is not usually stored in segment registers. Segment Records store the initial addresses of a segment. An offset value (or displacement) is required to obtain the exact of data or instructions within a segment. To refer to any memory in a segment, the processor combines the segment address in the segment register with the offset value .​
 
Son düzenleme:

Dolyetyus

International Team Leader
21 Nis 2020
910
80
Leiden
Nice article, but can you please add source at the bottom?

Additionally, don't forget to correct censored words like Iocation or méta
 
Son düzenleme:

THT SON MESAJLAR

Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.