Партнерка на США и Канаду по недвижимости, выплаты в крипто

  • 30% recurring commission
  • Выплаты в USDT
  • Вывод каждую неделю
  • Комиссия до 5 лет за каждого referral

The Rule of recording multi-bytes numbers in Intel microprocessors (“little endian” method): the junior byte is located at the junior address and the senior one at the senior address of the memory.

Address of some area of the memory, considered as a word, is equal to the junior byte’s address.

Simple Data Types in Assembly.

The rules of description simple data types serve as a base for description all types. Special directives serve for this aim.

Directives, which contain after letter D (Define) abbreviations of machinery types of data (DB(byte), DW(word), DD(double), DQ(quad), DT(tera)) are intended for static data determination and its reservation for storing. (DB – 1 byte, DW – 2 bytes, DD – 4 bytes, DQ – 8 bytes, DT – 10 bytes)

These directives transform the symbolic designations of constants into internal form for the processing by machinery instructions, procedures and functions.

Binary Coded Decimals (BCD).

Numbers, which are used in business applications must be large and precise. These requirements cause special difficulties for programming in assembly, where as a rule comparatively short binary numbers are used. Diapason as of 16 bits values, so of 32 bits values often doesn’t satisfy applications, for which it is necessary process precisely very large (up to 20-width) values.

One of the ways for solving this problem is a storage of data in a form of binary coded decimals, which are easily may be transformed into ASCII codes and vice versa; these representation allows storing of quite large numbers (which may contain up to 20 digits). There are two types of BCD numbers:

НЕ нашли? Не то? Что вы ищете?

-  Packed BCD, which store 2 digits in one byte in usual for separate digits order, i. e. from senior ranges (more significant) to junior (less significant) ones, but what concerns bytes – in order from junior to senior, correspondingly.

-  Unpacked BCD store only one digit in one byte, and order bytes as from junior to senior, so vice versa.

Packed BCD store 2 decimal digits in each byte in a binary form (so, as 4 bits may represent binary value in a diapason from 0 up to 15, that is why there are some additional place for representation values from 0 up to 9 in every byte). Unpacked BCD are used as intermediate form for transforming packed BCD in ASCII symbols and conversely. There is a direct correspondence with ASCII symbols and unpacked BCD.

Structure is a type of data, which consists of fixed number of elements of different characteristics.

Structures can be considered as pictures with descriptions of data formats, which may be patched (наложены) on different areas of memory with a purpose – to have a possibility for addressing to fields of these areas with help of mnemonic names, which are determined in the structure description.

Structures are especially useful in cases, when it is necessary to address for memory areas, which haven’t been included in program’s segments (i. e. to such fields, which are not possible to describe with help of symbolic names). Structures are also used in such situations, when a program includes complex collections of data, which repeat many times and have different meanings.

For using structures in the program, it is necessary:

1.  To set a picture of the structure, i. e. to determine a new type of data, which will be used in future for determination of variables of this type;

2.  To determine an exemplar of the structure, i. e. to initialize a certain variable with the beforehand determined (with help of the picture) structure;

3.  To organize access (addressing) to this variable.

It is important to distinguish two concepts: description of structure and structure determination.

“To describe a structure” in the program means, that a scheme or a picture is to be pointed out; in this case the memory will not be allotted. The picture (or the scheme) may be considered only as information for the translator: how the fields will be located, and what are their meanings on default.

“To determine a structure” means pointing out to the translator to allot the memory and give a certain name for the allotted part of memory.

Structure may be described only once, but it can be determined many times.

The description of a structure has got the following syntax:

name_of_structure STRUC

<description of fields>

name_of_structure ENDS

here <description of fields> is a sequence of directives of data description: DB, DW, DD, DQ or DT, their operands determine sizes of fields and may be given some initial meanings (by these meanings it is possible to initialize corresponding fields, during the structure determination).

The picture of structure should be described in the program before the place, where a variable of the type of the given structure is determined.

Structure determination (determination data of the given type of structure).

For using the described with help of picture structure, it is necessary to determine all variables with type of given structure. For this purpose serves the following syntax construction:

[name_of_variable] name_of_structure <[list of meanings]>

here

name_of_variable is an identifier of the variable of the given structure type. The setting of it is not compulsory, and if it hasn’t been set, then an area of memory, which is equal to the sum of lengths of all structure elements, will be allotted.

<[list of meanings]> is a list of initial meanings, separated by commas. The setting of the list is also not compulsory, and if it hasn’t been pointed out, then all the fields of the given variable are initialized by the picture meanings (if such had been envisaged). It is also possible to initialize only some separate fields, but in this case the omitted fields will be initialized by meanings from the structure’s picture, and they must be separate by commas. If you agree with all meanings of fields, which have been pointed in the structure’s picture (i. e. set by default), then you should put angular brackets.

Record is a structure type of data, which consists from the fixed number of elements of the size from one up to a number of bits.

When a record is described, then for each element its length in bits is pointed out, and, what is not compulsory, its meaning is also pointed our. The total length of a record is determined by the sum of its fields and can’t be more than 8, 16 or 32 bits. If the total length of the record is less than the pointed sizes, then all fields of the record will be “clasped” to the junior ranges.

The using of records in a program are organized in three stages:

1.  Setting a picture of record, i. e. determination of bits fields, their lengths, and, if it’s necessary, initialization of the fields;

2.  Determination of record exemplar. As it is made for structures, this stage means initialization of certain variable by type of beforehand determined record with help of picture.

3.  Organization of addressing to the record’s elements.

Record Description.

The description of picture has got the following syntax:

name_of_record RECORD <description of elements>

here

<description of elements> is a sequence of different elements descriptions according the syntax diagram:

 

As for any structure, during description of the record picture the memory is not allotted, and location of it may by arbitrary, but with an account of program executing logic (or logic of one passage translator work).

How is determined an exemplar of Record?

In order to use the described picture of Record, it is necessary to determine variables with a type of given Record; for this purpose the following syntax construction is used:

 

Name of field

 

Expression

 
Овал: =.Овал: ,

Work with Records.

It is not possible to use usual mechanisms for addressing to record’s elements, because they work on the bytes level (but in this case we work on the bit’s level). In this situation it is important to understand the following moments:

·  to each element of record the translator (assembly) puts in correspondence (assigns) a numeric value, which is equal to a number of shifts to the right (this number of shifts is necessary to execute in order the element will be at the beginning of the cell, or will be “clasped” to the right border of cell), that procedure is necessary for the localizing this element in order to have a possibility to work with it (for this purpose it is necessary to know a length of this element);

·  the shift to the right is performed with help of instruction shr ;

·  with help of operator width it is possible to determine a size of element (or the record as a whole) in bits. There are the next variants of using this operator

°  width name_of_record’s_element – the meaning of this operator will be a size of the element in bits;

°  width name_of_record’s_examplar

or

width name_of_record’s_type

·  the Assembly has an operator mask, which allows to localize bits of record’s element. This localization is realized by creation a mask, the size of which coincides with the size of the record. In such mask all bits, except bits of the given element, are zerofilled (обнулены);

Из за большого объема этот материал размещен на нескольких страницах:
1 2 3 4 5 6