Assembly Language for Beginners

(Jeff_L) #1

1.28. 64-BIT VALUES IN 32-BIT ENVIRONMENT


Listing 1.370: Optimizing Keil 6/2013 (ARM mode)

||f|| PROC
LDR r0,|L0.12|
LDR r1,|L0.16|
BX lr
ENDP


|L0.12|
DCD 0x90abcdef
|L0.16|
DCD 0x12345678


MIPS


A 64-bit value is returned in theV0-V1($2-$3) register pair (V0($2) is for the high part andV1($3) for the
low part):


Listing 1.371: Optimizing GCC 4.4.5 (assembly listing)
li $3,-1867841536 # 0xffffffff90ab0000
li $2,305397760 # 0x12340000
ori $3,$3,0xcdef
j $31
ori $2,$2,0x5678

Listing 1.372: Optimizing GCC 4.4.5 (IDA)
lui $v1, 0x90AB
lui $v0, 0x1234
li $v1, 0x90ABCDEF
jr $ra
li $v0, 0x12345678

1.28.2 Arguments passing, addition, subtraction.


#include <stdint.h>


uint64_t f_add (uint64_t a, uint64_t b)
{
return a+b;
};


void f_add_test ()
{
#ifdef GNUC
printf ("%lld\n", f_add(12345678901234, 23456789012345));
#else
printf ("%I64d\n", f_add(12345678901234, 23456789012345));
#endif
};


uint64_t f_sub (uint64_t a, uint64_t b)
{
return a-b;
};


x86


Listing 1.373: Optimizing MSVC 2012 /Ob1

_a$ = 8 ; size = 8
_b$ = 16 ; size = 8
_f_add PROC

Free download pdf