- 2.3.8. -
Table of Contents
2. TMT Pascal Language Description
2.3. Built-in Assembler
The following registers can appear in built-in assembler:
The segment register can be used for segment overrides. 32-bit registers
can be used for indexation following the standard 80386 conventions. 16-bit
registers should never be used for addressing, unless your entire program
does not exceed 64K. Even then,addressing with 16-bit registers is inefficient.
Generally, an address is formed as
|8-bit:||AL BL CL DL AH BH CH DH|
|16-bit:||AX BX CX DX SI DI BP SP|
|32-bit:||EAX EBX ECX EDX ESI EDI EBP ESP|
|Segment:||CS DS ES SS FS GS|
Base + Index * Scale + Displacement
where Base is any of the 32-bit registers, Index is any
32-bit register but not ESP, and Scale should be 1,2,4, or 8.
Finally, the Displacement is a 32-bit integer quantity.
Here are some valid and invalid indexing modes:
Intel™ 80386 programmer's reference for more details.
|[EAX+EAX]||ok, EAX is both base and index.|
|[ESP]||ok, ESP is index, no base.|
|[EDX*2]||ok, use this to index a global array of words.|
|[EAX*4+EBP]||ok, use this to index a local array of longints.|
|[SI]||ok, but is likely to lead to hard-to-find bugs.|
|[ESI+BX]||illegal, mix of 16- and 32- bit registers.|
|[SI*4]||illegal, 16-bit registers cannot be scaled.|
|[ESP*4]||illegal, ESP cannot be an index.|
- 2.3.8. -