Re: A basic question on asm
From: Grumble (devnull_at_kma.eu.org)
Date: 09/24/04
- Next message: Calm n Collected: "How to code procs for masm"
- Previous message: C : "Re: A basic question on asm"
- In reply to: C : "Re: A basic question on asm"
- Next in thread: Percival : "Re: A basic question on asm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 24 Sep 2004 11:20:40 +0000 (UTC)
C wrote:
> Percival wrote:
>
>> Rong wrote:
>>
>>> I ran into this x86 sentence:
>>> mov %eax,(%esp,1)
>>> I am not sure what (%esp, 1) part mean.
>>> And I could not find the explanation in x86 manual.
>>> Can anyone explain a little?
>>
>> It is AT&T syntax. I am not familiar with it, but possibly the gas
>> manual or some sort should tell you what it means.
>>
>> My *GUESS*, and only a guess, is that it is mov [esp+1], [eax] in
>> intel syntax.
>>
>> But it is only a guess. I need to learn at&T syntax soon.
>
> Close, your example would be "mov %eax, 1(%esp)" in gas.
> "mov %eax, (%esp,1)" is "mov [esp], eax" the 1 being the scale
> so "mov %eax,(%ebx,2)" is "mov [ebx*2], eax".
Nope :-)
mov %eax, (%ebx,2) == mov [2*no_index_register+ebx], eax
In other words, it's probably a syntax error.
$ cat toto.s
mov %eax,(%ebx,1)
mov %eax,(%ebx,2)
mov %eax,(%ebx,4)
mov %eax,(%ebx,8)
mov %eax,(,%ebx,1)
mov %eax,(,%ebx,2)
mov %eax,(,%ebx,4)
mov %eax,(,%ebx,8)
$ as -v toto.s
GNU assembler version 2.13.90.0.18 (i386-redhat-linux) using BFD
version 2.13.90.0.18 20030206
toto.s: Assembler messages:
toto.s:2: Warning: scale factor of 2 without an index register
toto.s:3: Warning: scale factor of 4 without an index register
toto.s:4: Warning: scale factor of 8 without an index register
$ objdump -d a.out
a.out: file format elf32-i386
Disassembly of section .text:
00000000 <.text>:
0: 89 03 mov %eax,(%ebx)
2: 89 03 mov %eax,(%ebx)
4: 89 03 mov %eax,(%ebx)
6: 89 03 mov %eax,(%ebx)
8: 89 04 1d 00 00 00 00 mov %eax,0x0(,%ebx,1)
f: 89 04 5d 00 00 00 00 mov %eax,0x0(,%ebx,2)
16: 89 04 9d 00 00 00 00 mov %eax,0x0(,%ebx,4)
1d: 89 04 dd 00 00 00 00 mov %eax,0x0(,%ebx,8)
IMO, gas should reject mov %eax,(%ebx,1) as a syntax error on x86.
-- Regards, Grumble
- Next message: Calm n Collected: "How to code procs for masm"
- Previous message: C : "Re: A basic question on asm"
- In reply to: C : "Re: A basic question on asm"
- Next in thread: Percival : "Re: A basic question on asm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|