Assembly Language for Beginners

(Jeff_L) #1

1.32 ARM-specific details


Essentially,allinstructionsprefixedby-SD(“ScalarDouble-Precision”)—areinstructionsworkingwithfloat-
ing point numbers in IEEE 754 format, stored in the lower 64-bit half of a XMM register.

And it is easier than in the FPU, probably because the SIMD extensions were evolved in a less chaotic way
than the FPU ones in the past. The stack register model is not used.

If you would try to replacedoublewithfloat

in these examples, the same instructions will be used, but prefixed with-SS(“Scalar Single-Precision”),
for example,MOVSS,COMISS,ADDSS, etc.

“Scalar” implies that the SIMD register containing only one value instead of several.


Instructions working with several values in a register simultaneously have “Packed” in their name.

Needless to say, the SSE2 instructions work with 64-bit IEEE 754 numbers (double), while the internal
representation of the floating-point numbers in FPU is 80-bit numbers.

Hence, the FPU may produce less round-off errors and as a consequence, FPU may give more precise
calculation results.

1.32 ARM-specific details


1.32.1 Number sign (#) before number.


The Keil compiler,IDAand objdump precede all numbers with the “#” number sign, for example: list-
ing.1.16.1.

But when GCC 4.9 generates assembly language output, it doesn’t, for example: listing.3.15.

The ARM listings in this book are somewhat mixed.

It’s hard to say, which method is right. Supposedly, one has to obey the rules accepted in environment
he/she works in.

1.32.2 Addressing modes.


This instruction is possible in ARM64:

ldr x0, [x29,24]

This means add 24 to the value in X29 and load the value from this address.

Please note that 24 is inside the brackets. The meaning is different if the number is outside the brackets:

ldr w4, [x1],28

This means load the value at the address in X1, then add 28 to X1.

ARM allows you to add or subtract a constant to/from the address used for loading.

And it’s possible to do that both before and after loading.

There is no such addressing mode in x86, but it is present in some other processors, even on PDP-11.

There is a legend that the pre-increment, post-increment, pre-decrement and post-decrement modes in
PDP-11,

were “guilty” for the appearance of such C language (which developed on PDP-11) constructs as *ptr++,
*++ptr, *ptr--, *--ptr.

By the way, this is one of the hard to memorize C features. This is how it is:
Free download pdf