This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: $ in GNU as assembler



>    What is the meaning of $ in the GNU as assembler when it is prefixed
>to a number. For example, what is the difference between
>
>mov     $0x53, %al
>
>and 
>
>mov     0x53, %al.

The simple test case:

char a;
void b(void)
{
  a = 0x53;
}

void c(void)
{
  *(char *)(0x53) = a;
}

Compiles into:

b:
	pushl	%ebp
	movl	%esp, %ebp
	movb	$83, a
	popl	%ebp
	ret
c:
	pushl	%ebp
	movl	%esp, %ebp
	movb	a, %al
	movb	%al, 83
	popl	%ebp
	ret


So from this I'd conclude that the '$' is an immediate prefix to
indicate that it tells the assembler to load the value of 0x53(83)
into 'a' instead of loading the value at *memory address* 0x53 into
%al. 

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]