Редактирование: Константы

Перейти к: навигация, поиск

Внимание! Вы не авторизовались на сайте. Ваш IP-адрес будет публично видимым, если вы будете вносить любые правки. Если вы войдёте или создадите учётную запись, правки вместо этого будут связаны с вашим именем пользователя, а также у вас появятся другие преимущества.

Правка может быть отменена. Пожалуйста, просмотрите сравнение версий, чтобы убедиться, что это именно те изменения, которые вас интересуют, и нажмите «Записать страницу», чтобы изменения вступили в силу.
Текущая версия Ваш текст
Строка 5: Строка 5:
 
   | $IDENT        # Глобальный символ
 
   | $IDENT        # Глобальный символ
  
В [[QBE | промежуточном языке]] константы задаются с помощью единого синтаксиса и семантики. Константы используются явно, непосредственно в инструкциях; нет необходимости в команде «загрузки константы» (из памяти).
 
<pre>Throughout the IL, constants are specified with a unified syntax and semantics. Constants are immediates, meaning that they can be used directly in instructions; there is no need for a "load constant" instruction.</pre>
 
  
Представление целых чисел является [https://ru.wikipedia.org/wiki/Дополнительный_код дополнительным кодом]. Числа с плавающей запятой представлены с использованием одноточечных и двухточечных форматов стандарта [https://en.wikipedia.org/wiki/IEEE_754 IEEE 754].
+
Throughout the IL, constants are specified with a unified syntax and semantics. Constants are immediates, meaning that they can be used directly in instructions; there is no need for a "load constant" instruction.
<pre>The representation of integers is two's complement. Floating-point numbers are represented using the single-precision and double-precision formats of the IEEE 754 standard.</pre>
 
  
Константы определяют последовательность бит и являются нетипизированными. Они всегда анализируются как 64-битные блобы (прим. примерно тоже самое, что кластер). В зависимости от контекста, окружающего константу, могут использоваться только некоторые из ее битов. Например, в приведенной ниже программе обе указанные переменные имеют одинаковое значение, так как первый операнд вычитания представляет собой w - word (32-бит) контекст.
+
The representation of integers is two's complement. Floating-point numbers are represented using the single-precision and double-precision formats of the IEEE 754 standard.
<pre>Constants specify a sequence of bits and are untyped. They are always parsed as 64-bit blobs. Depending on the context surrounding a constant, only some of its bits are used. For example, in the program below, the two variables defined have the same value since the first operand of the subtraction is a word (32-bit) context.</pre>
+
 
 +
Constants specify a sequence of bits and are untyped. They are always parsed as 64-bit blobs. Depending on the context surrounding a constant, only some of its bits are used. For example, in the program below, the two variables defined have the same value since the first operand of the subtraction is a word (32-bit) context.
  
 
  %x =w sub -1, 0
 
  %x =w sub -1, 0
 
  %y =w sub 4294967295, 0
 
  %y =w sub 4294967295, 0
  
Поскольку указание констант с плавающей запятой на их биты делает код менее читаемым, то для их выражения предоставляется [https://ru.wikipedia.org/wiki/Синтаксический_сахар синтаксический сахар]. Стандартная экспоненциальная запись имеет префикс <code>s_</code> и <code>d_</code> для чисел с одной и двумя точками соответственно. Следующий пример определяет дважды ту же константу с двойной точностью.
+
Because specifying floating-point constants by their bits makes the code less readable, syntactic sugar is provided to express them. Standard scientific notation is prefixed with s_ and d_ for single and double precision numbers respectively. Once again, the following example defines twice the same double-precision constant.
<pre>Because specifying floating-point constants by their bits makes the code less readable, syntactic sugar is provided to express them. Standard scientific notation is prefixed with s_ and d_ for single and double precision numbers respectively. Once again, the following example defines twice the same double-precision constant.</pre>
 
  
 
  %x =d add d_0, d_-1
 
  %x =d add d_0, d_-1
 
  %y =d add d_0, -4616189618054758400
 
  %y =d add d_0, -4616189618054758400
 
+
Global symbols can also be used directly as constants; they will be resolved and turned into actual numeric constants by the linker.
Глобальные символы также могут использоваться непосредственно как константы; они будут разрешены и превращены в фактические числовые константы компоновщиком.
 
<pre>Global symbols can also be used directly as constants; they will be resolved and turned into actual numeric constants by the linker.</pre>
 

Пожалуйста, учтите, что любой ваш вклад в проект «Compilers Wiki» может быть отредактирован или удалён другими участниками. Если вы не хотите, чтобы кто-либо изменял ваши тексты, не помещайте их сюда.
Вы также подтверждаете, что являетесь автором вносимых дополнений, или скопировали их из источника, допускающего свободное распространение и изменение своего содержимого (см. Compilers Wiki:Авторские права). НЕ РАЗМЕЩАЙТЕ БЕЗ РАЗРЕШЕНИЯ ОХРАНЯЕМЫЕ АВТОРСКИМ ПРАВОМ МАТЕРИАЛЫ!