hi everybody :)

i've just bought a sun box on ebay, installed gnu/linux on it and am now trying to write a short assembler program. this seems to be very different from assembler on my tried and trusted pentium III.

anyway, i found a few guides on the net and tried stuff out, but whatever i do, the loader starts complaining about main being defined twice and other stuff :(

so the question is, can someone post a really short assembler program for sparc under linux so i can see how the structure is with instructions on how to assemble and link it?
(for example, what would
.section .data
.section .text
.global _start
_start:
movl $2, %ebx
movl $1, %eax
int $0x80

on a sparc or ultrasparc be?)

ta muchly :)

howie

yep, i've had a look at a fair bit of literature, none of which seems to provide a simple program which works. i did however solve the problem by using gcc -S on the following program:

int main()
{
int a, b;
a=3;
b=2;
return 0;
}

and then looking at the code. now i had of course tried this before, but i couldn't get it to assemble and link by using as and then ld. however, the code does compile if you use gcc on the .s file. so i had a look at the output of the gcc file and lo and behold:

.global main
main:

is where i was going wrong. for some reason, it doesn't like:
.global _main
_main:

don't ask me why not...

howie

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.