Advanced In-line Assembler

According to the Delphi 7 help file, you can use the general purpose 32-bit registers EAX, ECX and EDX "freely" in your in-line assembler code. The naming requires some explanation. The 16-bit Intel forerunners of modern processors contained the 16-bit general purpose registers AX, BX, CX and DX. The letters A, B, C, D, represent the terms accumulator, base, count and data. Each of these registers was divided into a lower byte and a higher byte. For example, AX was divided into AL and AH. In 32-bit processors, the 16-bit registers form the lower two bytes of the corresponding 32-bit registers. The letter E stands for "extended". This is summarised in a diagram for the accumulator.

Subdivisions of the accumulator

Subdivisions of the accumulator

In many situations the general purpose registers can be used interchangeably, but the loop instruction decrements only the count register. Also, specific registers are used for returning the results of some operations.

Addressing Modes

Immediate addressing occurs when an operand contains a value. Examples using Intel syntax are:

 MOV EAX, 25
 MOV EAX, 11001b
 MOV EAX, $19        

Each of these three statements loads the denary value 25 into the accumulator.

Direct addressing uses an operand which is the address of data e.g. MOV Product, EAX. This is similar to the way that we use variables in high-level programming; the name of a variable is used instead of the address that it represents.

Indexed addressing applies an offset to an address, for example to locate items in an array.

Indirect addressing uses an operand that contains an address.

Follow the links for demonstration programs on addressing modes and flags.

Programming - a skill for life!

In-line assembler with Intel and AT&T syntax, addressing methods and encryption