Pelles C forum

Pelles C => General discussions => Topic started by: Vortex on September 15, 2004, 10:56:28 PM

Title: Reference for the asm syntax
Post by: Vortex on September 15, 2004, 10:56:28 PM
Hi Pelle,

To create an asm listing, we use the /Tx86-asm option. My question is that have you a complete reference / manual explaining the asm syntax used by Pocc? Some statements appearing in the listing are unclear for me.
Example code:
Code: [Select]

#include <stdio.h>

void main(int argc,char *argv[])
{
char *s="Pelles C";
printf("%s",s);
}

Code: [Select]

pocc /Ze /Zx /Tx86-asm Sample.c

Code: [Select]

[cpu 486]
[global _main]
[section .text]
[function _main]
_main:
push ebp
mov ebp,esp
sub esp,4
lea eax,[(@2)]
mov dword [ebp+(-4)],eax
mov eax,dword [ebp+(-4)]
push dword eax
push dword (@3)
call _printf
add esp,(8+3)&(~3) ;This syntax?
@1:
mov esp,ebp
pop ebp
ret
..?X_main:     ; What does mean the symbols ..?X ?
[extern _printf]
[section .rdata]
@3:
db '%s',0
@2:
db 'Pelles C',0
[section .drectve]
db " -defaultlib:crt"


Many thanks,

Vortex
Title: Re: Reference for the asm syntax
Post by: Pelle on September 16, 2004, 12:16:37 AM
Hello Vortex,

Not really. Not many questions about it, so far. The basic syntax is probably closest to the NASM assembler, which was popular a few years back.

Code: [Select]

add esp,(8+3)&(~3) ;This syntax?

The purpose is to align the stack pointer to a DWORD. In this case it just tries to align the value 8, which is already aligned, but the compiler uses templates, so it sometimes looks more complicated than it is...

Code: [Select]

..?X_main:     ; What does mean the symbols ..?X ?

Labels starting with . (one dot) are local, labels starting with ..? are local and 'special', which (today) only means they don't end up in the debugging information.

Pelle
Title: Reference for the asm syntax
Post by: Vortex on September 16, 2004, 09:55:06 AM
Hi Pelle,

Thanks for the info.

To discover Pocc's asm syntax, I think the best method is to study the asm listings. ( and maybe to study also Nasm )