AT&T Assembly

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mywyoo

AT&T Assembly

Post by mywyoo »

Hello, I would like to better my AT&T assembly but never seem to find just what I'm looking for. Also, please no "Just use NASM" responses.. I really would like to be as proficient in AT&T syntax as most people are in Intel, thanks.

I can declare small simple variables, or asciiz strings. I can't do other things like arrays, structures, pointers to arrays.. like char *x[20] in C, things like that. I have done arrays as:

Code: Select all

array:             # char array[400]; 
    .byte 0x0
    .zero 400  
I however don't know if this is the right way or not, and if it is, why.

for pointers arrays of strings I've done:

Code: Select all

str1:
    .asciz "str1"     

str2:
    .asciz "str2"     
    
pstr:
    .long str1
    .long str2
    .long 0x0
but again, is this correct or not? if it is, why?


I'm looking for some guide or something on how to declare all kinds of possible variables that have some kind of relationship with C, or TASM, forgot I still remember a thing or 2 about how TASM declares variables. Like say:

Code: Select all

x:
   .long 0x0
is the same as

Code: Select all

unsigned long x;
or something like that =)

Thanks for any help, and thanks to the people that run this site, I just ran across this site monday and have been reading like crazy. Finally a place that explains things in a way (so far) that I understand... now I have hopes that I may actually be able to write an OS, no matter how mediocre it may be. =))
Tom

Re:AT&T Assembly

Post by Tom »

yes, a .long is a long...and since I cant say use NASM, I will tell you this:
I don't know much AT&T syntax....
Tom

Re:AT&T Assembly

Post by Tom »

and a .byte in GAS will be a

char somechar; // in GCC
elias

Re:AT&T Assembly

Post by elias »

i hate AT&T syntax so much. its so ugly. use nasm instead
.bdjames

Re:AT&T Assembly

Post by .bdjames »

http://www.gnu.org/manual/gas-2.9.1/html_mono/as.html

a: .asciz "A string"
b: .long a

char a[] = "A string\0";
void * b = a;

c:
.fill 256,4,0

int c[256] = 0;
.bdjames

Re:AT&T Assembly

Post by .bdjames »

char a[] = "A string";
Tom

Re:AT&T Assembly

Post by Tom »

I think I'll learn AT&T syntax...makes programming easier in C/C++ with GCC.
mywyoo

Re:AT&T Assembly

Post by mywyoo »

Well, as I searched the net and did my 'gcc -S' all night with different declarations, GAS seems to treat structures as strings of bytes (yes, just what they are), I couldn't find anything that would let me make structures and access them via '.' operator... so I don't know if there is away to declare anything more than basic variables.

If you're serious Tom, I ran across a book mentioned at this site (which also has bunches of tutorials and information on doing assembly with gas):

http://linuxassembly.org/

The book, which has been a huge help to me in just one night, is here:

http://www.eskimo.com/~johnnyb/computers/ProgrammingGroundUp/

The book appears to be a work in progress, but it still had enough to help me where I needed it.

Thanks for everyone's help, unfortunately I have to go do this thanksgiving thing with the wife so I won't get to play with this any more today.

mywyoo
Post Reply