Delphi帮助文档(翻译六)

The built-in assembler divides expressions into three classes: registers, memory references, and immediate values.

内嵌的汇编器把表达式分为3种类型:寄存器,内存引用和立即数.

An expression that consists solely of a register name is a register expression. Examples of register expressions are AX, CL, DI, and ES. Used

as operands, register expressions direct the assembler to generate instructions that operate on the CPU registers.

只包含一个寄存器名的表达式是寄存器表达式.寄存器表达式比如AX, CL, DI 和 ES.用做操作数,寄存器表达式直接使汇编器产生在CPU寄存器上操作的指令。

Expressions that denote memory locations are memory references. Delphi's labels, variables, typed constants, procedures, and functions belong to this category.

表示内存位置的表达式是内存引用。Delphi的标签,变量,类型常量,过程和函数属于这种类别。

Expressions that aren't registers and aren't associated with memory locations are immediate values. This group includes Delphi's untyped constants and type identifiers.

既不是寄存器也不跟内存位置有关的是立即数表达式。这一组包含Delphi的无类型常量和类型标志符。

Immediate values and memory references cause different code to be generated when used as operands. For example,

立即数和内存引用在用做操作数的时候导致不同的代码产生。比如。

 

const
  Start = 10;
var
  Count: Integer;
  ...
asm
  MOV     EAX,Start            { MOV EAX,xxxx }
  MOV     EBX,Count            { MOV EBX,[xxxx] }
  MOV     ECX,[Start]          { MOV ECX,[xxxx] }
  MOV     EDX,OFFSET Count     { MOV EDX,xxxx }
end;

2010060621581975.jpg 

Because Start is an immediate value, the first MOV is assembled into a move immediate instruction. The second MOV, however, is translated into

因为Start是一个立即数,第一个Mov被编译成一个移动立即数的指令。第二个Mov,然而翻译成一个移动内存的指令,Count作为一个内存引用。第三个Mov,括号把Start转换成一个内存引用(在这种情况下,在数据段中偏移为10的一个字的内容),第四个Mov,OFFSET操作符把Count转换为一个立即数(在数据段中的Count个偏移)。

a move memory instruction, as Count is a memory reference. In the third MOV, the brackets convert Start into a memory reference (in this case, the word at offset 10 in the data segment). In the fourth MOV, the OFFSET operator converts Count into an immediate value (the offset of Count in the data segment).

The brackets and OFFSET operator complement each other. The following asm statement produces identical machine code to the first two lines of the previous asm statement.

括号和OFFSET可以互相转换。在asm前的头2行汇编语句将产生同样的机器码。

asm
  MOV     EAX,OFFSET [Start]
  MOV     EBX,[OFFSET Count]
end;

Memory references and immediate values are further classified as either relocatable or absolute. Relocation is the process by which the linker assigns absolute addresses to symbols. A relocatable expression denotes a value that requires relocation at link time, while an absolute

立即数和内存引用是进步的分类作为重定位和绝对地址。

expression denotes a value that requires no such relocation. Typically, expressions that refer to labels, variables, procedures, or functions are relocatable, since the final address of these symbols is unknown at compile time. Expressions that operate solely on constants are absolute.

The built-in assembler allows you to carry out any operation on an absolute value, but it restricts operations on relocatable values to addition and subtraction of constants.

表示一个数值的表达式要求没有如此的重定位

典型地,引用标签,变量,过程和函数的表达式是可重定位的,因为这些标志符最终的地址在编译时是未知的

表达式操作常量是唯一的绝对

内嵌汇编允许你对一个绝对值进行任何操作,但是限制可重定位的值的加或者减常量的操作。

 

转载于:https://www.cnblogs.com/abcliu110/archive/2010/06/06/1752682.html

有原文有译文,下面是其中一段: Original Integer types An integer type represents a subset of the whole numbers. The generic integer types are Integer and Cardinal; use these whenever possible, since they result in the best performance for the underlying CPU and operating system. The table below gives their ranges and storage formats for the current 32-bit Object Pascal compiler. Type Range Format Integer -2147483648..2147483647 signed 32-bit Cardinal 0..4294967295 unsigned 32-bit Fundamental integer types include Shortint, Smallint, Longint, Int64, Byte, Word, and Longword. Type Range Format Shortint -128..127 signed 8-bit Smallint -32768..32767 signed 16-bit Longint -2147483648..2147483647 signed 32-bit Int64 -2^63..2^63 signed 64-bit Byte 0.255 unsigned 8-bit Word 0.65535 unsigned 16-bit Longword 0..4294967295 unsigned 32-bit In general, arithmetic operations on integers return a value of type Integer which, in its current implementation, is equivalent to the 32-bit Longint. Operations return a value of type Int64 only when performed on an Int64 operand. Hence the following code produces incorrect results. var I: Integer; J: Int64; ... I := High(Integer); J := I + 1; To get an Int64 return value in this situation, cast I as Int64: ... J := Int64(I) + 1; For more information, see Arithmetic operators. Note: Most standard routines that take integer arguments truncate Int64 values to 32 bits. However, the High, Low, Succ, Pred, Inc, Dec, IntToStr, and IntToHex routines fully support Int64 arguments. Also, the Round, Trunc, StrToInt64, and StrToInt64Def functions return Int64 values. A few routines including Ord cannot take Int64 values at all. When you increment the last value or decrement the first value of an integer type, the result wraps around the beginning or end of the range. For example, the Shortint type has the range -128..127; hence, after execution of the code var I: Shortint; ... I := High(Shortint); I := I + 1; the value of I is -128. If compiler range-checking is enabled, however, this code generates a runtime error. Topic groups See also Numerals Ordinal types: Overview Real types 译文 整数类型 整数类型表示全部数字的子界。一般的整数类型是Integer和Cardinal,需要时,应当尽可能地使用这两种类型,因为它们在各种CPU和操作系统中都提供最佳的性能。下面是当前32位Object Pascal编译器中这两种整数类型的范围和存储格式: 类型 范围 格式 Integer -2147483648..2147483647 含符号的32位 Cardinal 0..4294967295 无符号的32位 基本整数类型包括Shortint、Smallint、Longint、Int64、Byte、Word、Longword等,如下: 类型 范围 格式 Shortint -128..127 含符号的8位 Smallint -32768..32767 含符号的16位 Longint -2147483648..2147483647 含符号的32位 Int64 -2^63..2^63 含符号的64位 Byte 0.255 无符号的8位 Word 0.65535 无符号的16位 Longword 0..4294967295 无符号的32位 通常,作用于整数的算术运算符返回Integer类型的值,在当前执行中,等价于32位的长整型(LongInt)。仅当对Int64类型执行运算时,运算结果返回Int64类型。因此,下面的代码将执行后得到的结果是不正确的: var I: Integer; J: Int64; ... I := High(Integer); J := I + 1; 要使返回值是Int64类型,在上面的情况中可以将 I 转换为Int64: ... J := Int64(I) + 1; 更多信息见算术运算符。 注意:大多数标准例程在处理Int64值的时候,都将参数截断为32位。不过,High、Low、Succ、Pred、Inc、Dec、IntToStr、IntToHex等例程完全支持Int64参数。此外,Round、Trunc、StrToInt64、StrToInt64Def等函数也可以返回Int64值。少数例程根本不能将Int64值作为参数,如Ord。 对于整数类型,当要递增最后一个值或要递减第一个值的时候,运算结果将在范围的起点和中点之间环绕。例如,ShortInt类型的范围是 -128..127,因此,执行下面的代码: var I: Shortint; ... I := High(Shortint); I := I + 1; 之后,变量 I 的值为 –128。如果范围检查编译指示有效({$R+},缺省为{$R-}),那么上面的代码将产生一个运行时错误。 主题组 相关主题 数字 序数类型:概述 实数类型
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值